Spaces:
Sleeping
Sleeping
Fadhili Sumaye commited on
Commit ·
1243e10
1
Parent(s): 23f3fa4
Deploy custom Cereal Pests model (LFS) and prioritize it in backend
Browse files- .gitattributes +1 -0
- backend/app.py +12 -14
- backend/best_cereal.pt +3 -0
.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
backend/app.py
CHANGED
|
@@ -172,28 +172,26 @@ def init_model():
|
|
| 172 |
try:
|
| 173 |
from ultralytics import YOLO
|
| 174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
if MODEL_IP102_FILE.exists():
|
| 176 |
model = YOLO(str(MODEL_IP102_FILE))
|
| 177 |
HAS_YOLO = True
|
| 178 |
print(f"Success: Loaded IP102 YOLO model from {MODEL_IP102_FILE} ({len(model.names)} classes)")
|
| 179 |
return
|
| 180 |
|
| 181 |
-
|
| 182 |
-
if
|
| 183 |
-
model = YOLO(str(
|
| 184 |
HAS_YOLO = True
|
| 185 |
-
print(f"Success: Loaded fallback
|
| 186 |
-
loaded_fallback = True
|
| 187 |
else:
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
model = YOLO(str(fallback_path))
|
| 191 |
-
HAS_YOLO = True
|
| 192 |
-
print(f"Success: Loaded fallback YOLO model from {fallback_path} ({len(model.names)} classes)")
|
| 193 |
-
loaded_fallback = True
|
| 194 |
-
|
| 195 |
-
print("IP102 model is missing. Initiating background download...")
|
| 196 |
-
threading.Thread(target=download_ip102_model, daemon=True).start()
|
| 197 |
except Exception as e:
|
| 198 |
if not HAS_YOLO:
|
| 199 |
HAS_YOLO = False
|
|
|
|
| 172 |
try:
|
| 173 |
from ultralytics import YOLO
|
| 174 |
|
| 175 |
+
if MODEL_FILE.exists():
|
| 176 |
+
model = YOLO(str(MODEL_FILE))
|
| 177 |
+
HAS_YOLO = True
|
| 178 |
+
print(f"Success: Loaded Cereal Pests custom YOLO model from {MODEL_FILE} ({len(model.names)} classes)")
|
| 179 |
+
return
|
| 180 |
+
|
| 181 |
if MODEL_IP102_FILE.exists():
|
| 182 |
model = YOLO(str(MODEL_IP102_FILE))
|
| 183 |
HAS_YOLO = True
|
| 184 |
print(f"Success: Loaded IP102 YOLO model from {MODEL_IP102_FILE} ({len(model.names)} classes)")
|
| 185 |
return
|
| 186 |
|
| 187 |
+
fallback_path = Path(r"C:\Users\fadhi\runs\detect\train-3\weights\best.pt")
|
| 188 |
+
if fallback_path.exists():
|
| 189 |
+
model = YOLO(str(fallback_path))
|
| 190 |
HAS_YOLO = True
|
| 191 |
+
print(f"Success: Loaded fallback YOLO model from {fallback_path} ({len(model.names)} classes)")
|
|
|
|
| 192 |
else:
|
| 193 |
+
print("Model files missing. Initiating background download...")
|
| 194 |
+
threading.Thread(target=download_ip102_model, daemon=True).start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
except Exception as e:
|
| 196 |
if not HAS_YOLO:
|
| 197 |
HAS_YOLO = False
|
backend/best_cereal.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:eb8491846099a322bb1055292e0ef84ce298e1a478d62334e6c9a520bafa58a5
|
| 3 |
+
size 22525546
|