Spaces:
Sleeping
Sleeping
alrichardbollans
commited on
Commit
·
4db8fed
1
Parent(s):
e19254b
Add waiting spinner
Browse files
app.py
CHANGED
|
@@ -40,6 +40,7 @@ app_ui = ui.page_fluid(
|
|
| 40 |
|
| 41 |
def server(input, output, session: Session):
|
| 42 |
analysis_results = reactive.Value([])
|
|
|
|
| 43 |
|
| 44 |
@reactive.Effect
|
| 45 |
@reactive.event(input.analyze)
|
|
@@ -48,14 +49,25 @@ def server(input, output, session: Session):
|
|
| 48 |
if not files:
|
| 49 |
return
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
@output
|
| 57 |
@render.ui
|
| 58 |
def results_container():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
results = analysis_results.get()
|
| 60 |
if not results:
|
| 61 |
return ui.div("No results yet. Upload images and click 'Analyze'.",
|
|
|
|
| 40 |
|
| 41 |
def server(input, output, session: Session):
|
| 42 |
analysis_results = reactive.Value([])
|
| 43 |
+
is_running = reactive.Value(False) # Flag to enable/disable loading spinner
|
| 44 |
|
| 45 |
@reactive.Effect
|
| 46 |
@reactive.event(input.analyze)
|
|
|
|
| 49 |
if not files:
|
| 50 |
return
|
| 51 |
|
| 52 |
+
is_running.set(True)
|
| 53 |
+
try:
|
| 54 |
+
results = run_predictions(files)
|
| 55 |
+
print('DONE ALL PREDICTIONS')
|
| 56 |
+
analysis_results.set(results)
|
| 57 |
+
finally:
|
| 58 |
+
is_running.set(False)
|
| 59 |
+
|
| 60 |
|
| 61 |
@output
|
| 62 |
@render.ui
|
| 63 |
def results_container():
|
| 64 |
+
if is_running.get():
|
| 65 |
+
return ui.div(
|
| 66 |
+
ui.div(class_="spinner-border text-primary", role="status", style="width: 3rem; height: 3rem;"),
|
| 67 |
+
ui.div("Analyzing images, please wait...", class_="text-muted", style="margin-top: 10px;"),
|
| 68 |
+
style="text-align: center; margin-top: 30px;"
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
results = analysis_results.get()
|
| 72 |
if not results:
|
| 73 |
return ui.div("No results yet. Upload images and click 'Analyze'.",
|