Spaces:
Sleeping
Sleeping
rasoul asadian
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ max_len = 10
|
|
9 |
def ocr(plate_image, ocr_model):
|
10 |
try:
|
11 |
if 'yolo' in ocr_model:
|
12 |
-
model = YOLO(f'/
|
13 |
preds = model.predict(plate_image)
|
14 |
return ''.join([model.names[int(pred.boxes.cls.cpu().numpy()[0])] for pred in preds[0]])
|
15 |
else:
|
@@ -20,7 +20,7 @@ def ocr(plate_image, ocr_model):
|
|
20 |
|
21 |
def process_image(image, detection_model, ocr_model, yolo_thresh, perpective_width, perpective_height):
|
22 |
task = 'obb' if 'obb' in detection_model else 'detect'
|
23 |
-
model = YOLO(f'/
|
24 |
|
25 |
predict = model(image, conf=yolo_thresh)
|
26 |
|
@@ -44,7 +44,7 @@ def create_interface():
|
|
44 |
with gr.Row():
|
45 |
with gr.Column(scale=1):
|
46 |
detection_model = gr.Dropdown(label="Detection Model", choices=["yolov8-m", "yolov8-obb-m","yolov8-s", "yolov8-obb-s"], value="yolov8-m")
|
47 |
-
ocr_model = gr.Dropdown(label="OCR Model", choices=["
|
48 |
yolo_thresh = gr.Slider(minimum=0.0, maximum=1.0, label='yolo_threshold')
|
49 |
with gr.Row():
|
50 |
perpective_width = gr.Slider(minimum=100, maximum=500, label='perpective_width')
|
|
|
9 |
def ocr(plate_image, ocr_model):
|
10 |
try:
|
11 |
if 'yolo' in ocr_model:
|
12 |
+
model = YOLO(f'./weights/{ocr_model}.pt', task='detect')
|
13 |
preds = model.predict(plate_image)
|
14 |
return ''.join([model.names[int(pred.boxes.cls.cpu().numpy()[0])] for pred in preds[0]])
|
15 |
else:
|
|
|
20 |
|
21 |
def process_image(image, detection_model, ocr_model, yolo_thresh, perpective_width, perpective_height):
|
22 |
task = 'obb' if 'obb' in detection_model else 'detect'
|
23 |
+
model = YOLO(f'./weights/{detection_model}.pt', task=task)
|
24 |
|
25 |
predict = model(image, conf=yolo_thresh)
|
26 |
|
|
|
44 |
with gr.Row():
|
45 |
with gr.Column(scale=1):
|
46 |
detection_model = gr.Dropdown(label="Detection Model", choices=["yolov8-m", "yolov8-obb-m","yolov8-s", "yolov8-obb-s"], value="yolov8-m")
|
47 |
+
ocr_model = gr.Dropdown(label="OCR Model", choices=["yolov32c", "trocr"], value="yolov32c")
|
48 |
yolo_thresh = gr.Slider(minimum=0.0, maximum=1.0, label='yolo_threshold')
|
49 |
with gr.Row():
|
50 |
perpective_width = gr.Slider(minimum=100, maximum=500, label='perpective_width')
|