Spaces:
Sleeping
Sleeping
π FINAL PUSH: Locked environment (Python 3.11) and stable dependencies.
Browse files
README.md
CHANGED
|
@@ -2,14 +2,6 @@
|
|
| 2 |
---
|
| 3 |
title: Sports Classifier
|
| 4 |
emoji: π
|
| 5 |
-
colorFrom: blue
|
| 6 |
-
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
-
python_version: 3.11
|
| 9 |
---
|
| 10 |
-
|
| 11 |
-
# Sports Classifier
|
| 12 |
-
|
| 13 |
-
A sports classifier trained on the images from Google using FastAI.
|
| 14 |
-
|
| 15 |
-
Deployed via Kaggle Notebooks.
|
|
|
|
| 2 |
---
|
| 3 |
title: Sports Classifier
|
| 4 |
emoji: π
|
|
|
|
|
|
|
| 5 |
sdk: gradio
|
| 6 |
+
python_version: 3.11
|
| 7 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -3,33 +3,31 @@ import gradio as gr
|
|
| 3 |
from fastai.vision.all import *
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
# --- Model Loading (Assumes model.pkl exists in the root) ---
|
| 7 |
try:
|
| 8 |
-
learn = load_learner('
|
| 9 |
-
except Exception:
|
| 10 |
-
print("Error loading
|
| 11 |
raise
|
| 12 |
|
| 13 |
labels = learn.dls.vocab
|
| 14 |
|
| 15 |
def predict(img):
|
| 16 |
img = PILImage.create(img)
|
| 17 |
-
pred, pred_idx, probs = learn.predict(img)
|
| 18 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 19 |
|
| 20 |
-
# --- Interface Setup ---
|
| 21 |
title = "Sports Classifier"
|
| 22 |
-
description = "A
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
if __name__ == "__main__":
|
| 35 |
demo.launch()
|
|
|
|
| 3 |
from fastai.vision.all import *
|
| 4 |
import os
|
| 5 |
|
|
|
|
| 6 |
try:
|
| 7 |
+
learn = load_learner('model.pkl')
|
| 8 |
+
except Exception as e:
|
| 9 |
+
print(f"Error loading model.pkl: {e}")
|
| 10 |
raise
|
| 11 |
|
| 12 |
labels = learn.dls.vocab
|
| 13 |
|
| 14 |
def predict(img):
|
| 15 |
img = PILImage.create(img)
|
| 16 |
+
pred, pred_idx, probs = learn.predict(img)
|
| 17 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 18 |
|
|
|
|
| 19 |
title = "Sports Classifier"
|
| 20 |
+
description = "A reliable deployment via minimal configuration."
|
| 21 |
+
examples = ["badminton.jpg", "cricket.jpg", "swimming.jpg"]
|
| 22 |
+
|
| 23 |
+
demo = gr.Interface(
|
| 24 |
+
fn=predict,
|
| 25 |
+
inputs=gr.Image(type="pil"),
|
| 26 |
+
outputs=gr.Label(num_top_classes=3),
|
| 27 |
+
title=title,
|
| 28 |
+
description=description,
|
| 29 |
+
examples=examples
|
| 30 |
+
)
|
| 31 |
|
| 32 |
if __name__ == "__main__":
|
| 33 |
demo.launch()
|
model.pkl
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6737d72a9326a58064d6cc1e9900e9eb4578971f1556e9ff43dfe5afa37ed2e8
|
| 3 |
+
size 87528813
|
requirements.txt
CHANGED
|
@@ -1,13 +1,8 @@
|
|
| 1 |
|
| 2 |
-
# Locked FastAI version (Stable)
|
| 3 |
fastai==2.7.12
|
| 4 |
-
# Locked PyTorch version (Stable)
|
| 5 |
torch<2.2
|
| 6 |
torchvision<0.16
|
| 7 |
-
|
| 8 |
-
# CRITICAL FIX: Lock NumPy to a 1.x version to avoid internal conflicts.
|
| 9 |
numpy<2.0
|
| 10 |
-
|
| 11 |
gradio
|
| 12 |
-
cloudpickle
|
| 13 |
-
|
|
|
|
| 1 |
|
|
|
|
| 2 |
fastai==2.7.12
|
|
|
|
| 3 |
torch<2.2
|
| 4 |
torchvision<0.16
|
|
|
|
|
|
|
| 5 |
numpy<2.0
|
|
|
|
| 6 |
gradio
|
| 7 |
+
cloudpickle
|
| 8 |
+
fasttransform
|