Spaces:
Sleeping
Sleeping
gauthambalraj07@gmail.com
commited on
Commit
·
3dc870c
1
Parent(s):
707dfbd
fix yolo call
Browse files- main.py +3 -0
- requirements.txt +1 -1
- test.ipynb +4 -4
- utils.py +7 -12
main.py
CHANGED
|
@@ -36,6 +36,9 @@ try:
|
|
| 36 |
except:
|
| 37 |
yolo_model = torch.load("weights/icon_detect/best.pt", map_location="cpu", weights_only=False)["model"]
|
| 38 |
|
|
|
|
|
|
|
|
|
|
| 39 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
| 40 |
import torch
|
| 41 |
|
|
|
|
| 36 |
except:
|
| 37 |
yolo_model = torch.load("weights/icon_detect/best.pt", map_location="cpu", weights_only=False)["model"]
|
| 38 |
|
| 39 |
+
|
| 40 |
+
print(f"YOLO model type: {type(yolo_model)}")
|
| 41 |
+
|
| 42 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
| 43 |
import torch
|
| 44 |
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
torch==2.
|
| 2 |
easyocr
|
| 3 |
torchvision
|
| 4 |
supervision==0.18.0
|
|
|
|
| 1 |
+
torch==2.2.2
|
| 2 |
easyocr
|
| 3 |
torchvision
|
| 4 |
supervision==0.18.0
|
test.ipynb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
-
"execution_count":
|
| 6 |
"metadata": {},
|
| 7 |
"outputs": [
|
| 8 |
{
|
|
@@ -11,8 +11,8 @@
|
|
| 11 |
"text": [
|
| 12 |
"Processing imscdr_ac_in___8.png...\n",
|
| 13 |
"Status Code: 500\n",
|
| 14 |
-
"Response Text: {\"detail\":\"BaseModel.predict() got an unexpected keyword argument '
|
| 15 |
-
"Finished processing imscdr_ac_in___8.png in
|
| 16 |
"Processing imscdr_ac_in___9.png...\n",
|
| 17 |
"Status Code: 500\n",
|
| 18 |
"Response Text: <!DOCTYPE html>\n",
|
|
@@ -124,7 +124,7 @@
|
|
| 124 |
"</body>\n",
|
| 125 |
"</html>\n",
|
| 126 |
"\n",
|
| 127 |
-
"Finished processing imscdr_ac_in___9.png in
|
| 128 |
"{}\n"
|
| 129 |
]
|
| 130 |
}
|
|
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
+
"execution_count": 4,
|
| 6 |
"metadata": {},
|
| 7 |
"outputs": [
|
| 8 |
{
|
|
|
|
| 11 |
"text": [
|
| 12 |
"Processing imscdr_ac_in___8.png...\n",
|
| 13 |
"Status Code: 500\n",
|
| 14 |
+
"Response Text: {\"detail\":\"BaseModel.predict() got an unexpected keyword argument 'conf'\"}\n",
|
| 15 |
+
"Finished processing imscdr_ac_in___8.png in 10.38 seconds\n",
|
| 16 |
"Processing imscdr_ac_in___9.png...\n",
|
| 17 |
"Status Code: 500\n",
|
| 18 |
"Response Text: <!DOCTYPE html>\n",
|
|
|
|
| 124 |
"</body>\n",
|
| 125 |
"</html>\n",
|
| 126 |
"\n",
|
| 127 |
+
"Finished processing imscdr_ac_in___9.png in 10.32 seconds\n",
|
| 128 |
"{}\n"
|
| 129 |
]
|
| 130 |
}
|
utils.py
CHANGED
|
@@ -378,19 +378,14 @@ def predict_yolo(model, image_path, box_threshold, imgsz, scale_img, iou_thresho
|
|
| 378 |
""" Use huggingface model to replace the original model
|
| 379 |
"""
|
| 380 |
# model = model['model']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
if scale_img:
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
conf=box_threshold,
|
| 385 |
-
imgsz=imgsz,
|
| 386 |
-
iou=iou_threshold, # default 0.7
|
| 387 |
-
)
|
| 388 |
-
else:
|
| 389 |
-
result = model(
|
| 390 |
-
image_path,
|
| 391 |
-
conf=box_threshold,
|
| 392 |
-
iou=iou_threshold, # default 0.7
|
| 393 |
-
)
|
| 394 |
boxes = result[0].boxes.xyxy#.tolist() # in pixel space
|
| 395 |
conf = result[0].boxes.conf
|
| 396 |
phrases = [str(i) for i in range(len(boxes))]
|
|
|
|
| 378 |
""" Use huggingface model to replace the original model
|
| 379 |
"""
|
| 380 |
# model = model['model']
|
| 381 |
+
|
| 382 |
+
kwargs = {
|
| 383 |
+
'conf': box_threshold,
|
| 384 |
+
'iou': iou_threshold,
|
| 385 |
+
}
|
| 386 |
if scale_img:
|
| 387 |
+
kwargs['imgsz'] = imgsz
|
| 388 |
+
result = model(image_path, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
boxes = result[0].boxes.xyxy#.tolist() # in pixel space
|
| 390 |
conf = result[0].boxes.conf
|
| 391 |
phrases = [str(i) for i in range(len(boxes))]
|