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
beac602c
Commit
beac602c
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Merged in from master
parent
6cf4f1c0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
model_server/accessors.py
+3
-8
3 additions, 8 deletions
model_server/accessors.py
model_server/process.py
+14
-0
14 additions, 0 deletions
model_server/process.py
model_server/util.py
+0
-4
0 additions, 4 deletions
model_server/util.py
tests/test_api.py
+1
-1
1 addition, 1 deletion
tests/test_api.py
with
18 additions
and
13 deletions
model_server/accessors.py
+
3
−
8
View file @
beac602c
from
abc
import
ABC
,
abstractmethod
from
abc
import
ABC
,
abstractmethod
import
os
import
os
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Dict
import
numpy
as
np
import
numpy
as
np
from
skimage.io
import
imread
from
skimage.io
import
imread
...
@@ -9,6 +8,8 @@ from skimage.io import imread
...
@@ -9,6 +8,8 @@ from skimage.io import imread
import
czifile
import
czifile
import
tifffile
import
tifffile
from
model_server.process
import
is_mask
class
GenericImageDataAccessor
(
ABC
):
class
GenericImageDataAccessor
(
ABC
):
@abstractmethod
@abstractmethod
...
@@ -34,13 +35,7 @@ class GenericImageDataAccessor(ABC):
...
@@ -34,13 +35,7 @@ class GenericImageDataAccessor(ABC):
return
True
if
self
.
shape_dict
[
'
Z
'
]
>
1
else
False
return
True
if
self
.
shape_dict
[
'
Z
'
]
>
1
else
False
def
is_mask
(
self
):
def
is_mask
(
self
):
if
self
.
_data
.
dtype
==
'
bool
'
:
return
is_mask
(
self
.
_data
)
return
True
elif
self
.
_data
.
dtype
==
'
uint8
'
:
unique
=
np
.
unique
(
self
.
_data
)
if
unique
.
shape
[
0
]
==
2
and
np
.
all
(
unique
==
[
0
,
255
]):
return
True
return
False
def
get_one_channel_data
(
self
,
channel
:
int
):
def
get_one_channel_data
(
self
,
channel
:
int
):
c
=
int
(
channel
)
c
=
int
(
channel
)
...
...
This diff is collapsed.
Click to expand it.
model_server/process.py
+
14
−
0
View file @
beac602c
...
@@ -6,6 +6,20 @@ from math import ceil, floor
...
@@ -6,6 +6,20 @@ from math import ceil, floor
import
numpy
as
np
import
numpy
as
np
from
skimage.exposure
import
rescale_intensity
from
skimage.exposure
import
rescale_intensity
def
is_mask
(
img
):
"""
Return True if an image represents a binary mask
:param img: np.ndarray
"""
if
img
.
dtype
==
'
bool
'
:
return
True
elif
img
.
dtype
==
'
uint8
'
:
unique
=
np
.
unique
(
img
)
if
unique
.
shape
[
0
]
==
2
and
np
.
all
(
unique
==
[
0
,
255
]):
return
True
return
False
def
pad
(
yxcz
,
mpx
:
int
):
def
pad
(
yxcz
,
mpx
:
int
):
"""
"""
Pad and crop image data in Y and X axes to meet specific dimension
Pad and crop image data in Y and X axes to meet specific dimension
...
...
This diff is collapsed.
Click to expand it.
model_server/util.py
+
0
−
4
View file @
beac602c
from
pathlib
import
Path
from
pathlib
import
Path
import
re
import
re
from
time
import
localtime
,
strftime
from
time
import
localtime
,
strftime
from
typing
import
List
import
pandas
as
pd
import
pandas
as
pd
from
model_server.accessors
import
InMemoryDataAccessor
,
write_accessor_data_to_file
from
model_server.accessors
import
InMemoryDataAccessor
,
write_accessor_data_to_file
from
model_server.models
import
Model
def
autonumber_new_directory
(
where
:
str
,
prefix
:
str
)
->
str
:
def
autonumber_new_directory
(
where
:
str
,
prefix
:
str
)
->
str
:
"""
"""
...
@@ -77,7 +75,6 @@ def loop_workflow(
...
@@ -77,7 +75,6 @@ def loop_workflow(
files
:
list
,
files
:
list
,
output_folder_path
:
str
,
output_folder_path
:
str
,
workflow_func
:
callable
,
workflow_func
:
callable
,
models
:
List
[
Model
],
params
:
dict
,
params
:
dict
,
export_batch_csvs
:
bool
=
True
,
export_batch_csvs
:
bool
=
True
,
write_intermediate_products
:
bool
=
True
,
write_intermediate_products
:
bool
=
True
,
...
@@ -98,7 +95,6 @@ def loop_workflow(
...
@@ -98,7 +95,6 @@ def loop_workflow(
export_kwargs
=
{
export_kwargs
=
{
'
input_file_path
'
:
ff
,
'
input_file_path
'
:
ff
,
'
output_folder_path
'
:
output_folder_path
,
'
output_folder_path
'
:
output_folder_path
,
'
models
'
:
models
,
**
params
,
**
params
,
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/test_api.py
+
1
−
1
View file @
beac602c
...
@@ -14,7 +14,7 @@ class TestServerBaseClass(unittest.TestCase):
...
@@ -14,7 +14,7 @@ class TestServerBaseClass(unittest.TestCase):
self
.
server_process
=
Process
(
self
.
server_process
=
Process
(
target
=
uvicorn
.
run
,
target
=
uvicorn
.
run
,
args
=
(
'
api:app
'
,
),
args
=
(
'
model_server.
api:app
'
,
),
kwargs
=
{
'
host
'
:
host
,
'
port
'
:
port
,
'
log_level
'
:
'
debug
'
},
kwargs
=
{
'
host
'
:
host
,
'
port
'
:
port
,
'
log_level
'
:
'
debug
'
},
daemon
=
True
daemon
=
True
)
)
...
...
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