Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -223,6 +223,22 @@ def show_preview_from_url(url_input):
|
|
| 223 |
return gr.update(visible=False), gr.update(value=url_input, visible=True)
|
| 224 |
return gr.update(visible=False), gr.update(visible=False)
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
# Gradio Interface
|
| 227 |
with gr.Blocks() as demo:
|
| 228 |
gr.Markdown("## Unified Visual Intelligence System (UVIS)")
|
|
@@ -315,6 +331,14 @@ with gr.Blocks() as demo:
|
|
| 315 |
json_out = gr.JSON(label="Scene JSON")
|
| 316 |
zip_out = gr.File(label="Download Results")
|
| 317 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
media_upload.change(show_preview_from_upload, inputs=media_upload, outputs=[img_out, vid_out])
|
| 319 |
url.submit(show_preview_from_url, inputs=url, outputs=[img_out, vid_out])
|
| 320 |
|
|
|
|
| 223 |
return gr.update(visible=False), gr.update(value=url_input, visible=True)
|
| 224 |
return gr.update(visible=False), gr.update(visible=False)
|
| 225 |
|
| 226 |
+
|
| 227 |
+
def clear_model_cache():
|
| 228 |
+
"""
|
| 229 |
+
Deletes all model weight folders so they are redownloaded fresh.
|
| 230 |
+
"""
|
| 231 |
+
folders = [
|
| 232 |
+
"models/detection/weights",
|
| 233 |
+
"models/segmentation/weights",
|
| 234 |
+
"models/depth/weights"
|
| 235 |
+
]
|
| 236 |
+
for folder in folders:
|
| 237 |
+
shutil.rmtree(folder, ignore_errors=True)
|
| 238 |
+
logger.info(f" Cleared: {folder}")
|
| 239 |
+
return " Model cache cleared. Models will be reloaded on next run."
|
| 240 |
+
|
| 241 |
+
|
| 242 |
# Gradio Interface
|
| 243 |
with gr.Blocks() as demo:
|
| 244 |
gr.Markdown("## Unified Visual Intelligence System (UVIS)")
|
|
|
|
| 331 |
json_out = gr.JSON(label="Scene JSON")
|
| 332 |
zip_out = gr.File(label="Download Results")
|
| 333 |
|
| 334 |
+
|
| 335 |
+
with gr.Row():
|
| 336 |
+
clear_button = gr.Button("🧹 Clear Model Cache")
|
| 337 |
+
status_box = gr.Textbox(label="Status", interactive=False)
|
| 338 |
+
|
| 339 |
+
clear_button.click(fn=clear_model_cache, inputs=[], outputs=[status_box])
|
| 340 |
+
|
| 341 |
+
|
| 342 |
media_upload.change(show_preview_from_upload, inputs=media_upload, outputs=[img_out, vid_out])
|
| 343 |
url.submit(show_preview_from_url, inputs=url, outputs=[img_out, vid_out])
|
| 344 |
|