MCPcopy
hub / github.com/microsoft/Magma / predict_yolo

Function predict_yolo

agents/ui_agent/util/utils.py:378–399  ·  view source on GitHub ↗

Use huggingface model to replace the original model

(model, image, box_threshold, imgsz, scale_img, iou_threshold=0.7)

Source from the content-addressed store, hash-verified

376
377
378def 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
401def int_box_area(box, w, h):
402 x1, y1, x2, y2 = box

Callers 1

get_som_labeled_imgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected