Downloads · 30 days
0
shalchianmh/Iran_license_plate_detection_YOLOv8m_onnx
Iran_license_plate_detection_YOLOv8m_onnx is a object detection model from shalchianmh. Use it when you need objects located in an image. It is set up for ultralytics. The card lists the license as agpl-3.0.
This model is an ONNX version of a YOLOv8 medium fine tuned on Iran veichle plate dataset. YOLOv8 is designed to efficiently detect objects in images by generating bounding boxes around objects of interest and predict…
Downloads · 30 days
0
Access
Public
Updated Oct 3, 2024
Repo size
207 MB
Likes
2
Public
Click a slice to open those files.
.onnx207 MB · 100%
From the Hugging Face model README
This model is an ONNX version of a YOLOv8 medium fine tuned on Iran veichle plate dataset. YOLOv8 is designed to efficiently detect objects in images by generating bounding boxes around objects of interest and predicting their associated class probabilities.
import onnxruntime as rt
sess = rt.InferenceSession("path_to_model.onnx")
# View model input and output details
input_name = sess.get_inputs()[0].name
print("Input name:", input_name)
input_shape = sess.get_inputs()[0].shape
print("Input shape:", input_shape)
input_type = sess.get_inputs()[0].type
print("Input type:", input_type)
output_name = sess.get_outputs()[0].name
print("Output name:", output_name)
output_shape = sess.get_outputs()[0].shape
print("Output shape:", output_shape)
output_type = sess.get_outputs()[0].type
print("Output type:", output_type)
cv2.imread().(C, H, W).import cv2
import numpy as np
# Pre-process the input image
image_path = "/path_to_image.png"
input_image = cv2.imread(image_path)
resized_image = cv2.resize(input_image, (224, 224))
scaled_image = resized_image / 255.0
transposed_image = scaled_image.transpose((2, 0, 1))
prep_image = np.array(transposed_image, dtype='float32')[None, :]
After pre-processing, run the model on the prepared image.
# Run inference
output_probabilities = sess.run([output_name], {input_name: prep_image})
To extract bounding box details:
# Extract bounding box information
most_prob_idx = output_probabilities[0][0][4].argmax()
x, y, width, height, prob = output_probabilities[0][0][:, most_prob_idx]
print(x, y, width, height, prob)