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
e5661bce
Commit
e5661bce
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Consolidated ilastik model load API endpoints; report out error when loading project file
parent
2fd272e1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api.py
+18
-13
18 additions, 13 deletions
api.py
tests/test_ilastik.py
+9
-0
9 additions, 0 deletions
tests/test_ilastik.py
with
27 additions
and
13 deletions
api.py
+
18
−
13
View file @
e5661bce
...
...
@@ -3,7 +3,7 @@ from typing import Dict
from
fastapi
import
FastAPI
,
HTTPException
from
model_server.ilastik
import
IlastikPixelClassifierModel
,
IlastikObjectClassifierModel
from
model_server.model
import
DummyImageToImageModel
from
model_server.model
import
DummyImageToImageModel
,
ParameterExpectedError
from
model_server.session
import
Session
from
model_server.workflow
import
infer_image_to_image
...
...
@@ -39,23 +39,28 @@ def list_active_models():
def
load_dummy_model
()
->
dict
:
return
{
'
model_id
'
:
session
.
load_model
(
DummyImageToImageModel
)}
def
load_ilastik_model
(
model_class
,
project_file
):
try
:
result
=
{
'
model_id
'
:
session
.
load_model
(
model_class
,
{
'
project_file
'
:
project_file
}
)
}
except
(
FileNotFoundError
,
ParameterExpectedError
):
raise
HTTPException
(
status_code
=
404
,
detail
=
f
'
Could not load project file
{
project_file
}
'
,
)
return
result
@app.put
(
'
/models/ilastik/pixel_classification/load/
'
)
def
load_ilastik_pixel_classification_model
(
project_file
:
str
)
->
dict
:
return
{
'
model_id
'
:
session
.
load_model
(
IlastikPixelClassifierModel
,
{
'
project_file
'
:
project_file
}
)
}
return
load_ilastik_model
(
IlastikPixelClassifierModel
,
project_file
)
@app.put
(
'
/models/ilastik/object_classification/load/
'
)
def
load_ilastik_object_classification_model
(
project_file
:
str
)
->
dict
:
return
{
'
model_id
'
:
session
.
load_model
(
IlastikObjectClassifierModel
,
{
'
project_file
'
:
project_file
}
)
}
return
load_ilastik_model
(
IlastikObjectClassifierModel
,
project_file
)
@app.put
(
'
/infer/from_image_file
'
)
def
infer_img
(
model_id
:
str
,
input_filename
:
str
,
channel
:
int
=
None
)
->
dict
:
...
...
This diff is collapsed.
Click to expand it.
tests/test_ilastik.py
+
9
−
0
View file @
e5661bce
...
...
@@ -109,6 +109,15 @@ class TestIlastikPixelClassification(unittest.TestCase):
self
.
assertGreater
(
result
.
timer_results
[
'
inference
'
],
1.0
)
class
TestIlastikOverApi
(
TestServerBaseClass
):
def
test_httpexception_if_incorrect_project_file_loaded
(
self
):
resp_load
=
requests
.
put
(
self
.
uri
+
'
models/ilastik/pixel_classification/load/
'
,
params
=
{
'
project_file
'
:
'
improper.ilp
'
},
)
self
.
assertEqual
(
resp_load
.
status_code
,
404
)
def
test_load_ilastik_pixel_model
(
self
):
resp_load
=
requests
.
put
(
self
.
uri
+
'
models/ilastik/pixel_classification/load/
'
,
...
...
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