sks01dev commited on
Commit
f19ece8
Β·
1 Parent(s): 49e4e5c

πŸš€ FINAL PUSH: Locked environment (Python 3.11) and stable dependencies.

Browse files
Files changed (4) hide show
  1. README.md +1 -9
  2. app.py +15 -17
  3. model.pkl +2 -2
  4. requirements.txt +2 -7
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 # <--- THIS IS THE CRITICAL FIX for TypeError
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('export.pkl')
9
- except Exception:
10
- print("Error loading export.pkl. Check file path/existence.")
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 sports classifier trained on the images from Google. Created as a demo for Gradio and HuggingFace Spaces."
23
- article="<p style='text-align: center'><a href='www.linkedin.com/in/shivamkswarnkar' target='_blank'>Linkedin Profile</a></p>"
24
- enable_queue=True
25
- examples = ["badminton.jpg", "cricket.jpg", "swimming.jpg"]
26
- demo = gr.Interface(fn=predict,
27
- inputs=gr.Image(type="pil"),
28
- outputs=gr.Label(num_top_classes=3),
29
- title=title,
30
- description=description,
31
- article=article,
32
- examples=examples)
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:2b037e5eb7f44f17f0e22a0d9386696c068a7d1b9b0d0cfd4770d3144f22b222
3
- size 87546221
 
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
- scikit-image
 
1
 
 
2
  fastai==2.7.12
 
3
  torch<2.2
4
  torchvision<0.16
 
 
5
  numpy<2.0
 
6
  gradio
7
+ cloudpickle
8
+ fasttransform