{"id":23102669,"url":"https://github.com/dataxujing/yolact_pytorch","last_synced_at":"2025-08-16T14:33:03.355Z","repository":{"id":56735996,"uuid":"241467935","full_name":"DataXujing/yolact_pytorch","owner":"DataXujing","description":":fire: :fire: :fire:Train Your Own DataSet for YOLACT and YOLACT++  Instance Segmentation Model!!!","archived":false,"fork":false,"pushed_at":"2020-02-20T15:36:08.000Z","size":10547,"stargazers_count":68,"open_issues_count":5,"forks_count":14,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T13:23:27.618Z","etag":null,"topics":["computer-vision","convolutional-neural-networks","deep-learning","instance-segmentation","pytorch","yolact"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DataXujing.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-18T21:08:55.000Z","updated_at":"2025-03-19T08:30:02.000Z","dependencies_parsed_at":"2022-08-16T00:50:48.179Z","dependency_job_id":null,"html_url":"https://github.com/DataXujing/yolact_pytorch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DataXujing/yolact_pytorch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataXujing%2Fyolact_pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataXujing%2Fyolact_pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataXujing%2Fyolact_pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataXujing%2Fyolact_pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DataXujing","download_url":"https://codeload.github.com/DataXujing/yolact_pytorch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataXujing%2Fyolact_pytorch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270723411,"owners_count":24634375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","convolutional-neural-networks","deep-learning","instance-segmentation","pytorch","yolact"],"created_at":"2024-12-17T00:00:18.620Z","updated_at":"2025-08-16T14:33:01.211Z","avatar_url":"https://github.com/DataXujing.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## YOLACT++训练自己的数据集\n\n## **Y**ou **O**nly **L**ook **A**t **C**oefficien**T**s\n\npaper:\n\n[YOLACT: Real-time Instance Segmentation](https://arxiv.org/abs/1904.02689)\n[YOLACT++: Better Real-time Instance Segmentation](https://arxiv.org/abs/1912.06218)\n\n\n**Xu Jing**\n\n### 1.将labelme标注的数据转化为coco数据样式\n\n通过[labelme](https://github.com/wkentaro/labelme)我们标注了自己的训练集，我们将标注的训练集经过如下处理后即可得到coco样式的数据\n\n```\n$ cd labelme-master/examples/instance_segmentation\n$ python3 labelme2coco.py water water_coco --labels labels.txt\n```\n\n其中`labels.txt`文件为labelme标注的label名称列表，如下：\n\n```\n__ignore__\n_background_\nwater\n\n```\n\n会在当前文件夹下的`water_coco`文件下生成`JPEGImages`文件夹内存放了所有的image及`annotations.json`为coco类型的标注文件。\n\n\n\n### 2. YOLACT环境安装\n\n+ clone yolact项目\n\n```\n$ git clone https://github.com/dbolya/yolact.git\n$ cd yolact\n```\n\n+ 安装相关环境\n\n\n```\n# anaconda\n$ conda env create -f environment.yml\n\n```\n\n```\n# Pytorch 1.0.1 (or higher) 和 TorchVision建议手动安装\n\n# Cython needs to be installed before pycocotools\n$ pip3 install cython\n$ pip3 install opencv-python pillow pycocotools matplotlib \n\n```\n\n如果想使用YOLACT++,请编译DCNv2\n\n```\n$ cd external/DCNv2\n$ python3 setup.py build develop\n```\n\n### 3.修改yolact代码\n\n+ 打开`yolact-master/data/config.py`\n\n```\n# 修改dataset_base\n\n# ----------------------- DATASETS ----------------------- #\n\ndataset_base = Config({\n    'name': 'water',   # 起个名字\n\n    # Training images and annotations\n    'train_images': './myData/coco/JPEGImages/train',  # 训练集的路径\n    'train_info':   './myData/coco/annotations/train/annotations_train.json', # 标签的路径\n\n    # Validation images and annotations.\n    'valid_images': './myData/coco/JPEGImages/val', # 验证集路径\n    'valid_info':   './myData/coco/annotations/train/annotations_val.json', #验证集标签的路径\n\n    # Whether or not to load GT. If this is False, eval.py quantitative evaluation won't work.\n    'has_gt': True,\n\n    # A list of names for each of you classes.\n    'class_names': ('water'),   # 修改成自己的class name 是一个truple\n\n    # COCO class ids aren't sequential, so this is a bandage fix. If your ids aren't sequential,\n    # provide a map from category_id -\u003e index in class_names + 1 (the +1 is there because it's 1-indexed).\n    # If not specified, this just assumes category ids start at 1 and increase sequentially.\n    'label_map': {1:1}   # 修改成自己的label map\n})\n```\n\n\n+ 修改数据名称和`num_classes`。（`num_classes=数据集标签类数+1`）\n\n\n```\n\n# ----------------------- YOLACT v1.0 CONFIGS ----------------------- #\n\nyolact_base_config = coco_base_config.copy({\n    'name': 'yolact_base',\n\n    # Dataset stuff\n    'dataset': dataset_base,   # 数据源\n    'num_classes': 1 + 1,   # 类别数量 = label + 1\n\n    # Image Size\n    'max_size': 550,\n    \n    # Training params\n    'lr_steps': (280000, 600000, 700000, 750000),\n    'max_iter': 800000,\n```\n\n\n### 4.训练\n\n\n+ 下载预训练权重放至根目录里的`weights`文件夹下\n   \n  - For Resnet101, download resnet101_reducedfc.pth from [here](https://drive.google.com/file/d/1tvqFPd4bJtakOlmn-uIA492g2qurRChj/view?usp=sharing).\n  - For Resnet50, download resnet50-19c8e357.pth from [here](https://drive.google.com/file/d/1Jy3yCdbatgXa5YYIdTCRrSV0S9V5g1rn/view?usp=sharing).\n  - For Darknet53, download darknet53.pth from [here](https://drive.google.com/file/d/17Y431j4sagFpSReuPNoFcj9h7azDTZFf/view?usp=sharing).\n\n+ 在训练过程中按`ctrl+c`能够保存当前训练权重并保存在weight文件夹里。命名为：`\u003cconfig\u003e_\u003cepoch\u003e_\u003citer\u003e.pth`\n\n+ 训练\n\n使用默认为8的batch size训练：\n\n```\n$ python3 train.py --config=yolact_base_config\n```\n\n根据根据实际情况可以适当调节batch size的大小，如果显卡性能低可以减小batch size大小：\n\n```\n$ python3 train.py --config=yolact_base_config --batch_size=5\n\n```\n从中断的权重继续训练：\n\n```\n$ python3 train.py --config=yolact_base_config --resume=weights/yolact_base_10_32100.pth --start_iter=-1\n```\n\n```\n$ python3 train.py --config=yolact_plus_resnet50_config\n```\n\n帮助：\n\n```\n$ python3 train.py --help\n```\n\n### 5.推断\n\n+ image\n\n```\n# Display qualitative results on the specified image.\n$ python3 eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --image=my_image.png\n\n# Process an image and save it to another file.\n$ python3 eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --image=input_image.png:output_image.png\n\n# Process a whole folder of images.\n$ python3 eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --images=path/to/input/folder:path/to/output/folder\n\n\n$ python3 eval.py --trained_model=weights/yolact_plus_resnet50_1086_100000.pth --score_threshold=0.15 --top_k=15 --images=./test:./result\n\n```\n\n+ video\n\n```\n# Display a video in real-time. \"--video_multiframe\" will process that many frames at once for improved performance.\n# If you want, use \"--display_fps\" to draw the FPS directly on the frame.\n$ python3 eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --video_multiframe=4 --video=my_video.mp4\n\n# Display a webcam feed in real-time. If you have multiple webcams pass the index of the webcam you want instead of 0.\n$ python3 eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --video_multiframe=4 --video=0\n\n# Process a video and save it to another file. This uses the same pipeline as the ones above now, so it's fast!\n$ python3 eval.py --trained_model=weights/yolact_base_54_800000.pth --score_threshold=0.15 --top_k=15 --video_multiframe=4 --video=input_video.mp4:output_video.mp4\n\n$ python3 eval.py --trained_model=weights/yolact_plus_resnet50_1086_100000.pth --score_threshold=0.50 --top_k=15 --video_multiframe=4 --display_fps --video=test.mp4:test_res.mp4\n\npython3 eval.py --trained_model=weights/yolact_plus_resnet50_1086_100000.pth --score_threshold=0.50 --top_k=15 --display_fps --video=test.mp4:test_res.mp4\n\n\n```\n\n+ help\n\n```\npython3 eval.py --help\n\n```\n\n![](./data/test.png)\n\n### 6.Referecne\n\n\n```\n@inproceedings{yolact-iccv2019,\n  author    = {Daniel Bolya and Chong Zhou and Fanyi Xiao and Yong Jae Lee},\n  title     = {YOLACT: {Real-time} Instance Segmentation},\n  booktitle = {ICCV},\n  year      = {2019},\n}\n```\n\nFor YOLACT++, please cite\n```\n@misc{yolact-plus-arxiv2019,\n  title         = {YOLACT++: Better Real-time Instance Segmentation},\n  author        = {Daniel Bolya and Chong Zhou and Fanyi Xiao and Yong Jae Lee},\n  year          = {2019},\n  eprint        = {1912.06218},\n  archivePrefix = {arXiv},\n  primaryClass  = {cs.CV}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataxujing%2Fyolact_pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdataxujing%2Fyolact_pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataxujing%2Fyolact_pytorch/lists"}