Spaces:
Running on Zero
Running on Zero
Refresh prediction count on page load
Browse files
app.py
CHANGED
|
@@ -96,6 +96,10 @@ def increment_prediction_count():
|
|
| 96 |
return None
|
| 97 |
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
def unload_cuda():
|
| 100 |
gc.collect()
|
| 101 |
torch.cuda.empty_cache()
|
|
@@ -492,6 +496,14 @@ with gr.Blocks(
|
|
| 492 |
if examples:
|
| 493 |
gr.Examples(examples=examples, inputs=input_image, label="Try an example")
|
| 494 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
|
| 496 |
if __name__ == "__main__":
|
| 497 |
demo.queue(default_concurrency_limit=1).launch()
|
|
|
|
| 96 |
return None
|
| 97 |
|
| 98 |
|
| 99 |
+
def get_prediction_count_text():
|
| 100 |
+
return format_prediction_count(read_prediction_count())
|
| 101 |
+
|
| 102 |
+
|
| 103 |
def unload_cuda():
|
| 104 |
gc.collect()
|
| 105 |
torch.cuda.empty_cache()
|
|
|
|
| 496 |
if examples:
|
| 497 |
gr.Examples(examples=examples, inputs=input_image, label="Try an example")
|
| 498 |
|
| 499 |
+
# Component defaults are fixed when the Space starts. Refresh the value
|
| 500 |
+
# for each browser session so visitors see predictions made by others.
|
| 501 |
+
demo.load(
|
| 502 |
+
fn=get_prediction_count_text,
|
| 503 |
+
outputs=prediction_count,
|
| 504 |
+
queue=False,
|
| 505 |
+
)
|
| 506 |
+
|
| 507 |
|
| 508 |
if __name__ == "__main__":
|
| 509 |
demo.queue(default_concurrency_limit=1).launch()
|