Spaces:
Running
on
Zero
Running
on
Zero
2025-07-31 20:34 π
Browse filesFixed a bug in app.py
app.py
CHANGED
@@ -242,7 +242,7 @@ def predict(image: Image.Image, variant_dataset: str, metric: str):
|
|
242 |
compute the total crowd count, and prepare the density map for display.
|
243 |
"""
|
244 |
global loaded_model
|
245 |
-
variant, dataset = variant_dataset.
|
246 |
|
247 |
if loaded_model is None:
|
248 |
|
@@ -374,7 +374,7 @@ def predict(image: Image.Image, variant_dataset: str, metric: str):
|
|
374 |
lambda_map = Image.blend(image_rgba, lambda_map, alpha=alpha)
|
375 |
complete_zero_map = Image.blend(image_rgba, complete_zero_map, alpha=alpha)
|
376 |
|
377 |
-
return image,
|
378 |
|
379 |
|
380 |
# -----------------------------
|
@@ -405,17 +405,18 @@ with gr.Blocks() as demo:
|
|
405 |
|
406 |
with gr.Column():
|
407 |
output_den_map = gr.Image(label="Predicted Density Map", type="pil")
|
|
|
|
|
|
|
|
|
408 |
output_structural_zero_map = gr.Image(label="Structural Zero Map", type="pil")
|
409 |
output_sampling_zero_map = gr.Image(label="Sampling Zero Map", type="pil")
|
410 |
-
output_lambda_map = gr.Image(label="Lambda Map", type="pil")
|
411 |
output_complete_zero_map = gr.Image(label="Complete Zero Map", type="pil")
|
412 |
-
|
413 |
-
output_text = gr.Textbox(label="Total Count")
|
414 |
|
415 |
submit_btn.click(
|
416 |
fn=predict,
|
417 |
inputs=[input_img, model_dropdown, metric_dropdown],
|
418 |
-
outputs=[input_img,
|
419 |
)
|
420 |
|
421 |
gr.Examples(
|
|
|
242 |
compute the total crowd count, and prepare the density map for display.
|
243 |
"""
|
244 |
global loaded_model
|
245 |
+
variant, dataset = variant_dataset.split(" @ ")
|
246 |
|
247 |
if loaded_model is None:
|
248 |
|
|
|
374 |
lambda_map = Image.blend(image_rgba, lambda_map, alpha=alpha)
|
375 |
complete_zero_map = Image.blend(image_rgba, complete_zero_map, alpha=alpha)
|
376 |
|
377 |
+
return image, den_map, lambda_map, round(count, 2), strucrual_zero_map, sampling_zero_map, complete_zero_map
|
378 |
|
379 |
|
380 |
# -----------------------------
|
|
|
405 |
|
406 |
with gr.Column():
|
407 |
output_den_map = gr.Image(label="Predicted Density Map", type="pil")
|
408 |
+
output_lambda_map = gr.Image(label="Lambda Map", type="pil")
|
409 |
+
output_text = gr.Textbox(label="Predicted Count")
|
410 |
+
|
411 |
+
with gr.Column():
|
412 |
output_structural_zero_map = gr.Image(label="Structural Zero Map", type="pil")
|
413 |
output_sampling_zero_map = gr.Image(label="Sampling Zero Map", type="pil")
|
|
|
414 |
output_complete_zero_map = gr.Image(label="Complete Zero Map", type="pil")
|
|
|
|
|
415 |
|
416 |
submit_btn.click(
|
417 |
fn=predict,
|
418 |
inputs=[input_img, model_dropdown, metric_dropdown],
|
419 |
+
outputs=[input_img, output_den_map, output_lambda_map, output_text, output_structural_zero_map, output_sampling_zero_map, output_complete_zero_map]
|
420 |
)
|
421 |
|
422 |
gr.Examples(
|