kebincontreras
commited on
Commit
•
aa91e1a
1
Parent(s):
278f8b0
Update app.py
Browse files
app.py
CHANGED
@@ -13,12 +13,17 @@ import matplotlib.pyplot as plt
|
|
13 |
# Definir el tamaño de la imagen constante
|
14 |
IMAGE_SIZE = 640 # Asignar el valor constante para image_size
|
15 |
|
16 |
-
def process_image(image, model_id, sat_factor,
|
17 |
# Definir valores fijos dentro de la función
|
18 |
conf_threshold = 0.85
|
19 |
correction = 1.0
|
20 |
kernel_size = 7 # Definir kernel_size como constante
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
original_image = np.array(image)
|
23 |
original_image = original_image - original_image.min()
|
24 |
original_image = original_image / original_image.max()
|
@@ -42,7 +47,7 @@ def process_image(image, model_id, sat_factor, DO, t, vertical):
|
|
42 |
clipped_annotated, clipped_detections = yolov10_inference((clipped_image*255.0).astype(np.uint8), "yolov10n", IMAGE_SIZE, conf_threshold)
|
43 |
wrapped_annotated, wrapped_detections = yolov10_inference(wrapped_image, model_id, IMAGE_SIZE, conf_threshold)
|
44 |
|
45 |
-
recon_image = recons(img_tensor, DO=
|
46 |
recon_image_pil = transforms.ToPILImage()(recon_image.squeeze(0))
|
47 |
recon_image_np = np.array(recon_image_pil).astype(np.uint8)
|
48 |
|
@@ -86,12 +91,12 @@ def app():
|
|
86 |
}}
|
87 |
.custom-button {{
|
88 |
display: inline-block;
|
89 |
-
padding: 10px
|
90 |
-
font-size:
|
91 |
font-weight: bold;
|
92 |
color: white;
|
93 |
border-radius: 5px;
|
94 |
-
margin:
|
95 |
text-decoration: none;
|
96 |
text-align: center;
|
97 |
}}
|
@@ -101,6 +106,10 @@ def app():
|
|
101 |
.btn-red {{
|
102 |
background-color: #e94e42;
|
103 |
}}
|
|
|
|
|
|
|
|
|
104 |
""") as demo:
|
105 |
gr.Markdown("## Modulo Imaging for Computer Vision", elem_id="centered-title")
|
106 |
|
@@ -113,34 +122,49 @@ def app():
|
|
113 |
gr.Markdown("### Autoregressive High-Order Finite Difference Modulo Imaging: High-Dynamic Range for Computer Vision Applications", elem_id="centered-text")
|
114 |
gr.HTML('<a href="https://cvlai.net/aim/2024/" target="_blank" class="custom-button btn-red">Article</a>')
|
115 |
|
116 |
-
image = gr.Image(type="pil", label="Upload Image")
|
|
|
117 |
model_id = gr.Dropdown(label="Model", choices=["yolov10n", "yolov10s", "yolov10m", "yolov10b", "yolov10l", "yolov10x"], value="yolov10x")
|
118 |
-
|
119 |
sat_factor = gr.Slider(label="Saturation Factor", minimum=1.0, maximum=5.0, step=0.1, value=2.0)
|
120 |
-
DO = gr.Radio(label="DO", choices=["1", "2"], value="1")
|
121 |
-
t = gr.Slider(label="t", minimum=0.0, maximum=1.0, step=0.1, value=0.7)
|
122 |
-
vertical = gr.Radio(label="Vertical", choices=["True", "False"], value="True")
|
123 |
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
127 |
|
128 |
process_button = gr.Button("Process Image")
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
with gr.Row():
|
131 |
with gr.Column():
|
132 |
-
output_original = gr.Image(label="
|
133 |
-
|
134 |
with gr.Column():
|
135 |
-
|
136 |
-
output_recons = gr.Image(label="
|
137 |
|
138 |
process_button.click(
|
139 |
fn=process_image,
|
140 |
-
inputs=[image, model_id, sat_factor,
|
141 |
outputs=[output_original, output_clip, output_wrap, output_recons]
|
142 |
)
|
143 |
|
|
|
|
|
144 |
return demo
|
145 |
|
146 |
if __name__ == "__main__":
|
|
|
13 |
# Definir el tamaño de la imagen constante
|
14 |
IMAGE_SIZE = 640 # Asignar el valor constante para image_size
|
15 |
|
16 |
+
def process_image(image, model_id, sat_factor, selected_method):
|
17 |
# Definir valores fijos dentro de la función
|
18 |
conf_threshold = 0.85
|
19 |
correction = 1.0
|
20 |
kernel_size = 7 # Definir kernel_size como constante
|
21 |
|
22 |
+
# Valores fijos para DO, t y vertical
|
23 |
+
DO = 1
|
24 |
+
t = 0.7
|
25 |
+
vertical = True
|
26 |
+
|
27 |
original_image = np.array(image)
|
28 |
original_image = original_image - original_image.min()
|
29 |
original_image = original_image / original_image.max()
|
|
|
47 |
clipped_annotated, clipped_detections = yolov10_inference((clipped_image*255.0).astype(np.uint8), "yolov10n", IMAGE_SIZE, conf_threshold)
|
48 |
wrapped_annotated, wrapped_detections = yolov10_inference(wrapped_image, model_id, IMAGE_SIZE, conf_threshold)
|
49 |
|
50 |
+
recon_image = recons(img_tensor, DO=DO, L=1.0, vertical=vertical, t=t)
|
51 |
recon_image_pil = transforms.ToPILImage()(recon_image.squeeze(0))
|
52 |
recon_image_np = np.array(recon_image_pil).astype(np.uint8)
|
53 |
|
|
|
91 |
}}
|
92 |
.custom-button {{
|
93 |
display: inline-block;
|
94 |
+
padding: 5px 10px; /* Ajustar el tamaño del botón */
|
95 |
+
font-size: 12px; /* Reducir el tamaño de la fuente */
|
96 |
font-weight: bold;
|
97 |
color: white;
|
98 |
border-radius: 5px;
|
99 |
+
margin: 5px; /* Ajustar el margen */
|
100 |
text-decoration: none;
|
101 |
text-align: center;
|
102 |
}}
|
|
|
106 |
.btn-red {{
|
107 |
background-color: #e94e42;
|
108 |
}}
|
109 |
+
.gr-examples img {{
|
110 |
+
width: 200px; /* Ajusta este valor al doble del tamaño original */
|
111 |
+
height: 200px; /* Ajusta este valor al doble del tamaño original */
|
112 |
+
}}
|
113 |
""") as demo:
|
114 |
gr.Markdown("## Modulo Imaging for Computer Vision", elem_id="centered-title")
|
115 |
|
|
|
122 |
gr.Markdown("### Autoregressive High-Order Finite Difference Modulo Imaging: High-Dynamic Range for Computer Vision Applications", elem_id="centered-text")
|
123 |
gr.HTML('<a href="https://cvlai.net/aim/2024/" target="_blank" class="custom-button btn-red">Article</a>')
|
124 |
|
125 |
+
image = gr.Image(type="pil", label="Upload Image", interactive=True)
|
126 |
+
|
127 |
model_id = gr.Dropdown(label="Model", choices=["yolov10n", "yolov10s", "yolov10m", "yolov10b", "yolov10l", "yolov10x"], value="yolov10x")
|
|
|
128 |
sat_factor = gr.Slider(label="Saturation Factor", minimum=1.0, maximum=5.0, step=0.1, value=2.0)
|
|
|
|
|
|
|
129 |
|
130 |
+
selected_method = gr.Radio(
|
131 |
+
label="Select Method",
|
132 |
+
choices=["SPUD", "AHFD"],
|
133 |
+
value="SPUD"
|
134 |
+
)
|
135 |
|
136 |
process_button = gr.Button("Process Image")
|
137 |
|
138 |
+
# Agregar las imágenes de ejemplo al final con tamaño más grande
|
139 |
+
examples = [
|
140 |
+
["imagen1.png"],
|
141 |
+
["imagen2.png"],
|
142 |
+
["imagen3.png"],
|
143 |
+
["imagen4.png"]
|
144 |
+
]
|
145 |
+
|
146 |
+
gr.Examples(
|
147 |
+
examples=examples,
|
148 |
+
inputs=[image],
|
149 |
+
label="Choose an Example Image"
|
150 |
+
)
|
151 |
+
|
152 |
with gr.Row():
|
153 |
with gr.Column():
|
154 |
+
output_original = gr.Image(label="Real")
|
155 |
+
output_wrap = gr.Image(label="Modulo")
|
156 |
with gr.Column():
|
157 |
+
output_clip = gr.Image(label="Saturated")
|
158 |
+
output_recons = gr.Image(label="Recovery")
|
159 |
|
160 |
process_button.click(
|
161 |
fn=process_image,
|
162 |
+
inputs=[image, model_id, sat_factor, selected_method],
|
163 |
outputs=[output_original, output_clip, output_wrap, output_recons]
|
164 |
)
|
165 |
|
166 |
+
|
167 |
+
|
168 |
return demo
|
169 |
|
170 |
if __name__ == "__main__":
|