- How to run Code on Windows
- How to run Code on Linux
- How to train on Custom Data
- Development of streamlit dashboard for Instance-Segmentation with Object Tracking
- GPU (Needed for installation of detectron2)
- Git for Windows Download Link
- Git on Linux (Install git on linux by using command in terminal.
sudo apt-get install git
)
- Open the terminal and run mentioned command below to download & install anaconda for linux operating system
wget https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh
bash Anaconda3-2022.05-Linux-x86_64.sh #(you will need to accept license terms from terminal, then you installation will continue)
-
Once Anaconda Installed, restart your machine.
-
Open the terminal in home folder, and run the mentioned command below.
cd ~
sudo chmod 777 .conda
- Clone the repository.
git clone https://github.com/RizwanMunawar/yolov7-instance-segmentation
- Goto the cloned folder.
cd yolov7-instance-segmentation
- Create envirnoment
conda env create -f envirnoment.yml
- Activate the envirnoment
conda activate detectron2
- Install extra modules
pip install -r requirements.txt
- Download weights
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-mask.pt
- Run Code with mentioned command.
#Basic Usage
python instance-segmentation.py
#For LiveStream (Ip Stream URL Format i.e "rtsp://username:pass@ipaddress:portno/video/video.amp")
python instance-segmentation.py --source "your IP Camera Stream URL"
#For WebCam
python instance-segmentation.py --source 0
#For External Camera
python instance-segmentation.py --source 1
- Output file will be created in the working directory with name ("your-file-name-without-extension"+"_segmentation.mp4")
- Download the 64-Bit or 32-Bit Anaconda (Based on your system specifications).
- Install the executable
- Goto Start Menu and search for "Anaconda Prompt". Double Click to Open it.
- Change the path of anaconda prompt with mentioned command below.
cd "C:\Users\"yourusername"\Desktop
- Clone the repository.
git clone https://github.com/RizwanMunawar/yolov7-instance-segmentation
- Goto the cloned folder.
cd yolov7-instance-segmentation
- Create envirnoment
conda env create -f environment.yml
- Activate the envirnoment
conda activate detectron2
- Install extra modules
pip install -r requirements.txt
- Download weights from link and move them to the cloned folder.
- Run Code with mentioned command.
#Basic Usage
python instance-segmentation.py
#For LiveStream (Ip Stream URL Format i.e "rtsp://username:pass@ipaddress:portno/video/video.amp")
python instance-segmentation.py --source "your IP Camera Stream URL"
#For WebCam
python instance-segmentation.py --source 0
#For External Camera
python instance-segmentation.py --source 1
- Output file will be created in the working directory with name ("your-file-name-without-extension"+"_segmentation.mp4")
Football Match Image Segmentation | Cricket Match Image Segmentation | FPS and Time Comparision Graph |
![]() |
![]() |
![]() |
- Make sure to follow above mentioned steps before you will start training on custom dataset.
- Make a folder name inside yolov7-instance-segmentation with name dataset.
- Move your (segmentation custom labelled data) inside that folder with mentioned structure.
└── dataset
└── train
└── images (folder including all training images)
└── labels (folder including all training labels)
└── test
└── images (folder including all testing images)
└── labels (folder including all testing labels)
- Go to the data folder and create a file with name custom.yaml and paste the mentioned code below inside that.
train: "path to train folder"
val: "path to validation folder"
# number of classes
nc: 2
# class names
names: [ 'person','Bike']
- Go to the terminal, and run mentioned command below. (Make sure to activate first conda envirnoment "detectron2")
python train.py --weights yolov7-mask.pt --cfg cfg/yolov7-mask.yaml --batch-size 4 --img 256 --hyp data/hyp.scratch.mask.yaml --data data/custom.yaml
python test.py --data data/custom.yaml --img 256 --conf 0.25 --iou 0.65 --weights yolov7-mask.pt
- https://medium.com/augmented-startups/yolov7-training-on-custom-data-b86d23e6623
- https://medium.com/augmented-startups/roadmap-for-computer-vision-engineer-45167b94518c
- https://medium.com/augmented-startups/yolor-or-yolov5-which-one-is-better-2f844d35e1a1
- https://medium.com/augmented-startups/train-yolor-on-custom-data-f129391bd3d6
- https://medium.com/augmented-startups/develop-an-analytics-dashboard-using-streamlit-e6282fa5e0f