Spaces:
Build error
Build error
Create App2.py
Browse files
App2.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ultralyticsplus import YOLO, render_result
|
| 2 |
+
|
| 3 |
+
# load model
|
| 4 |
+
model = YOLO('keremberke/yolov8n-pcb-defect-segmentation')
|
| 5 |
+
|
| 6 |
+
# set model parameters
|
| 7 |
+
model.overrides['conf'] = 0.25 # NMS confidence threshold
|
| 8 |
+
model.overrides['iou'] = 0.45 # NMS IoU threshold
|
| 9 |
+
model.overrides['agnostic_nms'] = False # NMS class-agnostic
|
| 10 |
+
model.overrides['max_det'] = 1000 # maximum number of detections per image
|
| 11 |
+
|
| 12 |
+
# set image
|
| 13 |
+
image = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'
|
| 14 |
+
|
| 15 |
+
# perform inference
|
| 16 |
+
results = model.predict(image)
|
| 17 |
+
|
| 18 |
+
# observe results
|
| 19 |
+
print(results[0].boxes)
|
| 20 |
+
print(results[0].masks)
|
| 21 |
+
render = render_result(model=model, image=image, result=results[0])
|
| 22 |
+
render.show()
|