Nepal Vehicle License Plates Detection
!pip install ultralytics
!pip install PIL
from ultralytics import YOLO
import matplotlib.pyplot as plt
from PIL import Image, ImageDraw
from google.colab import files
import requests
model_url = "https://huggingface.co/krishnamishra8848/Nepal_Vehicle_License_Plates_Detection_Version2/resolve/main/best.pt"
model_path = "best.pt"
print("Downloading the model...")
response = requests.get(model_url)
with open(model_path, 'wb') as f:
f.write(response.content)
print("Model downloaded!")
model = YOLO(model_path)
print("Please upload an image to test:")
uploaded = files.upload()
image_path = list(uploaded.keys())[0]
results = model(image_path)
img = Image.open(image_path)
draw = ImageDraw.Draw(img)
for box in results[0].boxes:
x_min, y_min, x_max, y_max = box.xyxy[0].tolist()
label = int(box.cls)
confidence = float(box.conf)
draw.rectangle([x_min, y_min, x_max, y_max], outline="red", width=3)
text = f"Class {label}, {confidence:.2f}"
draw.text((x_min, y_min - 10), text, fill="red")
plt.figure(figsize=(10, 10))
plt.imshow(img)
plt.axis('off')
plt.show()