Use huggingface model to replace the original model
(model, image, box_threshold, imgsz, scale_img, iou_threshold=0.7)
| 376 | |
| 377 | |
| 378 | def predict_yolo(model, image, box_threshold, imgsz, scale_img, iou_threshold=0.7): |
| 379 | """ Use huggingface model to replace the original model |
| 380 | """ |
| 381 | # model = model['model'] |
| 382 | if scale_img: |
| 383 | result = model.predict( |
| 384 | source=image, |
| 385 | conf=box_threshold, |
| 386 | imgsz=imgsz, |
| 387 | iou=iou_threshold, # default 0.7 |
| 388 | ) |
| 389 | else: |
| 390 | result = model.predict( |
| 391 | source=image, |
| 392 | conf=box_threshold, |
| 393 | iou=iou_threshold, # default 0.7 |
| 394 | ) |
| 395 | boxes = result[0].boxes.xyxy#.tolist() # in pixel space |
| 396 | conf = result[0].boxes.conf |
| 397 | phrases = [str(i) for i in range(len(boxes))] |
| 398 | |
| 399 | return boxes, conf, phrases |
| 400 | |
| 401 | def int_box_area(box, w, h): |
| 402 | x1, y1, x2, y2 = box |
no outgoing calls
no test coverage detected