Yassine Mhirsi commited on
Commit
3c91dc9
·
1 Parent(s): c8c6d4d

state farm dataset

Browse files
Files changed (2) hide show
  1. .gitignore +0 -2
  2. app/models/state_farm_model.py +8 -6
.gitignore CHANGED
@@ -1,7 +1,5 @@
1
  # Datasets - exclude all except samples and state-farm
2
  datasets/
3
- !datasets/text/val/
4
- !datasets/state-farm/
5
 
6
  # Environment
7
  .env
 
1
  # Datasets - exclude all except samples and state-farm
2
  datasets/
 
 
3
 
4
  # Environment
5
  .env
app/models/state_farm_model.py CHANGED
@@ -40,13 +40,15 @@ class StateFarmDetector:
40
  return
41
 
42
  try:
43
- # Load model directly from HuggingFace (YOLO handles this)
44
- # If token is needed, YOLO will use environment variable or we can pass it
45
- if HF_TOKEN:
46
- # Set token as environment variable for YOLO to use
47
- os.environ['HF_TOKEN'] = HF_TOKEN
 
48
 
49
- self.model = YOLO(STATE_FARM_MODEL)
 
50
  print(f"State Farm detection model loaded successfully from {STATE_FARM_MODEL}")
51
 
52
  except Exception as e:
 
40
  return
41
 
42
  try:
43
+ # Download model file from HuggingFace
44
+ model_path = hf_hub_download(
45
+ repo_id=STATE_FARM_MODEL,
46
+ filename="weights/best.pt",
47
+ token=HF_TOKEN
48
+ )
49
 
50
+ # Load YOLO model from downloaded file
51
+ self.model = YOLO(model_path)
52
  print(f"State Farm detection model loaded successfully from {STATE_FARM_MODEL}")
53
 
54
  except Exception as e: