Object detection and segmentation using YOLOv8 for Images | Image/Object segmentation using Python
ฝัง
- เผยแพร่เมื่อ 17 ต.ค. 2024
- In this video, we are going to do Object detection and segmentation in an image using the Yolov8 model. We will segment the various detected objects and display the segmentation masks and also the outline segments in Python.
Image segmentation is primarily required when we need to segment objects from the scene and do some other analysis on it. The most common way to do object segmentation or object segmentation is that we have the get a mask from the model and we then convert that mask to a grayscale image and display it using Opencv. In this video we are going to do just that. In addition to that we are also going to draw the outline segments of the different objects in the image. Lastly, we are also going to print the class names of the objects detected.
Code: github.com/Dat...
coco_names = ["person" , "bicycle" , "car" , "motorcycle" , "airplane" , "bus" , "train" , "truck" , "boat" , "traffic light" , "fire hydrant" , "street sign" , "stop sign" , "parking meter" , "bench" , "bird" , "cat" , "dog" , "horse" , "sheep" , "cow" , "elephant" , "bear" , "zebra" , "giraffe" , "hat" , "backpack" , "umbrella" , "shoe" , "eye glasses" , "handbag" , "tie" , "suitcase" ,
"frisbee" , "skis" , "snowboard" , "sports ball" , "kite" , "baseball bat" ,
"baseball glove" , "skateboard" , "surfboard" , "tennis racket" , "bottle" ,
"plate" , "wine glass" , "cup" , "fork" , "knife" , "spoon" , "bowl" ,
"banana" , "apple" , "sandwich" , "orange" , "broccoli" , "carrot" , "hot dog" ,
"pizza" , "donut" , "cake" , "chair" , "couch" , "potted plant" , "bed" ,
"mirror" , "dining table" , "window" , "desk" , "toilet" , "door" , "tv" ,
"laptop" , "mouse" , "remote" , "keyboard" , "cell phone" , "microwave" ,
"oven" , "toaster" , "sink" , "refrigerator" , "blender" , "book" ,
"clock" , "vase" , "scissors" , "teddy bear" , "hair drier" , "toothbrush" , "hair brush"]
Thank you so much for your help. It's very clear, even to a non-native speaker. Thank you again very much
THANK U VERY MUCH FOR THIS AMAZING VIDEO. Love from Indonesia😻😻
Hi thanks for ur video. How do create text file for our custom data? Do you have any video to create text file ?
sir is there any video to fine tune the yolo v8 for image segmentation on custome dataset.
plz sir give me the link
can we access a custom-trained model when calling through YOLO
Is there a way of separating masks according to the class of the object
Did you got any solution ?
very interesting .. how it can be to generate more than one image(large size)?
I got
AttributeError: 'Masks' object has no attribute 'masks'. See valid attributes below.
Does anyone have solution?
me too
@@taiphamtan1545 Hi, try: predict[0].masks.data.shape
predict[0].masks.data[0].unique()
cv2_imshow((predict[0].masks.data[2].numpy() * 255).astype("uint8"))
Hi! There are some mistakes here. A have tried to fix them and the working code for today is:
predict[0].masks.data.shape
predict[0].masks.data[0].unique()
cv2_imshow((predict[0].masks.data[2].numpy() * 255).astype("uint8"))
x = (predict[0].masks.xy[2][: , 0].astype('int'))
y = (predict[0].masks.xy[2][: , 1].astype('int'))
blk = np.zeros((H , W))
blk[y , x] = 255
cv2_imshow(blk.astype("uint8"))
And for getting the write name it is better to use this code:
for dt in outs:
print(int(dt.split()[0]) , predict[0].names.get(int(dt.split()[0])))
And then you will get:
1 bicycle
16 dog
7 truck
I'd have to use some python code, YOLO and a webcam so it detects visually.
What do other values mean in the doggo.txt file? I know the first value is for the class label.
bounding box coordinates.