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"]

ความคิดเห็น • 16

  • @showpiecep
    @showpiecep ปีที่แล้ว +1

    Thank you so much for your help. It's very clear, even to a non-native speaker. Thank you again very much

  • @jasanontonfilm
    @jasanontonfilm 5 หลายเดือนก่อน

    THANK U VERY MUCH FOR THIS AMAZING VIDEO. Love from Indonesia😻😻

  • @DeathlessLife786
    @DeathlessLife786 ปีที่แล้ว

    Hi thanks for ur video. How do create text file for our custom data? Do you have any video to create text file ?

  • @RanjitSingh-rq1qx
    @RanjitSingh-rq1qx 9 หลายเดือนก่อน

    sir is there any video to fine tune the yolo v8 for image segmentation on custome dataset.
    plz sir give me the link

  • @CITLAB-zp2sj
    @CITLAB-zp2sj ปีที่แล้ว

    can we access a custom-trained model when calling through YOLO

  • @achukasimonallan6720
    @achukasimonallan6720 ปีที่แล้ว +2

    Is there a way of separating masks according to the class of the object

  • @mulugetashitie7282
    @mulugetashitie7282 ปีที่แล้ว

    very interesting .. how it can be to generate more than one image(large size)?

  • @ParthMendapara
    @ParthMendapara 10 หลายเดือนก่อน +2

    I got
    AttributeError: 'Masks' object has no attribute 'masks'. See valid attributes below.
    Does anyone have solution?

    • @taiphamtan1545
      @taiphamtan1545 10 หลายเดือนก่อน

      me too

    • @ЕленаКаштанова-к6з
      @ЕленаКаштанова-к6з 10 หลายเดือนก่อน

      @@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"))

    • @ЕленаКаштанова-к6з
      @ЕленаКаштанова-к6з 10 หลายเดือนก่อน +7

      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

  • @DDDprinting
    @DDDprinting 5 หลายเดือนก่อน

    I'd have to use some python code, YOLO and a webcam so it detects visually.

  • @sudhirprasad8221
    @sudhirprasad8221 ปีที่แล้ว

    What do other values mean in the doggo.txt file? I know the first value is for the class label.