Docs Ruff codeblocks reformat and fix (#12847)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
be5cf7a033
commit
68031133fd
9 changed files with 167 additions and 178 deletions
|
|
@ -63,13 +63,12 @@ After performing the [Segment Task](../tasks/segment.md), it's sometimes desirab
|
|||
# (2) Iterate detection results (helpful for multiple images)
|
||||
for r in res:
|
||||
img = np.copy(r.orig_img)
|
||||
img_name = Path(r.path).stem # source image base-name
|
||||
img_name = Path(r.path).stem # source image base-name
|
||||
|
||||
# Iterate each object contour (multiple detections)
|
||||
for ci,c in enumerate(r):
|
||||
for ci, c in enumerate(r):
|
||||
# (1) Get detection class name
|
||||
label = c.names[c.boxes.cls.tolist().pop()]
|
||||
|
||||
```
|
||||
|
||||
1. To learn more about working with detection results, see [Boxes Section for Predict Mode](../modes/predict.md#boxes).
|
||||
|
|
@ -98,12 +97,7 @@ After performing the [Segment Task](../tasks/segment.md), it's sometimes desirab
|
|||
|
||||
|
||||
# Draw contour onto mask
|
||||
_ = cv2.drawContours(b_mask,
|
||||
[contour],
|
||||
-1,
|
||||
(255, 255, 255),
|
||||
cv2.FILLED)
|
||||
|
||||
_ = cv2.drawContours(b_mask, [contour], -1, (255, 255, 255), cv2.FILLED)
|
||||
```
|
||||
|
||||
1. For more info on `c.masks.xy` see [Masks Section from Predict Mode](../modes/predict.md#masks).
|
||||
|
|
@ -280,16 +274,16 @@ import cv2
|
|||
import numpy as np
|
||||
from ultralytics import YOLO
|
||||
|
||||
m = YOLO('yolov8n-seg.pt')#(4)!
|
||||
res = m.predict()#(3)!
|
||||
m = YOLO("yolov8n-seg.pt") # (4)!
|
||||
res = m.predict() # (3)!
|
||||
|
||||
# iterate detection results (5)
|
||||
# Iterate detection results (5)
|
||||
for r in res:
|
||||
img = np.copy(r.orig_img)
|
||||
img_name = Path(r.path).stem
|
||||
|
||||
# iterate each object contour (6)
|
||||
for ci,c in enumerate(r):
|
||||
# Iterate each object contour (6)
|
||||
for ci, c in enumerate(r):
|
||||
label = c.names[c.boxes.cls.tolist().pop()]
|
||||
|
||||
b_mask = np.zeros(img.shape[:2], np.uint8)
|
||||
|
|
@ -312,7 +306,6 @@ for r in res:
|
|||
iso_crop = isolated[y1:y2, x1:x2]
|
||||
|
||||
# TODO your actions go here (2)
|
||||
|
||||
```
|
||||
|
||||
1. The line populating `contour` is combined into a single line here, where it was split to multiple above.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue