Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SVLT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ALMF
SVLT
Commits
c2f02f84
Commit
c2f02f84
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Mocked up ilastik model classes
parent
125847bc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
model_server/ilastik.py
+68
-0
68 additions, 0 deletions
model_server/ilastik.py
with
68 additions
and
0 deletions
model_server/ilastik.py
0 → 100644
+
68
−
0
View file @
c2f02f84
import
os
from
ilastik
import
app
from
ilastik.applets.dataSelection
import
DatasetInfo
,
FilesystemDatasetInfo
from
ilastik.applets.dataSelection.opDataSelection
import
PreloadedArrayDatasetInfo
from
ilastik.workflows.pixelClassification
import
PixelClassificationWorkflow
from
ilastik.workflows.objectClassification.objectClassificationWorkflow
import
ObjectClassificationWorkflow
import
numpy
as
np
from
model_server.model
import
ImageToImageModel
,
ParameterExpectedError
class
IlastikImageToImageModel
(
ImageToImageModel
):
# workflows = {
# 'pixel_classification': PixelClassificationWorkflow,
# 'object_classification': ObjectClassificationWorkflow,
# }
def
__init__
(
self
,
params
,
autoload
=
True
):
super
().
__init__
(
autoload
,
params
)
if
'
project_file
'
not
in
params
or
not
os
.
path
.
exists
(
params
[
'
project_file
'
]):
raise
ParameterExpectedError
(
'
Ilastik model expects a project (*.ilp) file
'
)
self
.
project_file
=
params
[
'
project_file
'
]
def
load
(
self
):
os
.
environ
[
"
LAZYFLOW_THREADS
"
]
=
"
8
"
os
.
environ
[
"
LAZYFLOW_TOTAL_RAM_MB
"
]
=
"
24000
"
args
=
app
.
parse_args
([])
args
.
headless
=
True
args
.
project
=
self
.
project_file
shell
=
app
.
main
(
args
)
if
shell
.
workflow
.
__class__
!=
self
.
workflow
:
raise
ParameterExpectedError
(
f
'
Ilastik project file
{
self
.
project_file
}
does not describe an instance of
{
shell
.
workflow
.
__class__
}
'
)
self
.
operator
=
self
.
get_top_level_operator
(
shell
.
workflow
)
self
.
shell
=
shell
@staticmethod
def
get_top_level_operator
(
workflow
):
if
isinstance
(
workflow
,
PixelClassificationWorkflow
):
return
workflow
.
pcApplet
.
topLevelOperator
elif
isinstance
(
workflow
,
ObjectClassificationWorkflow
):
return
workflow
.
objectClassificationApplet
.
topLevelOperator
# def infer(self, img, channel=None) -> (np.ndarray, dict):
# assert self.operator.Classifier.ready()
class
IlastikPixelClassifierModel
(
IlastikImageToImageModel
):
workflow
=
PixelClassificationWorkflow
def
infer
(
self
,
input_img
:
np
.
ndarray
,
channel
=
None
)
->
(
np
.
ndarray
,
dict
):
dsi
=
[
{
'
Raw Data
'
:
PreloadedArrayDatasetInfo
(
preloaded_array
=
input_img
),
}
]
pxmap
=
self
.
shell
.
workflow
.
batchProcessingApplet
.
run_export
(
dsi
,
export_to_array
=
True
)
return
pxmap
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment