{"id":15628394,"url":"https://github.com/rizwanmunawar/yolov7-segmentation","last_synced_at":"2025-05-16T05:04:43.375Z","repository":{"id":57839960,"uuid":"526616950","full_name":"RizwanMunawar/yolov7-segmentation","owner":"RizwanMunawar","description":"YOLOv7 Instance Segmentation using OpenCV and PyTorch","archived":false,"fork":false,"pushed_at":"2025-04-29T13:06:07.000Z","size":5143,"stargazers_count":327,"open_issues_count":19,"forks_count":78,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-29T14:27:30.596Z","etag":null,"topics":["imagesegmentation","medium-article","opencv-python","yolov5","yolov7-mask"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RizwanMunawar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"muhammadrizwanm","thanks_dev":null,"custom":null}},"created_at":"2022-08-19T13:23:09.000Z","updated_at":"2025-04-29T13:06:14.000Z","dependencies_parsed_at":"2024-01-14T12:18:27.235Z","dependency_job_id":"bc38d440-83fa-42f6-879d-ab460cf16b0e","html_url":"https://github.com/RizwanMunawar/yolov7-segmentation","commit_stats":{"total_commits":107,"total_committers":6,"mean_commits":"17.833333333333332","dds":0.05607476635514019,"last_synced_commit":"2f5795c497e54e3c30e683be23b3aa0707c6d373"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RizwanMunawar%2Fyolov7-segmentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RizwanMunawar%2Fyolov7-segmentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RizwanMunawar%2Fyolov7-segmentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RizwanMunawar%2Fyolov7-segmentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RizwanMunawar","download_url":"https://codeload.github.com/RizwanMunawar/yolov7-segmentation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471060,"owners_count":22076585,"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","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":["imagesegmentation","medium-article","opencv-python","yolov5","yolov7-mask"],"created_at":"2024-10-03T10:22:23.231Z","updated_at":"2025-05-16T05:04:43.368Z","avatar_url":"https://github.com/RizwanMunawar.png","language":"Python","funding_links":["https://buymeacoffee.com/muhammadrizwanm"],"categories":[],"sub_categories":[],"readme":"# YOLOv7 Instance Segmentation\n\n🚀 [Read the blog](https://muhammadrizwanmunawar.medium.com/train-yolov7-segmentation-on-custom-data-b91237bd2a29) \n\n## Steps to run Code\n\n- Clone the repository\n```bash\ngit clone https://github.com/RizwanMunawar/yolov7-segmentation.git\n```\n\n- Goto the cloned folder.\n```bash\ncd yolov7-segmentation\n```\n\n- Create a virtual envirnoment (Recommended, If you dont want to disturb python packages)\n```bash\n\n### For Linux Users\npython3 -m venv yolov7seg\nsource yolov7seg/bin/activate\n\n### For Window Users\npython3 -m venv yolov7seg\ncd yolov7seg\ncd Scripts\nactivate\ncd ..\ncd ..\n```\n\n- Upgrade pip with mentioned command below.\n```bash\npip install --upgrade pip\n```\n\n- Install requirements with mentioned command below.\n```bash\npip install -r requirements.txt\n```\n\n- Download weights from [link](https://github.com/RizwanMunawar/yolov7-segmentation/releases/download/yolov7-segmentation/yolov7-seg.pt) and store in \"yolov7-segmentation\" directory.\n\n- Run the code with mentioned command below.\n```bash\n#for segmentation with detection\npython3 segment/predict.py --weights yolov7-seg.pt --source \"videopath.mp4\"\n\n#for segmentation with detection + Tracking\npython3 segment/predict.py --weights yolov7-seg.pt --source \"videopath.mp4\" --trk\n\n#save the labels files of segmentation\npython3 segment/predict.py --weights yolov7-seg.pt --source \"videopath.mp4\" --save-txt\n```\n\n- Output file will be created in the working directory with name `yolov7-segmentation/runs/predict-seg/exp/original-video-name.mp4`\u003c/b\u003e\n\n### RESULTS\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eCar Semantic Segmentation\u003c/td\u003e\n     \u003ctd\u003eCar Semantic Segmentation\u003c/td\u003e\n     \u003ctd\u003ePerson Segmentation + Tracking\u003c/td\u003e\n     \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003cimg src=\"https://user-images.githubusercontent.com/62513924/190402435-931f0ee3-9af1-4399-8222-1028d5afbd1a.png\" width=640 height=180\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"https://user-images.githubusercontent.com/62513924/190402752-521b7815-bea8-4cef-8b36-54fb7a962244.png\" width=640 height=180\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"https://user-images.githubusercontent.com/62513924/191729411-a8d8b5e2-bdbf-4c0e-bd1b-a52e23f7c9d3.png\" width=640 height=180\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003c/tr\u003e\n \u003c/table\u003e\n\n\n### Custom Data Labelling\n\n- I have used [roboflow](https://roboflow.com/) for data labelling. \u003cb\u003eThe data labelling for Segmentation will be a Polygon box,While data labelling for object detection will be a bounding box\u003c/b\u003e\n\n- Go to the [link](https://app.roboflow.com/my-personal-workspace/createSample) and create a new workspace. Make sure to login with roboflow account.\n\n\n![1](https://user-images.githubusercontent.com/62513924/190390384-db8f71fa-e963-4ee6-aaca-c49e993c64ae.png)\n\n\n- Once you will click on \u003cb\u003ecreate workspace\u003c/b\u003e, You will see the popup as shown below to upload the dataset.\n\n![2](https://user-images.githubusercontent.com/62513924/190390882-fe08559d-ef47-450e-8613-2de899fffa4c.png)\n\n\n- Click on upload dataset and roboflow will ask for workspace name as shown below. Fill that form and then click on \u003cb\u003eCreate Private Project\u003c/b\u003e\n- Note: Make sure to select \u003cb\u003eInstance Segmentation\u003c/b\u003e Option in below image.\n ![dataset](https://user-images.githubusercontent.com/62513924/190853038-612791d0-9b33-4222-b28a-63ac4c13ed83.png)\n\n\n-You can upload your dataset now.\n\n![Screenshot 2022-09-17 155330](https://user-images.githubusercontent.com/62513924/190853135-887b389c-2356-4435-a946-867bb05ac4f2.png)\n\n- Once files will upload, you can click on \u003cb\u003eFinish Uploading\u003c/b\u003e.\n\n- Roboflow will ask you to assign Images to someone, click on \u003cb\u003eAssign Images\u003c/b\u003e.\n\n- After that, you will see the tab shown below.\n\n![6](https://user-images.githubusercontent.com/62513924/190392948-90010cd0-ef88-437a-b94f-44ee93d8bc31.png)\n\n\n- Click on any Image in \u003cb\u003eUnannotated\u003c/b\u003e tab, and then you can start labelling.\n\n- \u003cb\u003eNote:\u003c/b\u003e Press p and then draw polygon points for \u003cB\u003esegmentation\u003c/b\u003e\n\n![10](https://user-images.githubusercontent.com/62513924/190394353-d7dd7b7f-7a07-4738-99b6-1d5ae66b5bca.png)\n\n\n- Once you will complete labelling, you can then export the data and follow mentioned steps below to start training.\n\n### Custom Training\n\n- Move your (segmentation custom labelled data) inside \"yolov7-segmentation\\data\" folder by following mentioned structure.\n\n\n\n![ss](https://user-images.githubusercontent.com/62513924/190388927-62a3ee84-bad8-4f59-806f-1185acdc8acb.png)\n\n\n\n- Go to the \u003cb\u003edata\u003c/b\u003e folder, create a file with name \u003cb\u003ecustom.yaml\u003c/b\u003e and paste the mentioned code below inside that.\n\n```yaml\ntrain: \"path to train folder\"\nval: \"path to validation folder\"\n# number of classes\nnc: 1\n# class names\nnames: [ 'car']\n```\n\n- Download weights from the \u003ca href= \"https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-seg.pt\"\u003elink\u003c/a\u003e and move to \u003cb\u003eyolov7-segmentation\u003c/b\u003e folder.\n- Go to the terminal, and run mentioned command below to start training.\n```bash\npython3 segment/train.py --data data/custom.yaml \\\n                          --batch 4 \\\n                          --weights \"yolov7-seg.pt\"\n                          --cfg yolov7-seg.yaml \\\n                          --epochs 10 \\\n                          --name yolov7-seg \\\n                          --img 640 \\\n                          --hyp hyp.scratch-high.yaml\n```\n\n### Custom Model Detection Command\n```bash\npython3 segment/predict.py --weights \"runs/yolov7-seg/exp/weights/best.pt\" --source \"videopath.mp4\"\n```\n\n### RESULTS\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eCar Semantic Segmentation\u003c/td\u003e\n     \u003ctd\u003eCar Semantic Segmentation\u003c/td\u003e\n     \u003ctd\u003ePerson Segmentation + Tracking\u003c/td\u003e\n     \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003cimg src=\"https://user-images.githubusercontent.com/62513924/190402435-931f0ee3-9af1-4399-8222-1028d5afbd1a.png\" width=640 height=180\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"https://user-images.githubusercontent.com/62513924/190410343-ada838c6-e505-4248-8a76-fbc5996e091e.png\" width=640 height=180\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"https://user-images.githubusercontent.com/62513924/191729411-a8d8b5e2-bdbf-4c0e-bd1b-a52e23f7c9d3.png\" width=640 height=180\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003c/tr\u003e\n \u003c/table\u003e\n\n\n### References\n- https://github.com/WongKinYiu/yolov7/tree/u7/seg\n- https://github.com/ultralytics/yolov5\n\n**Some of my articles/research papers | computer vision awesome resources for learning | How do I appear to the world? 🚀**\n\n[Ultralytics YOLO11: Object Detection and Instance Segmentation🤯](https://muhammadrizwanmunawar.medium.com/ultralytics-yolo11-object-detection-and-instance-segmentation-88ef0239a811) ![Published Date](https://img.shields.io/badge/published_Date-2024--10--27-brightgreen)\n\n[Parking Management using Ultralytics YOLO11](https://muhammadrizwanmunawar.medium.com/parking-management-using-ultralytics-yolo11-fba4c6bc62bc) ![Published Date](https://img.shields.io/badge/published_Date-2024--11--10-brightgreen)\n\n[My 🖐️Computer Vision Hobby Projects that Yielded Earnings](https://muhammadrizwanmunawar.medium.com/my-️computer-vision-hobby-projects-that-yielded-earnings-7923c9b9eead) ![Published Date](https://img.shields.io/badge/published_Date-2023--09--10-brightgreen)\n\n[Best Resources to Learn Computer Vision](https://muhammadrizwanmunawar.medium.com/best-resources-to-learn-computer-vision-311352ed0833) ![Published Date](https://img.shields.io/badge/published_Date-2023--06--30-brightgreen)\n\n[Roadmap for Computer Vision Engineer](https://medium.com/augmented-startups/roadmap-for-computer-vision-engineer-45167b94518c)  ![Published Date](https://img.shields.io/badge/published_Date-2022--08--07-brightgreen)\n\n[How did I spend 2022 in the Computer Vision Field](https://www.linkedin.com/pulse/how-did-i-spend-2022-computer-vision-field-muhammad-rizwan-munawar) ![Published Date](https://img.shields.io/badge/published_Date-2022--12--20-brightgreen)\n\n[Domain Feature Mapping with YOLOv7 for Automated Edge-Based Pallet Racking Inspections](https://www.mdpi.com/1424-8220/22/18/6927) ![Published Date](https://img.shields.io/badge/published_Date-2022--09--13-brightgreen)\n\n[Exudate Regeneration for Automated Exudate Detection in Retinal Fundus Images](https://ieeexplore.ieee.org/document/9885192) ![Published Date](https://img.shields.io/badge/published_Date-2022--09--12-brightgreen)\n\n[Feature Mapping for Rice Leaf Defect Detection Based on a Custom Convolutional Architecture](https://www.mdpi.com/2304-8158/11/23/3914) ![Published Date](https://img.shields.io/badge/published_Date-2022--12--04-brightgreen)\n\n[Yolov5, Yolo-x, Yolo-r, Yolov7 Performance Comparison: A Survey](https://aircconline.com/csit/papers/vol12/csit121602.pdf)  ![Published Date](https://img.shields.io/badge/published_Date-2022--09--24-brightgreen)\n\n[Explainable AI in Drug Sensitivity Prediction on Cancer Cell Lines](https://ieeexplore.ieee.org/document/9922931)  ![Published Date](https://img.shields.io/badge/published_Date-2022--09--23-brightgreen)\n\n[Train YOLOv8 on Custom Data](https://medium.com/augmented-startups/train-yolov8-on-custom-data-6d28cd348262)  ![Published Date](https://img.shields.io/badge/published_Date-2022--09--23-brightgreen)\n\n\n**More Information**\n\nFor more details, you can reach out to me on [Medium](https://muhammadrizwanmunawar.medium.com/) or can connect with me on [LinkedIn](https://www.linkedin.com/in/muhammadrizwanmunawar/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizwanmunawar%2Fyolov7-segmentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frizwanmunawar%2Fyolov7-segmentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizwanmunawar%2Fyolov7-segmentation/lists"}