本文整理汇总了Python中ilastik.shell.projectManager.ProjectManager._importProject方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectManager._importProject方法的具体用法?Python ProjectManager._importProject怎么用?Python ProjectManager._importProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilastik.shell.projectManager.ProjectManager
的用法示例。
在下文中一共展示了ProjectManager._importProject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HeadlessShell
# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import _importProject [as 别名]
class HeadlessShell(object):
"""
For now, this class is just a stand-in for the GUI shell (used when running from the command line).
"""
def __init__(self, workflowClass):
self._workflowClass = workflowClass
self.projectManager = None
@property
def workflow(self):
return self.projectManager.workflow
def createBlankProjectFile(self, projectFilePath):
hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)
readOnly = False
self.projectManager = ProjectManager( self._workflowClass, headless=True )
self.projectManager._loadProject(hdf5File, projectFilePath, readOnly)
def openProjectPath(self, projectFilePath):
try:
# Open the project file
hdf5File, readOnly = ProjectManager.openProjectFile(projectFilePath)
# Create our project manager
# This instantiates the workflow and applies all settings from the project.
self.projectManager = ProjectManager( self._workflowClass, headless=True )
self.projectManager._loadProject(hdf5File, projectFilePath, readOnly = False)
except ProjectManager.ProjectVersionError:
# Couldn't open project. Try importing it.
oldProjectFilePath = projectFilePath
name, ext = os.path.splitext(oldProjectFilePath)
# Create a brand new project file.
projectFilePath = name + "_imported" + ext
logger.info("Importing project as '" + projectFilePath + "'")
hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)
# Create the project manager.
# Here, we provide an additional parameter: the path of the project we're importing from.
self.projectManager = ProjectManager( self._workflowClass, importFromPath=oldProjectFilePath, headless=True )
self.projectManager._importProject(importFromPath, hdf5File, projectFilePath,readOnly = False)
def closeCurrentProject(self):
self.projectManager._closeCurrentProject()
self.projectManager.cleanUp()
self.projectManager = None
示例2: HeadlessShell
# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import _importProject [as 别名]
class HeadlessShell(object):
"""
For now, this class is just a stand-in for the GUI shell (used when running from the command line).
"""
def __init__(self, workflow_cmdline_args=None):
self._workflow_cmdline_args = workflow_cmdline_args or []
self.projectManager = None
@property
def workflow(self):
return self.projectManager.workflow
def createAndLoadNewProject(self, newProjectFilePath, workflow_class):
hdf5File = ProjectManager.createBlankProjectFile(newProjectFilePath)
readOnly = False
self.projectManager = ProjectManager(
self, workflow_class, headless=True, workflow_cmdline_args=self._workflow_cmdline_args
)
self.projectManager._loadProject(hdf5File, newProjectFilePath, readOnly)
def openProjectFile(self, projectFilePath):
# Make sure all workflow sub-classes have been loaded,
# so we can detect the workflow type in the project.
import ilastik.workflows
try:
# Open the project file
hdf5File, workflow_class, _ = ProjectManager.openProjectFile(projectFilePath)
if workflow_class is None:
# If the project file has no known workflow, we assume pixel classification
import ilastik.workflows
workflow_class = ilastik.workflows.pixelClassification.PixelClassificationWorkflow
import warnings
warnings.warn(
"Your project file ({}) does not specify a workflow type. "
"Assuming Pixel Classification".format(projectFilePath)
)
# Create our project manager
# This instantiates the workflow and applies all settings from the project.
self.projectManager = ProjectManager(
self, workflow_class, headless=True, workflow_cmdline_args=self._workflow_cmdline_args
)
self.projectManager._loadProject(hdf5File, projectFilePath, readOnly=False)
except ProjectManager.ProjectVersionError:
# Couldn't open project. Try importing it.
oldProjectFilePath = projectFilePath
name, ext = os.path.splitext(oldProjectFilePath)
# Create a brand new project file.
projectFilePath = name + "_imported" + ext
logger.info("Importing project as '" + projectFilePath + "'")
hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)
# For now, we assume that any imported projects are pixel classification workflow projects.
import ilastik.workflows
default_workflow = ilastik.workflows.pixelClassification.PixelClassificationWorkflow
# Create the project manager.
# Here, we provide an additional parameter: the path of the project we're importing from.
self.projectManager = ProjectManager(
self, default_workflow, importFromPath=oldProjectFilePath, headless=True
)
self.projectManager._importProject(oldProjectFilePath, hdf5File, projectFilePath, readOnly=False)
def setAppletEnabled(self, applet, enabled):
"""
Provided here to satisfy the ShellABC.
For now, HeadlessShell has no concept of "enabled" or "disabled" applets.
"""
pass
def enableProjectChanges(self, enabled):
"""
Provided here to satisfy the ShellABC.
For now, HeadlessShell has no mechanism for closing projects.
"""
pass
def closeCurrentProject(self):
self.projectManager._closeCurrentProject()
self.projectManager.cleanUp()
self.projectManager = None
示例3: HeadlessShell
# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import _importProject [as 别名]
#.........这里部分代码省略.........
url_format = url_format.replace( field, '(?P<' + field + '>[^?/]+)' )
match = re.match( url_format, dvid_key_url )
if not match:
# DVID is the only url-based format we support right now.
# So if it looks like the user gave a URL that isn't a valid DVID node, then error.
raise RuntimeError("Invalid URL format for DVID key-value data: {}".format(projectFilePath))
fields = match.groupdict()
projectFilePath = ProjectManager.downloadProjectFromDvid( fields['hostname'],
fields['uuid'],
fields['kv_instance_name'],
fields['keyname'] )
return projectFilePath
def openProjectFile(self, projectFilePath, force_readonly=False):
# If the user gave a URL to a DVID key, then download the project file from dvid first.
# (So far, DVID is the only type of URL access we support for project files.)
if isUrl(projectFilePath):
projectFilePath = HeadlessShell.downloadProjectFromDvid(projectFilePath)
# Make sure all workflow sub-classes have been loaded,
# so we can detect the workflow type in the project.
import ilastik.workflows
try:
# Open the project file
hdf5File, workflow_class, readOnly = ProjectManager.openProjectFile(projectFilePath, force_readonly)
# If there are any "creation-time" command-line args saved to the project file,
# load them so that the workflow can be instantiated with the same settings
# that were used when the project was first created.
project_creation_args = []
if "workflow_cmdline_args" in hdf5File.keys():
if len(hdf5File["workflow_cmdline_args"]) > 0:
project_creation_args = map(str, hdf5File["workflow_cmdline_args"][...])
if workflow_class is None:
# If the project file has no known workflow, we assume pixel classification
import ilastik.workflows
workflow_class = ilastik.workflows.pixelClassification.PixelClassificationWorkflow
import warnings
warnings.warn( "Your project file ({}) does not specify a workflow type. "
"Assuming Pixel Classification".format( projectFilePath ) )
# Create our project manager
# This instantiates the workflow and applies all settings from the project.
self.projectManager = ProjectManager( self,
workflow_class,
headless=True,
workflow_cmdline_args=self._workflow_cmdline_args,
project_creation_args=project_creation_args )
self.projectManager._loadProject(hdf5File, projectFilePath, readOnly)
except ProjectManager.FileMissingError:
logger.error("Couldn't find project file: {}".format( projectFilePath ))
raise
except ProjectManager.ProjectVersionError:
# Couldn't open project. Try importing it.
oldProjectFilePath = projectFilePath
name, ext = os.path.splitext(oldProjectFilePath)
# Create a brand new project file.
projectFilePath = name + "_imported" + ext
logger.info("Importing project as '" + projectFilePath + "'")
hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)
# For now, we assume that any imported projects are pixel classification workflow projects.
import ilastik.workflows
default_workflow = ilastik.workflows.pixelClassification.PixelClassificationWorkflow
# Create the project manager.
self.projectManager = ProjectManager( self,
default_workflow,
headless=True,
workflow_cmdline_args=self._workflow_cmdline_args,
project_creation_args=self._workflow_cmdline_args )
self.projectManager._importProject(importFromPath, hdf5File, projectFilePath)
def setAppletEnabled(self, applet, enabled):
"""
Provided here to satisfy the ShellABC.
For now, HeadlessShell has no concept of "enabled" or "disabled" applets.
"""
pass
def isAppletEnabled(self, applet):
return False
def enableProjectChanges(self, enabled):
"""
Provided here to satisfy the ShellABC.
For now, HeadlessShell has no mechanism for closing projects.
"""
pass
def closeCurrentProject(self):
self.projectManager._closeCurrentProject()
self.projectManager.cleanUp()
self.projectManager = None
示例4: HeadlessShell
# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import _importProject [as 别名]
class HeadlessShell(object):
"""
For now, this class is just a stand-in for the GUI shell (used when running from the command line).
"""
def __init__(self, workflow_cmdline_args=None):
self._workflow_cmdline_args = workflow_cmdline_args or []
self.projectManager = None
@property
def workflow(self):
return self.projectManager.workflow
def createAndLoadNewProject(self, newProjectFilePath, workflow_class):
hdf5File = ProjectManager.createBlankProjectFile(newProjectFilePath)
readOnly = False
self.projectManager = ProjectManager( workflow_class,
headless=True,
workflow_cmdline_args=self._workflow_cmdline_args )
self.projectManager._loadProject(hdf5File, newProjectFilePath, readOnly)
def openProjectFile(self, projectFilePath):
# Make sure all workflow sub-classes have been loaded,
# so we can detect the workflow type in the project.
import ilastik.workflows
try:
# Open the project file
hdf5File, workflow_class, _ = ProjectManager.openProjectFile(projectFilePath)
# Create our project manager
# This instantiates the workflow and applies all settings from the project.
self.projectManager = ProjectManager( workflow_class,
headless=True,
workflow_cmdline_args=self._workflow_cmdline_args )
self.projectManager._loadProject(hdf5File, projectFilePath, readOnly = False)
except ProjectManager.ProjectVersionError:
# Couldn't open project. Try importing it.
oldProjectFilePath = projectFilePath
name, ext = os.path.splitext(oldProjectFilePath)
# Create a brand new project file.
projectFilePath = name + "_imported" + ext
logger.info("Importing project as '" + projectFilePath + "'")
hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)
# For now, we assume that any imported projects are pixel classification workflow projects.
import ilastik.workflows
default_workflow = ilastik.workflows.pixelClassification.PixelClassificationWorkflow
# Create the project manager.
# Here, we provide an additional parameter: the path of the project we're importing from.
self.projectManager = ProjectManager( default_workflow,
importFromPath=oldProjectFilePath,
headless=True )
self.projectManager._importProject(oldProjectFilePath, hdf5File, projectFilePath,readOnly = False)
def closeCurrentProject(self):
self.projectManager._closeCurrentProject()
self.projectManager.cleanUp()
self.projectManager = None