Commit
·
6e43639
1
Parent(s):
a3d87d4
Update app.py
Browse files
app.py
CHANGED
@@ -24,16 +24,12 @@ def _generate_center_coordinates(l_x):
|
|
24 |
|
25 |
def build_projection_operator(l_x, n_dir):
|
26 |
"""Compute the tomography design matrix.
|
27 |
-
|
28 |
Parameters
|
29 |
----------
|
30 |
-
|
31 |
l_x : int
|
32 |
linear size of image array
|
33 |
-
|
34 |
n_dir : int
|
35 |
number of angles at which projections are acquired.
|
36 |
-
|
37 |
Returns
|
38 |
-------
|
39 |
p : sparse matrix of shape (n_dir l_x, l_x**2)
|
@@ -110,15 +106,16 @@ def Generate_synthetic_images_and_projections(l,alpha_l2,alpha_l1):
|
|
110 |
|
111 |
title = "Compressive sensing: Tomography reconstruction with L1 prior (Lasso)"
|
112 |
|
113 |
-
des="""This example
|
114 |
-
|
115 |
-
In comparison, other methods of reconstruction, such as the Ridge algorithm, produce a large number of labeling errors for the pixels.
|
116 |
-
The example demonstrates the effectiveness of the Lasso algorithm for image reconstruction from a small number of projections. This is a promising technique for applications where it is not possible or practical to acquire a large number of projections, such as in medical imaging or in astronomy."""
|
117 |
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
120 |
gr.Markdown(f"{des}")
|
121 |
-
gr.Markdown("This demo is based on this [scikit-learn example](https://scikit-learn.org/stable/auto_examples/applications/plot_tomography_l1_reconstruction.html#sphx-glr-auto-examples-applications-plot-tomography-l1-reconstruction-py).")
|
122 |
|
123 |
with gr.Row():
|
124 |
l=gr.Slider(minimum=100, maximum=500, step=1, value = 128, label = "Linear size")
|
@@ -126,8 +123,9 @@ with gr.Blocks(title=title) as demo:
|
|
126 |
alpha_l1=gr.Slider(minimum=0, maximum=1, step=0.001, value = 0.001, label = "alpha l1")
|
127 |
|
128 |
|
|
|
129 |
output = gr.Image()
|
130 |
btn = gr.Button(value="Submit")
|
131 |
-
btn.click(
|
132 |
-
|
133 |
-
demo.launch()
|
|
|
24 |
|
25 |
def build_projection_operator(l_x, n_dir):
|
26 |
"""Compute the tomography design matrix.
|
|
|
27 |
Parameters
|
28 |
----------
|
|
|
29 |
l_x : int
|
30 |
linear size of image array
|
|
|
31 |
n_dir : int
|
32 |
number of angles at which projections are acquired.
|
|
|
33 |
Returns
|
34 |
-------
|
35 |
p : sparse matrix of shape (n_dir l_x, l_x**2)
|
|
|
106 |
|
107 |
title = "Compressive sensing: Tomography reconstruction with L1 prior (Lasso)"
|
108 |
|
109 |
+
des="""This example illustrates the utilization of the Lasso algorithm to reconstruct an image from a collection of parallel projections taken at various angles.
|
110 |
+
It also highlights the capability of the Lasso algorithm to accurately reconstruct images with no errors, even when noise is present in the projections.
|
|
|
|
|
111 |
|
112 |
+
The example demonstrates the effectiveness of the Lasso algorithm in reconstructing images using only a limited number of projections.
|
113 |
+
In contrast, alternative reconstruction methods like the Ridge algorithm tend to introduce numerous labeling errors in the pixel reconstruction process"""
|
114 |
+
|
115 |
+
with gr.Blocks() as demo:
|
116 |
+
gr.Markdown("# Compressive sensing: Tomography reconstruction with L1 prior (Lasso)")
|
117 |
+
gr.Markdown("This demo is based on [Compressive sensing: Tomography reconstruction with L1 prior (Lasso)](https://scikit-learn.org/stable/auto_examples/applications/plot_tomography_l1_reconstruction.html#sphx-glr-auto-examples-applications-plot-tomography-l1-reconstruction-py).")
|
118 |
gr.Markdown(f"{des}")
|
|
|
119 |
|
120 |
with gr.Row():
|
121 |
l=gr.Slider(minimum=100, maximum=500, step=1, value = 128, label = "Linear size")
|
|
|
123 |
alpha_l1=gr.Slider(minimum=0, maximum=1, step=0.001, value = 0.001, label = "alpha l1")
|
124 |
|
125 |
|
126 |
+
|
127 |
output = gr.Image()
|
128 |
btn = gr.Button(value="Submit")
|
129 |
+
btn.click(Generate_synthetic_images_and_projections,[l,alpha_l2,alpha_l1],output)
|
130 |
+
|
131 |
+
demo.launch()
|