Spaces:
Sleeping
Sleeping
updated process_image args
Browse files
app.py
CHANGED
|
@@ -21,7 +21,7 @@ def load_sample_image(sample_name):
|
|
| 21 |
return Image.open(image_path)
|
| 22 |
return None
|
| 23 |
|
| 24 |
-
def process_image(sample_choice, uploaded_image, yolo_versions):
|
| 25 |
"""Process the image using selected YOLO models."""
|
| 26 |
# Load sample or uploaded image
|
| 27 |
if uploaded_image is not None:
|
|
@@ -37,7 +37,7 @@ def process_image(sample_choice, uploaded_image, yolo_versions):
|
|
| 37 |
# Apply selected models
|
| 38 |
for yolo_version in yolo_versions:
|
| 39 |
if yolo_version == "yolov5":
|
| 40 |
-
result_images.append(xai_yolov5(image))
|
| 41 |
elif yolo_version == "yolov8s":
|
| 42 |
result_images.append(xai_yolov8s(image))
|
| 43 |
else:
|
|
@@ -129,14 +129,14 @@ with gr.Blocks(css=custom_css) as interface:
|
|
| 129 |
|
| 130 |
|
| 131 |
# Multi-threaded processing
|
| 132 |
-
def run_both(sample_choice, uploaded_image, selected_models):
|
| 133 |
results = []
|
| 134 |
netron_html = ""
|
| 135 |
|
| 136 |
# Thread to process the image
|
| 137 |
def process_thread():
|
| 138 |
nonlocal results
|
| 139 |
-
results = process_image(sample_choice, uploaded_image, selected_models)
|
| 140 |
|
| 141 |
# Thread to generate Netron visualization
|
| 142 |
def netron_thread():
|
|
@@ -158,7 +158,7 @@ with gr.Blocks(css=custom_css) as interface:
|
|
| 158 |
# Run button click
|
| 159 |
run_button.click(
|
| 160 |
fn=run_both,
|
| 161 |
-
inputs=[sample_selection, upload_image, selected_models],
|
| 162 |
outputs=[result_gallery, netron_display, dff_gallery],
|
| 163 |
)
|
| 164 |
|
|
|
|
| 21 |
return Image.open(image_path)
|
| 22 |
return None
|
| 23 |
|
| 24 |
+
def process_image(sample_choice, uploaded_image, yolo_versions, target_lyr = -5, n_components = 8):
|
| 25 |
"""Process the image using selected YOLO models."""
|
| 26 |
# Load sample or uploaded image
|
| 27 |
if uploaded_image is not None:
|
|
|
|
| 37 |
# Apply selected models
|
| 38 |
for yolo_version in yolo_versions:
|
| 39 |
if yolo_version == "yolov5":
|
| 40 |
+
result_images.append(xai_yolov5(image, target_lyr = -5, n_components = 8))
|
| 41 |
elif yolo_version == "yolov8s":
|
| 42 |
result_images.append(xai_yolov8s(image))
|
| 43 |
else:
|
|
|
|
| 129 |
|
| 130 |
|
| 131 |
# Multi-threaded processing
|
| 132 |
+
def run_both(sample_choice, uploaded_image, selected_models, target_lyr = -5, n_components = 8):
|
| 133 |
results = []
|
| 134 |
netron_html = ""
|
| 135 |
|
| 136 |
# Thread to process the image
|
| 137 |
def process_thread():
|
| 138 |
nonlocal results
|
| 139 |
+
results = process_image(sample_choice, uploaded_image, selected_models, target_lyr = -5, n_components = 8)
|
| 140 |
|
| 141 |
# Thread to generate Netron visualization
|
| 142 |
def netron_thread():
|
|
|
|
| 158 |
# Run button click
|
| 159 |
run_button.click(
|
| 160 |
fn=run_both,
|
| 161 |
+
inputs=[sample_selection, upload_image, selected_models, target_lyr = -5, n_components = 8],
|
| 162 |
outputs=[result_gallery, netron_display, dff_gallery],
|
| 163 |
)
|
| 164 |
|