Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ import numpy as np
|
|
| 7 |
from PIL import Image
|
| 8 |
|
| 9 |
# Step 1: Download the YOLO model weights from your Hugging Face repository
|
| 10 |
-
weights_path = hf_hub_download(repo_id="krishnamishra8848/Nepal-Vehicle-License-Plate-Detection", filename="
|
| 11 |
|
| 12 |
# Step 2: Load the YOLO model
|
| 13 |
model = YOLO(weights_path)
|
|
@@ -27,7 +27,7 @@ def detect_license_plate(image):
|
|
| 27 |
for box, conf in zip(result.boxes.xyxy, result.boxes.conf):
|
| 28 |
x1, y1, x2, y2 = map(int, box) # Convert to integers
|
| 29 |
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2) # Green rectangle
|
| 30 |
-
label = f"{conf:.2f}"
|
| 31 |
cv2.putText(img, label, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
|
| 32 |
|
| 33 |
# Convert back to RGB for Streamlit display
|
|
|
|
| 7 |
from PIL import Image
|
| 8 |
|
| 9 |
# Step 1: Download the YOLO model weights from your Hugging Face repository
|
| 10 |
+
weights_path = hf_hub_download(repo_id="krishnamishra8848/Nepal-Vehicle-License-Plate-Detection", filename="last.pt")
|
| 11 |
|
| 12 |
# Step 2: Load the YOLO model
|
| 13 |
model = YOLO(weights_path)
|
|
|
|
| 27 |
for box, conf in zip(result.boxes.xyxy, result.boxes.conf):
|
| 28 |
x1, y1, x2, y2 = map(int, box) # Convert to integers
|
| 29 |
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2) # Green rectangle
|
| 30 |
+
label = f"Confidence: {conf:.2f}"
|
| 31 |
cv2.putText(img, label, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
|
| 32 |
|
| 33 |
# Convert back to RGB for Streamlit display
|