Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YeaZ-GUI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
chadhat
YeaZ-GUI
Commits
21bf6909
Commit
21bf6909
authored
1 year ago
by
Farzaneh Labbaf
Browse files
Options
Downloads
Patches
Plain Diff
Make launch NN completely independent from GUI
parent
a4994d5a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Launch_NN_command_line.py
+21
-4
21 additions, 4 deletions
Launch_NN_command_line.py
with
21 additions
and
4 deletions
Launch_NN_command_line.py
+
21
−
4
View file @
21bf6909
...
@@ -15,18 +15,35 @@ sys.path.append("./disk")
...
@@ -15,18 +15,35 @@ sys.path.append("./disk")
#this file handles the interaction with the disk, so loading/saving images
#this file handles the interaction with the disk, so loading/saving images
#and masks and it also runs the neural network.
#and masks and it also runs the neural network.
from
GUI_main
import
App
from
segment
import
segment
from
segment
import
segment
import
Reader
as
nd
import
Reader
as
nd
import
argparse
import
argparse
import
skimage
import
skimage
import
neural_network
as
nn
import
neural_network
as
nn
def
LaunchPrediction
(
im
,
is_pc
,
pretrained_weights
=
None
):
"""
It launches the neural neutwork on the current image and creates
an hdf file with the prediction for the time T and corresponding FOV.
"""
im
=
skimage
.
exposure
.
equalize_adapthist
(
im
)
im
=
im
*
1.0
;
pred
=
nn
.
prediction
(
im
,
is_pc
,
pretrained_weights
)
return
pred
def
ThresholdPred
(
thvalue
,
pred
):
"""
Thresholds prediction with value
"""
if
thvalue
==
None
:
thresholdedmask
=
nn
.
threshold
(
pred
)
else
:
thresholdedmask
=
nn
.
threshold
(
pred
,
thvalue
)
return
thresholdedmask
def
LaunchInstanceSegmentation
(
reader
,
image_type
,
fov_indices
=
[
0
],
time_value1
=
0
,
time_value2
=
0
,
thr_val
=
None
,
min_seed_dist
=
5
,
path_to_weights
=
None
):
def
LaunchInstanceSegmentation
(
reader
,
image_type
,
fov_indices
=
[
0
],
time_value1
=
0
,
time_value2
=
0
,
thr_val
=
None
,
min_seed_dist
=
5
,
path_to_weights
=
None
):
"""
"""
"""
"""
# cannot have both path_to_weights and image_type supplied
# cannot have both path_to_weights and image_type supplied
if
(
image_type
is
not
None
)
and
(
path_to_weights
is
not
None
):
if
(
image_type
is
not
None
)
and
(
path_to_weights
is
not
None
):
print
(
"
image_type and path_to_weights cannot be both supplied.
"
)
print
(
"
image_type and path_to_weights cannot be both supplied.
"
)
...
@@ -58,7 +75,7 @@ def LaunchInstanceSegmentation(reader, image_type, fov_indices=[0], time_value1=
...
@@ -58,7 +75,7 @@ def LaunchInstanceSegmentation(reader, image_type, fov_indices=[0], time_value1=
im
=
reader
.
LoadOneImage
(
t
,
fov_ind
)
im
=
reader
.
LoadOneImage
(
t
,
fov_ind
)
try
:
try
:
pred
=
App
.
LaunchPrediction
(
im
,
is_pc
,
pretrained_weights
=
path_to_weights
)
pred
=
LaunchPrediction
(
im
,
is_pc
,
pretrained_weights
=
path_to_weights
)
except
ValueError
:
except
ValueError
:
print
(
'
Error!
'
,
print
(
'
Error!
'
,
'
The neural network weight files could not
'
'
The neural network weight files could not
'
...
@@ -67,7 +84,7 @@ def LaunchInstanceSegmentation(reader, image_type, fov_indices=[0], time_value1=
...
@@ -67,7 +84,7 @@ def LaunchInstanceSegmentation(reader, image_type, fov_indices=[0], time_value1=
'
the folder unet, or specify a path to a custom weights file with -w argument.
'
)
'
the folder unet, or specify a path to a custom weights file with -w argument.
'
)
return
return
thresh
=
App
.
ThresholdPred
(
thr_val
,
pred
)
thresh
=
ThresholdPred
(
thr_val
,
pred
)
seg
=
segment
(
thresh
,
pred
,
min_seed_dist
)
seg
=
segment
(
thresh
,
pred
,
min_seed_dist
)
reader
.
SaveMask
(
t
,
fov_ind
,
seg
)
reader
.
SaveMask
(
t
,
fov_ind
,
seg
)
print
(
'
--------- Finished segmenting.
'
)
print
(
'
--------- Finished segmenting.
'
)
...
...
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