Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,3 @@
|
|
1 |
-
# Commented out IPython magic to ensure Python compatibility.
|
2 |
-
# %%capture
|
3 |
-
# !pip install gradio
|
4 |
-
|
5 |
import gradio as gr
|
6 |
from PIL import Image
|
7 |
import os
|
@@ -129,7 +125,7 @@ def plan_images_list():
|
|
129 |
return [file_ for file_ in os.listdir(images_file) if file_.endswith((".JPG", ".jpg", ".jpeg", ".png", ".PNG"))]
|
130 |
|
131 |
# MAIN FUNCTION ****************************************************************
|
132 |
-
def main_function(plan_name, interference = True, aps_int = 0, aps_coor = '(0,0)',
|
133 |
apch1 = 0, apch6 = 0, apch11 = 0, coord1 = '(0,0)', coord6 = '(0,0)', coord11 = '(0,0)'):
|
134 |
|
135 |
plan_name = str(plan_name)
|
@@ -168,11 +164,18 @@ def main_function(plan_name, interference = True, aps_int = 0, aps_coor = '(0,0)
|
|
168 |
# **************************************************************************
|
169 |
|
170 |
# Load plan
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
|
174 |
-
|
175 |
-
|
|
|
176 |
|
177 |
# Some variables init
|
178 |
deep_count = 0
|
@@ -616,6 +619,7 @@ with gr.Blocks() as demo:
|
|
616 |
# Único bloque para el clic de button2
|
617 |
button2.click(main_function,
|
618 |
inputs=[map_dropdown,
|
|
|
619 |
enable_interference,
|
620 |
simple_dropdown,
|
621 |
simple_coords,
|
@@ -623,4 +627,4 @@ with gr.Blocks() as demo:
|
|
623 |
coords_ch1_input, coords_ch6_input, coords_ch11_input],
|
624 |
outputs=[image_ch1, image_ch6, image_ch11, image_ap1, image_ap2, image_cover_final, image_cells])
|
625 |
|
626 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from PIL import Image
|
3 |
import os
|
|
|
125 |
return [file_ for file_ in os.listdir(images_file) if file_.endswith((".JPG", ".jpg", ".jpeg", ".png", ".PNG"))]
|
126 |
|
127 |
# MAIN FUNCTION ****************************************************************
|
128 |
+
def main_function(plan_name, uploaded_file, interference = True, aps_int = 0, aps_coor = '(0,0)',
|
129 |
apch1 = 0, apch6 = 0, apch11 = 0, coord1 = '(0,0)', coord6 = '(0,0)', coord11 = '(0,0)'):
|
130 |
|
131 |
plan_name = str(plan_name)
|
|
|
164 |
# **************************************************************************
|
165 |
|
166 |
# Load plan
|
167 |
+
if plan_name == "Upload your own image" and uploaded_file is not None:
|
168 |
+
plan_image = np.array(Image.open(uploaded_file.name))/255
|
169 |
+
plan_grayscale = plan_image[:, :, 0]
|
170 |
+
plan_in = 1 - plan_grayscale
|
171 |
+
|
172 |
+
elif plan_name == "Upload your own image" and uploaded_file is None:
|
173 |
+
numero = "100"
|
174 |
+
plan_in = np.array(Image.open(f"{path_main}Scennarios init/Scennarios B/{numero}.png")) / 255
|
175 |
|
176 |
+
else:
|
177 |
+
numero = plan_name.split('.')[0]
|
178 |
+
plan_in = np.array(Image.open(f"{path_main}Scennarios init/Scennarios B/{numero}.png")) / 255
|
179 |
|
180 |
# Some variables init
|
181 |
deep_count = 0
|
|
|
619 |
# Único bloque para el clic de button2
|
620 |
button2.click(main_function,
|
621 |
inputs=[map_dropdown,
|
622 |
+
upload_image,
|
623 |
enable_interference,
|
624 |
simple_dropdown,
|
625 |
simple_coords,
|
|
|
627 |
coords_ch1_input, coords_ch6_input, coords_ch11_input],
|
628 |
outputs=[image_ch1, image_ch6, image_ch11, image_ap1, image_ap2, image_cover_final, image_cells])
|
629 |
|
630 |
+
demo.launch()
|