Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can use as_yolo convert coco2yolo to segmentation data format ? #615

Open
1 of 2 tasks
lonngxiang opened this issue Nov 22, 2023 · 6 comments
Open
1 of 2 tasks

Can use as_yolo convert coco2yolo to segmentation data format ? #615

lonngxiang opened this issue Nov 22, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@lonngxiang
Copy link

Search before asking

  • I have searched the Supervision issues and found no similar bug report.

Bug

use this script the conversion format is incorrect
https://docs.ultralytics.com/datasets/segment/coco/#dataset-yaml

import supervision as sv

sv.DetectionDataset.from_coco(
    images_directory_path= r"C:\Users\loong\Downloads\Car\valid",
    annotations_path=r"C:\Users\loong\Downloads\Car\valid\_annotations.coco.json",
    force_masks=True
).as_yolo(
    images_directory_path=r"C:\Users\loong\Downloads\Car_yolo\val\images",
    annotations_directory_path=r"C:\Users\loong\Downloads\Car_yolo\val\labels",
    data_yaml_path=r"C:\Users\loong\Downloads\Car_yolo\data.yaml"
)

Environment

No response

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@lonngxiang lonngxiang added the bug Something isn't working label Nov 22, 2023
@SkalskiP
Copy link
Collaborator

Hi @lonngxiang 👋🏻 Thanks for your interest in Supervision. Could you be a bit more specific? What do you mean by incorrect?

@lonngxiang
Copy link
Author

Hi @lonngxiang 👋🏻 Thanks for your interest in Supervision. Could you be a bit more specific? What do you mean by incorrect?

yeap,I want to use Ultralytics' YOLOv8 to train a segmentation algorithm, but the provided function seems to convert COCO dataset into YOLO format. Could you please help me how to convert it into the required format for segmentation dataset?

Please refer to for details:
https://github.com/roboflow/supervision/issues/267#issuecomment-1821974837

@lonngxiang
Copy link
Author

Hi @lonngxiang 👋🏻 Thanks for your interest in Supervision. Could you be a bit more specific? What do you mean by incorrect?

Using this script looks just converted to yolo object detection format, not segmentation data set format requirements

import supervision as sv

sv.DetectionDataset.from_coco(
    images_directory_path= r"C:\Users\loong\Downloads\Car\valid",
    annotations_path=r"C:\Users\loong\Downloads\Car\valid\_annotations.coco.json",
    force_masks=True
).as_yolo(
    images_directory_path=r"C:\Users\loong\Downloads\Car_yolo\val\images",
    annotations_directory_path=r"C:\Users\loong\Downloads\Car_yolo\val\labels",
    data_yaml_path=r"C:\Users\loong\Downloads\Car_yolo\data.yaml"
)

@SkalskiP
Copy link
Collaborator

@lonngxiang so if you examine the txt file that is produced as a result of conversion it contain box coordinates not segmentation coordinates? Could you paste here content of one of those files?

@lonngxiang
Copy link
Author

@lonngxiang so if you examine the txt file that is produced as a result of conversion it contain box coordinates not segmentation coordinates? Could you paste here content of one of those files?

Yes, the conversion of YAML and labels TXT files do not meet the segmentation dataset format requirements

yaml file:


nc: 2
names: [Car, Car]

labes txt file :

1 0.50625 0.24844 0.50469 0.25000 0.50000 0.25000 0.49844 0.25156 0.49375 0.25156 0.49219 0.25312 0.48750 0.25312 0.48594 0.25469 0.48125 0.25469 0.47969 0.25625 0.47500 0.25625 0.47344 0.25781 0.47031 0.25781 0.46875 0.25938 0.46406 0.25938 0.46250 0.26094 0.45781 0.26094 0.45625 0.26250 0.45156 0.26250 0.45000 0.26406 0.44531 0.26406 0.44375 0.26562 0.43906 0.26562 0.43750 0.26719 0.43281 0.26719 0.43125 0.26875 0.42969 0.26875 0.42500 0.27344 0.42344 0.27344 0.41406 0.28281 0.41250 0.28281 0.40469 0.29063 0.40313 0.29063 0.38906 0.30469 0.38906 0.30625 0.37188 0.32344 0.37188 0.32500 0.35469 0.34219 0.35469 0.34375 0.33750 0.36094 0.33750 0.36250 0.32812 0.37188 0.32500 0.36875 0.32344 0.36875 0.32031 0.36562 0.31875 0.36562 0.31719 0.36719 0.31406 0.36719 0.31250 0.36875 0.31094 0.36875 0.30938 0.37031 0.30938 0.37188 0.30781 0.37344 0.30938 0.37500 0.31094 0.37500 0.31250 0.37656 0.31406 0.37656 0.31562 0.37812 0.31562 0.38125 0.31406 0.38281 0.31406 0.39062 0.31250 0.39219 0.31250 0.39375 0.30938 0.39687 0.30781 0.39687 0.30625 0.39844 0.30312 0.39844 0.30156 0.40000 0.30000 0.40000 0.29844 0.40156 0.29531 0.40156 0.29375 0.40313 0.29219 0.40313 0.29063 0.40469 0.28750 0.40469 0.28594 0.40625 0.28437 0.40625 0.28281 0.40781 0.27969 0.40781 0.27813 0.40937 0.27656 0.40937 0.27500 0.41094 0.27187 0.41094 0.27031 0.41250 0.26875 0.41250 0.26719 0.41406 0.26406 0.41406 0.26250 0.41563 0.26094 0.41563 0.25938 0.41719 0.25625 0.41719 0.25469 0.41875 0.25312 0.41875 0.25156 0.42031 0.24844 0.42031 0.24688 0.42188 0.24531 0.42188 0.24375 0.42344 0.24063 0.42344 0.23906 0.42500 0.23750 0.42500 0.23594 0.42656 0.23281 0.42656 0.23125 0.42812 0.22969 0.42812 0.22812 0.42969 0.22500 0.42969 0.22344 0.43125 0.22187 0.43125 0.22031 0.43281 0.21875 0.43281 0.21406 0.43750 0.21250 0.43750 0.20312 0.44688 0.20156 0.44688 0.19375 0.45469 0.19219 0.45469 0.18594 0.46094 0.18594 0.46250 0.18281 0.46563 0.18281 0.46719 0.17969 0.47031 0.17969 0.47187 0.17656 0.47500 0.17656 0.47656 0.17344 0.47969 0.17344 0.48125 0.17031 0.48438 0.17031 0.48594 0.16719 0.48906 0.16719 0.49062 0.16562 0.49219 0.16562 0.49375 0.16406 0.49531 0.16406 0.49844 0.16250 0.50000 0.16250 0.50156 0.16094 0.50313 0.16094 0.50625 0.15937 0.50781 0.15937 0.51094 0.15781 0.51250 0.15781 0.51562 0.15625 0.51719 0.15625 0.52031 0.15469 0.52187 0.15469 0.52344 0.15313 0.52500 0.15313 0.52812 0.15156 0.52969 0.15156 0.53281 0.15000 0.53438 0.15000 0.53750 0.14844 0.53906 0.14844 0.54219 0.14688 0.54375 0.14688 0.54531 0.14531 0.54688 0.14531 0.55000 0.14375 0.55156 0.14375 0.55469 0.14219 0.55625 0.14219 0.59844 0.14375 0.60000 0.14375 0.64375 0.14219 0.64531 0.14219 0.65469 0.14062 0.65625 0.14062 0.66563 0.13906 0.66719 0.13906 0.67656 0.13750 0.67812 0.13750 0.68281 0.13906 0.68437 0.14062 0.68437 0.14531 0.68906 0.14688 0.68906 0.15156 0.69375 0.15313 0.69375 0.15625 0.69688 0.16250 0.69688 0.16406 0.69844 0.17656 0.69844 0.17813 0.70000 0.19062 0.70000 0.19219 0.70156 0.20469 0.70156 0.20625 0.70312 0.21719 0.70312 0.21875 0.70469 0.23125 0.70469 0.23281 0.70625 0.24531 0.70625 0.24688 0.70781 0.25938 0.70781 0.26094 0.70937 0.27344 0.70937 0.27500 0.71094 0.28750 0.71094 0.28906 0.71250 0.30156 0.71250 0.30312 0.71406 0.31562 0.71406 0.31719 0.71562 0.32969 0.71562 0.33125 0.71719 0.34219 0.71719 0.34375 0.71875 0.35625 0.71875 0.35781 0.72031 0.37031 0.72031 0.37188 0.72188 0.38438 0.72188 0.38594 0.72344 0.39531 0.72344 0.39687 0.72500 0.40313 0.72500 0.40469 0.72656 0.41094 0.72656 0.41250 0.72813 0.41875 0.72813 0.42031 0.72969 0.42656 0.72969 0.42812 0.73125 0.43438 0.73125 0.43594 0.73281 0.44219 0.73281 0.44375 0.73438 0.46563 0.73438 0.46719 0.73281 0.50313 0.73281 0.50469 0.73125 0.52500 0.73125 0.52656 0.72969 0.53281 0.72969 0.53438 0.72813 0.54063 0.72813 0.54219 0.72656 0.55000 0.72656 0.55156 0.72500 0.55781 0.72500 0.55937 0.72344 0.56563 0.72344 0.56719 0.72188 0.57344 0.72188 0.57500 0.72031 0.57812 0.72031 0.57969 0.72188 0.57969 0.72344 0.58281 0.72656 0.58281 0.72813 0.58594 0.73125 0.58594 0.73281 0.58906 0.73594 0.58906 0.73750 0.59219 0.74062 0.59219 0.74219 0.59375 0.74375 0.60313 0.74375 0.60469 0.74219 0.61406 0.74219 0.61875 0.73750 0.61875 0.73594 0.62500 0.72969 0.62500 0.72813 0.62656 0.72656 0.62656 0.72344 0.62813 0.72188 0.62813 0.72031 0.62969 0.71875 0.62969 0.71562 0.63125 0.71406 0.63125 0.71094 0.63281 0.70937 0.63281 0.70625 0.63438 0.70469 0.63438 0.70156 0.63594 0.70000 0.63594 0.69844 0.63750 0.69688 0.63750 0.69375 0.63906 0.69219 0.63906 0.69063 0.64062 0.68906 0.64219 0.68906 0.64375 0.68750 0.64531 0.68750 0.64844 0.68437 0.65000 0.68437 0.65312 0.68125 0.65469 0.68125 0.65625 0.67969 0.65781 0.67969 0.66094 0.67656 0.66250 0.67656 0.66563 0.67344 0.66719 0.67344 0.66875 0.67188 0.67031 0.67188 0.67188 0.67031 0.67344 0.67031 0.67500 0.66875 0.67656 0.66875 0.67812 0.66719 0.67969 0.66719 0.68125 0.66563 0.68437 0.66563 0.68594 0.66406 0.68750 0.66406 0.68906 0.66250 0.69219 0.66250 0.69375 0.66094 0.69531 0.66094 0.69688 0.65938 0.69844 0.65938 0.70000 0.65781 0.70312 0.65781 0.70469 0.65625 0.70625 0.65625 0.70781 0.65469 0.70937 0.65469 0.71094 0.65312 0.71406 0.65312 0.71562 0.65156 0.71719 0.65156 0.71875 0.65000 0.72031 0.65000 0.72188 0.64844 0.72500 0.64844 0.72656 0.64687 0.72813 0.64687 0.72969 0.64531 0.73281 0.64531 0.73438 0.64375 0.73594 0.64375 0.73750 0.64219 0.73906 0.64219 0.74062 0.64062 0.74687 0.64062 0.74844 0.63906 0.75625 0.63906 0.75781 0.63750 0.76250 0.63750 0.76406 0.63906 0.76562 0.63906 0.76719 0.64062 0.76875 0.64062 0.77187 0.64375 0.77344 0.64375 0.77656 0.64687 0.77812 0.64687 0.77969 0.64844 0.78125 0.64844 0.78281 0.65000 0.78594 0.65000 0.78750 0.64844 0.79219 0.64844 0.79375 0.64687 0.79531 0.64687 0.79688 0.64531 0.79688 0.64375 0.79844 0.64219 0.79844 0.64062 0.80156 0.63750 0.80156 0.63594 0.80312 0.63438 0.80312 0.63281 0.80469 0.63125 0.80469 0.62813 0.80625 0.62656 0.80625 0.61875 0.80781 0.61719 0.80781 0.61094 0.80937 0.60938 0.80937 0.60313 0.81094 0.60156 0.81094 0.59375 0.81250 0.59219 0.81250 0.58750 0.81406 0.58594 0.81406 0.58437 0.81563 0.58281 0.81563 0.58125 0.81719 0.57969 0.81719 0.57812 0.81875 0.57656 0.81875 0.57500 0.82031 0.57344 0.82031 0.44531 0.81875 0.44375 0.81875 0.43906 0.81719 0.43750 0.81719 0.43281 0.81563 0.43125 0.81563 0.42656 0.81406 0.42500 0.81406 0.42031 0.81250 0.41875 0.81250 0.41406 0.81094 0.41250 0.81094 0.40781 0.80937 0.40625 0.80937 0.40156 0.80781 0.40000 0.80781 0.39531 0.80625 0.39375 0.80625 0.38906 0.80469 0.38750 0.80469 0.38438 0.80312 0.38281 0.80156 0.38281 0.79844 0.37969 0.79688 0.37969 0.79531 0.37812 0.79375 0.37812 0.79063 0.37500 0.78906 0.37500 0.78594 0.37188 0.78438 0.37188 0.78125 0.36875 0.77969 0.36875 0.77812 0.36719 0.77656 0.36719 0.77344 0.36406 0.77187 0.36406 0.76875 0.36094 0.76875 0.35938 0.76562 0.35625 0.76562 0.35469 0.76250 0.35156 0.76250 0.35000 0.75938 0.34687 0.75938 0.34531 0.75625 0.34219 0.75625 0.34063 0.75313 0.33750 0.75313 0.33594 0.74844 0.33125 0.74844 0.32969 0.74531 0.32656 0.74531 0.32500 0.74219 0.32188 0.74219 0.32031 0.73906 0.31719 0.73906 0.31562 0.73594 0.31250 0.73594 0.31094 0.73281 0.30781 0.73281 0.30625 0.69219 0.26562 0.68906 0.26562 0.68750 0.26406 0.67969 0.26406 0.67812 0.26250 0.67031 0.26250 0.66875 0.26094 0.66094 0.26094 0.65938 0.25938 0.65312 0.25938 0.65156 0.25781 0.64375 0.25781 0.64219 0.25625 0.63438 0.25625 0.63281 0.25469 0.62656 0.25469 0.62500 0.25312 0.61719 0.25312 0.61562 0.25156 0.60781 0.25156 0.60625 0.25000 0.59844 0.25000 0.59688 0.24844
1 0.74375 0.31719 0.74531 0.31875 0.74531 0.32031 0.74844 0.32344 0.74844 0.32500 0.75156 0.32812 0.75156 0.32969 0.75469 0.33281 0.75469 0.33437 0.75781 0.33750 0.75781 0.33906 0.76094 0.34219 0.76094 0.34375 0.76250 0.34531 0.76250 0.34687 0.76562 0.35000 0.76562 0.35156 0.76875 0.35469 0.76875 0.35625 0.77187 0.35938 0.77187 0.36094 0.77500 0.36406 0.77500 0.36562 0.77812 0.36875 0.77812 0.37031 0.77969 0.37188 0.78594 0.37188 0.78750 0.37344 0.79375 0.37344 0.79375 0.37188 0.79219 0.37031 0.79219 0.36719 0.79063 0.36562 0.79063 0.36250 0.78906 0.36094 0.78906 0.35781 0.78750 0.35625 0.78750 0.35313 0.78594 0.35156 0.78594 0.35000 0.78438 0.34844 0.78438 0.34531 0.78281 0.34375 0.78281 0.34063 0.78125 0.33906 0.78125 0.33594 0.77969 0.33437 0.77969 0.33125 0.77812 0.32969 0.77812 0.32812 0.77656 0.32812 0.77500 0.32656 0.77187 0.32656 0.77031 0.32500 0.76719 0.32500 0.76562 0.32344 0.76250 0.32344 0.76094 0.32188 0.75625 0.32188 0.75469 0.32031 0.75156 0.32031 0.75000 0.31875 0.74687 0.31875 0.74531 0.31719

image

@SkalskiP SkalskiP self-assigned this Nov 27, 2023
@SkalskiP
Copy link
Collaborator

Hi @lonngxiang 👋🏻 is this still a problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants