Spaces:
Running on Zero
Running on Zero
Upload 3 files
Browse files- README.md +4 -2
- app.py +9 -2
- requirements.txt +2 -0
README.md
CHANGED
|
@@ -11,7 +11,7 @@ pinned: false
|
|
| 11 |
|
| 12 |
# 🍦 Ice Cream Dataset + Counter — Gradio Space
|
| 13 |
|
| 14 |
-
This is the **Gradio
|
| 15 |
|
| 16 |
## What it does
|
| 17 |
|
|
@@ -33,7 +33,9 @@ No YOLO is used.
|
|
| 33 |
Create a new Space and choose:
|
| 34 |
|
| 35 |
- **SDK:** Gradio
|
| 36 |
-
- **Hardware:** GPU is
|
|
|
|
|
|
|
| 37 |
|
| 38 |
Then upload these files/folders:
|
| 39 |
|
|
|
|
| 11 |
|
| 12 |
# 🍦 Ice Cream Dataset + Counter — Gradio Space
|
| 13 |
|
| 14 |
+
This is the **Gradio + ZeroGPU-compatible** version of the uploaded Ice Cream Counter project. It does **not** use Docker, FastAPI, Uvicorn, or a custom HTML frontend.
|
| 15 |
|
| 16 |
## What it does
|
| 17 |
|
|
|
|
| 33 |
Create a new Space and choose:
|
| 34 |
|
| 35 |
- **SDK:** Gradio
|
| 36 |
+
- **Hardware:** ZeroGPU or a dedicated GPU is recommended for training
|
| 37 |
+
|
| 38 |
+
The app uses `@spaces.GPU` for training and counting, so it also boots correctly when the Space hardware is **ZeroGPU**.
|
| 39 |
|
| 40 |
Then upload these files/folders:
|
| 41 |
|
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import threading
|
|
| 8 |
from collections import Counter
|
| 9 |
from pathlib import Path
|
| 10 |
|
|
|
|
| 11 |
import gradio as gr
|
| 12 |
import torch
|
| 13 |
from PIL import Image, ImageDraw
|
|
@@ -304,6 +305,7 @@ def build_coco():
|
|
| 304 |
)
|
| 305 |
|
| 306 |
|
|
|
|
| 307 |
def run_training(epochs, batch_size, learning_rate):
|
| 308 |
global _training, _model
|
| 309 |
try:
|
|
@@ -344,6 +346,7 @@ def training_status():
|
|
| 344 |
return json.dumps(_training, indent=2)
|
| 345 |
|
| 346 |
|
|
|
|
| 347 |
def count_image(image):
|
| 348 |
if image is None:
|
| 349 |
return None, "Upload an image first.", {}
|
|
@@ -397,7 +400,7 @@ h1 { margin-bottom: 0.2rem !important; }
|
|
| 397 |
.status { padding: 10px 14px; border-radius: 10px; }
|
| 398 |
"""
|
| 399 |
|
| 400 |
-
with gr.Blocks(title="Ice Cream Dataset + Counter"
|
| 401 |
gr.Markdown("# 🍦 Ice Cream Dataset + Counter\nUpload and annotate training images, train RT-DETR, then count ice creams in new images.")
|
| 402 |
status = gr.Markdown(dataset_status(), elem_classes="status")
|
| 403 |
|
|
@@ -487,4 +490,8 @@ with gr.Blocks(title="Ice Cream Dataset + Counter", css=CSS) as demo:
|
|
| 487 |
None, [status, image_select, ann_class])
|
| 488 |
|
| 489 |
if __name__ == "__main__":
|
| 490 |
-
demo.queue().launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
from collections import Counter
|
| 9 |
from pathlib import Path
|
| 10 |
|
| 11 |
+
import spaces
|
| 12 |
import gradio as gr
|
| 13 |
import torch
|
| 14 |
from PIL import Image, ImageDraw
|
|
|
|
| 305 |
)
|
| 306 |
|
| 307 |
|
| 308 |
+
@spaces.GPU(duration=120)
|
| 309 |
def run_training(epochs, batch_size, learning_rate):
|
| 310 |
global _training, _model
|
| 311 |
try:
|
|
|
|
| 346 |
return json.dumps(_training, indent=2)
|
| 347 |
|
| 348 |
|
| 349 |
+
@spaces.GPU(duration=60)
|
| 350 |
def count_image(image):
|
| 351 |
if image is None:
|
| 352 |
return None, "Upload an image first.", {}
|
|
|
|
| 400 |
.status { padding: 10px 14px; border-radius: 10px; }
|
| 401 |
"""
|
| 402 |
|
| 403 |
+
with gr.Blocks(title="Ice Cream Dataset + Counter") as demo:
|
| 404 |
gr.Markdown("# 🍦 Ice Cream Dataset + Counter\nUpload and annotate training images, train RT-DETR, then count ice creams in new images.")
|
| 405 |
status = gr.Markdown(dataset_status(), elem_classes="status")
|
| 406 |
|
|
|
|
| 490 |
None, [status, image_select, ann_class])
|
| 491 |
|
| 492 |
if __name__ == "__main__":
|
| 493 |
+
demo.queue().launch(
|
| 494 |
+
server_name="0.0.0.0",
|
| 495 |
+
server_port=int(os.getenv("PORT", "7860")),
|
| 496 |
+
css=CSS,
|
| 497 |
+
)
|
requirements.txt
CHANGED
|
@@ -7,3 +7,5 @@ Pillow>=10.0
|
|
| 7 |
numpy>=1.26
|
| 8 |
tqdm>=4.66
|
| 9 |
pycocotools>=2.0.8
|
|
|
|
|
|
|
|
|
| 7 |
numpy>=1.26
|
| 8 |
tqdm>=4.66
|
| 9 |
pycocotools>=2.0.8
|
| 10 |
+
|
| 11 |
+
spaces>=0.40.0
|