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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
qim3d
Commits
82aa0238
Commit
82aa0238
authored
2 months ago
by
fima
Browse files
Options
Downloads
Plain Diff
Merge branch 'gradio_plot_flicker_fix' into 'main'
Gradio plot flicker fix See merge request
!142
parents
191449a5
6709038f
No related branches found
No related tags found
1 merge request
!142
Gradio plot flicker fix
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
qim3d/gui/data_explorer.py
+17
-3
17 additions, 3 deletions
qim3d/gui/data_explorer.py
qim3d/gui/local_thickness.py
+19
-0
19 additions, 0 deletions
qim3d/gui/local_thickness.py
with
36 additions
and
3 deletions
qim3d/gui/data_explorer.py
+
17
−
3
View file @
82aa0238
...
@@ -166,17 +166,31 @@ class Interface(BaseInterface):
...
@@ -166,17 +166,31 @@ class Interface(BaseInterface):
# Visualization and results
# Visualization and results
with
gr
.
Row
():
with
gr
.
Row
():
def
create_uniform_image
(
intensity
=
1
):
"""
Generates a blank image with a single color.
Gradio `gr.Plot` components will flicker if there is no default value.
bug fix on gradio version 4.44.0
"""
pixels
=
np
.
zeros
((
100
,
100
,
3
),
dtype
=
np
.
uint8
)
+
int
(
intensity
*
255
)
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
10
,
10
))
ax
.
imshow
(
pixels
,
interpolation
=
"
nearest
"
)
# Adjustments
ax
.
axis
(
"
off
"
)
fig
.
subplots_adjust
(
left
=
0
,
right
=
1
,
bottom
=
0
,
top
=
1
)
return
fig
# Z Slicer
# Z Slicer
with
gr
.
Column
(
visible
=
False
)
as
result_z_slicer
:
with
gr
.
Column
(
visible
=
False
)
as
result_z_slicer
:
zslice_plot
=
gr
.
Plot
(
label
=
"
Z slice
"
)
zslice_plot
=
gr
.
Plot
(
label
=
"
Z slice
"
,
value
=
create_uniform_image
(
1
)
)
zpos
=
gr
.
Slider
(
zpos
=
gr
.
Slider
(
minimum
=
0
,
maximum
=
1
,
value
=
0.5
,
step
=
0.01
,
label
=
"
Z position
"
minimum
=
0
,
maximum
=
1
,
value
=
0.5
,
step
=
0.01
,
label
=
"
Z position
"
)
)
# Y Slicer
# Y Slicer
with
gr
.
Column
(
visible
=
False
)
as
result_y_slicer
:
with
gr
.
Column
(
visible
=
False
)
as
result_y_slicer
:
yslice_plot
=
gr
.
Plot
(
label
=
"
Y slice
"
)
yslice_plot
=
gr
.
Plot
(
label
=
"
Y slice
"
,
value
=
create_uniform_image
(
1
)
)
ypos
=
gr
.
Slider
(
ypos
=
gr
.
Slider
(
minimum
=
0
,
maximum
=
1
,
value
=
0.5
,
step
=
0.01
,
label
=
"
Y position
"
minimum
=
0
,
maximum
=
1
,
value
=
0.5
,
step
=
0.01
,
label
=
"
Y position
"
...
@@ -184,7 +198,7 @@ class Interface(BaseInterface):
...
@@ -184,7 +198,7 @@ class Interface(BaseInterface):
# X Slicer
# X Slicer
with
gr
.
Column
(
visible
=
False
)
as
result_x_slicer
:
with
gr
.
Column
(
visible
=
False
)
as
result_x_slicer
:
xslice_plot
=
gr
.
Plot
(
label
=
"
X slice
"
)
xslice_plot
=
gr
.
Plot
(
label
=
"
X slice
"
,
value
=
create_uniform_image
(
1
)
)
xpos
=
gr
.
Slider
(
xpos
=
gr
.
Slider
(
minimum
=
0
,
maximum
=
1
,
value
=
0.5
,
step
=
0.01
,
label
=
"
X position
"
minimum
=
0
,
maximum
=
1
,
value
=
0.5
,
step
=
0.01
,
label
=
"
X position
"
...
...
This diff is collapsed.
Click to expand it.
qim3d/gui/local_thickness.py
+
19
−
0
View file @
82aa0238
...
@@ -163,29 +163,48 @@ class Interface(qim3d.gui.interface.InterfaceWithExamples):
...
@@ -163,29 +163,48 @@ class Interface(qim3d.gui.interface.InterfaceWithExamples):
with
gr
.
Column
(
scale
=
4
):
with
gr
.
Column
(
scale
=
4
):
def
create_uniform_image
(
intensity
=
1
):
"""
Generates a blank image with a single color.
Gradio `gr.Plot` components will flicker if there is no default value.
bug fix on gradio version 4.44.0
"""
pixels
=
np
.
zeros
((
100
,
100
,
3
),
dtype
=
np
.
uint8
)
+
int
(
intensity
*
255
)
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
10
,
10
))
ax
.
imshow
(
pixels
,
interpolation
=
"
nearest
"
)
# Adjustments
ax
.
axis
(
"
off
"
)
fig
.
subplots_adjust
(
left
=
0
,
right
=
1
,
bottom
=
0
,
top
=
1
)
return
fig
with
gr
.
Row
():
with
gr
.
Row
():
input_vol
=
gr
.
Plot
(
input_vol
=
gr
.
Plot
(
show_label
=
True
,
show_label
=
True
,
label
=
"
Original
"
,
label
=
"
Original
"
,
visible
=
True
,
visible
=
True
,
value
=
create_uniform_image
(),
)
)
binary_vol
=
gr
.
Plot
(
binary_vol
=
gr
.
Plot
(
show_label
=
True
,
show_label
=
True
,
label
=
"
Binary
"
,
label
=
"
Binary
"
,
visible
=
True
,
visible
=
True
,
value
=
create_uniform_image
(),
)
)
output_vol
=
gr
.
Plot
(
output_vol
=
gr
.
Plot
(
show_label
=
True
,
show_label
=
True
,
label
=
"
Local thickness
"
,
label
=
"
Local thickness
"
,
visible
=
True
,
visible
=
True
,
value
=
create_uniform_image
(),
)
)
with
gr
.
Row
():
with
gr
.
Row
():
histogram
=
gr
.
Plot
(
histogram
=
gr
.
Plot
(
show_label
=
True
,
show_label
=
True
,
label
=
"
Thickness histogram
"
,
label
=
"
Thickness histogram
"
,
visible
=
True
,
visible
=
True
,
value
=
create_uniform_image
(),
)
)
with
gr
.
Row
():
with
gr
.
Row
():
lt_output
=
gr
.
File
(
lt_output
=
gr
.
File
(
...
...
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