Spaces:
Runtime error
Runtime error
deploy at 2025-05-13 17:28:26.321602
Browse files- config.ini +6 -0
- main.py +5 -1
config.ini
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[DEFAULT]
|
| 2 |
+
dataset_id = space-backup
|
| 3 |
+
db_dir = data
|
| 4 |
+
private_backup = True
|
| 5 |
+
interval = 15
|
| 6 |
+
|
main.py
CHANGED
|
@@ -4,6 +4,7 @@ from PIL import Image
|
|
| 4 |
from io import BytesIO
|
| 5 |
from starlette.responses import JSONResponse
|
| 6 |
from fasthtml_hf import setup_hf_backup
|
|
|
|
| 7 |
|
| 8 |
app, rt = fast_app(pico=False, hdrs=(
|
| 9 |
Script(src="https://cdn.tailwindcss.com?plugins=forms,typography"),
|
|
@@ -211,7 +212,10 @@ def post(filename: str = "black.jpg"):
|
|
| 211 |
@rt('/process')
|
| 212 |
def get(filename: str = "black.jpg"):
|
| 213 |
# Model inference
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
| 215 |
prediction = labrador_learner.predict(filename)
|
| 216 |
|
| 217 |
# Extract prediction data
|
|
|
|
| 4 |
from io import BytesIO
|
| 5 |
from starlette.responses import JSONResponse
|
| 6 |
from fasthtml_hf import setup_hf_backup
|
| 7 |
+
import os
|
| 8 |
|
| 9 |
app, rt = fast_app(pico=False, hdrs=(
|
| 10 |
Script(src="https://cdn.tailwindcss.com?plugins=forms,typography"),
|
|
|
|
| 212 |
@rt('/process')
|
| 213 |
def get(filename: str = "black.jpg"):
|
| 214 |
# Model inference
|
| 215 |
+
base_dir = os.path.dirname(os.path.abspath(__file__))
|
| 216 |
+
model_path = os.path.join(base_dir, 'export.pkl')
|
| 217 |
+
|
| 218 |
+
labrador_learner = load_learner(model_path)
|
| 219 |
prediction = labrador_learner.predict(filename)
|
| 220 |
|
| 221 |
# Extract prediction data
|