Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qim3d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
qim3d
Commits
e00d3e57
Commit
e00d3e57
authored
1 year ago
by
fima
Browse files
Options
Downloads
Patches
Plain Diff
Local thickness gui update
parent
bc7c05d1
No related branches found
No related tags found
1 merge request
!13
Local thickness gui update
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
qim3d/gui/local_thickness.py
+42
-10
42 additions, 10 deletions
qim3d/gui/local_thickness.py
with
42 additions
and
10 deletions
qim3d/gui/local_thickness.py
+
42
−
10
View file @
e00d3e57
...
@@ -77,7 +77,8 @@ class Interface:
...
@@ -77,7 +77,8 @@ class Interface:
internal_tools
.
gradio_header
(
self
.
title
,
self
.
port
)
internal_tools
.
gradio_header
(
self
.
title
,
self
.
port
)
# Create gradio interfaces
# Create gradio interfaces
interface
=
self
.
create_interface
(
img
=
img
)
self
.
interface
=
self
.
create_interface
(
img
=
img
)
# Set gradio verbose level
# Set gradio verbose level
if
self
.
verbose
:
if
self
.
verbose
:
...
@@ -85,15 +86,38 @@ class Interface:
...
@@ -85,15 +86,38 @@ class Interface:
else
:
else
:
quiet
=
True
quiet
=
True
interface
.
launch
(
self
.
interface
.
launch
(
quiet
=
quiet
,
quiet
=
quiet
,
height
=
self
.
height
,
height
=
self
.
height
,
width
=
self
.
width
,
width
=
self
.
width
,
show_tips
=
False
,
show_tips
=
False
,
)
)
return
def
get_result
(
self
):
# Get the temporary files from gradio
temp_sets
=
self
.
interface
.
temp_file_sets
for
temp_set
in
temp_sets
:
if
"
localthickness
"
in
str
(
temp_set
):
# Get the lsit of the temporary files
temp_path_list
=
list
(
temp_set
)
# Files are not in creation order,
# so we need to get find the latest
creation_time_list
=
[]
for
path
in
temp_path_list
:
creation_time_list
.
append
(
os
.
path
.
getctime
(
path
))
# Get index for the latest file
file_idx
=
np
.
argmax
(
creation_time_list
)
# Load the temporary file
vol_lt
=
DataLoader
().
load
(
temp_path_list
[
file_idx
])
return
vol_lt
def
create_interface
(
self
,
img
=
None
):
def
create_interface
(
self
,
img
=
None
):
print
(
img
)
with
gr
.
Blocks
(
css
=
self
.
css_path
)
as
gradio_interface
:
with
gr
.
Blocks
(
css
=
self
.
css_path
)
as
gradio_interface
:
gr
.
Markdown
(
gr
.
Markdown
(
"
# 3D Local thickness
\n
Interface for _Fast local thickness in 3D and 2D_ (https://github.com/vedranaa/local-thickness)
"
"
# 3D Local thickness
\n
Interface for _Fast local thickness in 3D and 2D_ (https://github.com/vedranaa/local-thickness)
"
...
@@ -101,9 +125,14 @@ class Interface:
...
@@ -101,9 +125,14 @@ class Interface:
with
gr
.
Row
():
with
gr
.
Row
():
with
gr
.
Column
(
scale
=
1
,
min_width
=
320
):
with
gr
.
Column
(
scale
=
1
,
min_width
=
320
):
if
img
is
not
None
:
data
=
gr
.
State
(
value
=
img
)
else
:
with
gr
.
Tab
(
"
Input
"
):
with
gr
.
Tab
(
"
Input
"
):
data
=
gr
.
File
(
data
=
gr
.
File
(
show_label
=
False
,
elem_classes
=
"
file-input h-128
"
show_label
=
False
,
elem_classes
=
"
file-input h-128
"
,
value
=
img
,
)
)
with
gr
.
Tab
(
"
Examples
"
):
with
gr
.
Tab
(
"
Examples
"
):
gr
.
Examples
(
examples
=
self
.
img_examples
,
inputs
=
data
)
gr
.
Examples
(
examples
=
self
.
img_examples
,
inputs
=
data
)
...
@@ -289,7 +318,10 @@ class Pipeline:
...
@@ -289,7 +318,10 @@ class Pipeline:
def
process_input
(
self
,
session
):
def
process_input
(
self
,
session
):
# Load volume
# Load volume
try
:
session
.
vol
=
DataLoader
().
load
(
session
.
data
.
name
)
session
.
vol
=
DataLoader
().
load
(
session
.
data
.
name
)
except
:
session
.
vol
=
session
.
data
if
session
.
dark_objects
:
if
session
.
dark_objects
:
session
.
vol
=
np
.
invert
(
session
.
vol
)
session
.
vol
=
np
.
invert
(
session
.
vol
)
...
...
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