alikh02 commited on
Commit
d71ff14
Β·
verified Β·
1 Parent(s): f5c21e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -20
app.py CHANGED
@@ -1,18 +1,3 @@
1
- """
2
- 🌿 Weed Species Classifier β€” Hugging Face Spaces App
3
- =====================================================
4
- Deploy this to a Hugging Face Space (Gradio SDK).
5
-
6
- Steps:
7
- 1. Create a new Space at https://huggingface.co/spaces
8
- - Owner: your username
9
- - Space SDK: Gradio
10
- - Visibility: Public (free)
11
- 2. Upload this app.py and requirements.txt
12
- 3. Set the HF_MODEL_REPO secret in Space Settings β†’ Variables
13
- (or just hardcode your repo ID below)
14
- """
15
-
16
  import os
17
  import json
18
  import torch
@@ -23,16 +8,13 @@ from PIL import Image
23
  from torchvision import transforms
24
  from huggingface_hub import hf_hub_download
25
 
26
- # ── Config ────────────────────────────────────────────────────────────────────
27
- # Set this to your model repo, e.g. "your-username/weed-classifier"
28
  MODEL_REPO = os.environ.get("HF_MODEL_REPO", "your-username/weed-classifier")
29
 
30
- # ── Load model + class names ──────────────────────────────────────────────────
31
  print(f"Loading model from {MODEL_REPO}...")
32
 
33
  class_names_path = hf_hub_download(repo_id=MODEL_REPO, filename="class_names.json")
34
  with open(class_names_path) as f:
35
- # Keys are string indices from json; convert to int->str dict
36
  raw = json.load(f)
37
  idx_to_species = {int(k): v for k, v in raw.items()}
38
 
@@ -90,7 +72,6 @@ or crop, and tell you which species it is.
90
  """
91
 
92
  EXAMPLES = [
93
- # Add paths to example images here if you include them in your Space repo
94
  # ["examples/chinee_apple.jpg"],
95
  # ["examples/snakeweed.jpg"],
96
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import json
3
  import torch
 
8
  from torchvision import transforms
9
  from huggingface_hub import hf_hub_download
10
 
 
 
11
  MODEL_REPO = os.environ.get("HF_MODEL_REPO", "your-username/weed-classifier")
12
 
 
13
  print(f"Loading model from {MODEL_REPO}...")
14
 
15
  class_names_path = hf_hub_download(repo_id=MODEL_REPO, filename="class_names.json")
16
  with open(class_names_path) as f:
17
+
18
  raw = json.load(f)
19
  idx_to_species = {int(k): v for k, v in raw.items()}
20
 
 
72
  """
73
 
74
  EXAMPLES = [
 
75
  # ["examples/chinee_apple.jpg"],
76
  # ["examples/snakeweed.jpg"],
77
  ]