Label-Detection is a graphical image annotation tool and using this tool a user can also train and test large satellite images. User can create small patches from a large image, annotate it, create training and testing data, select model, train-test the model. The annotations (labeling) part of this application is based on this repository.
It is written in Python and uses Qt for its graphical interface.
Annotations are saved as XML files in PASCAL VOC format, the format used by ImageNet.
Users can use many deep learning models such as Faster RCNN Resnet or SSD Mobilenet.
We can see an example of image labeling and detection in the following images. Sample Labeling, Training and Testing procedures can be found in the videos that are posted below the images.
Watch a demo video [Labeling] [Created by tzutalin]
Watch a demo video [Training Part-1]
Watch a demo video [Training Part-2]
Watch a demo video [Testing]
Linux/Ubuntu requires at least Python 3.6 and has been tested with PyQt 5.8. Download or clone the Label-Detect repository and then run the following commands (Ubuntu/Windows) within the Label-Detect directory.
Install Tensorflow with GPU support
Install Tensorflow with GPU support [Tensorflow Documentation]
sudo apt-get install pyqt5-dev-tools sudo pip3 install -r requirements/requirements-linux-python3.txt make qt5py3 python3 labelImg.py
Download and install Anaconda (Python 3.6+)
Install Tensorflow with GPU support
Open the Anaconda Prompt and go to the Labe-Detect directory
conda install pip pip install -r requirements/requirements-linux-python3.txt pyrcc5 -o resources.py resources.qrc python labelImg.py
- Tensoflow object detection API is used only for training purpose. By using this API we can use different types of models to train. I am also integrating models that are not in the API.
- Ubuntu: Go to the '/home/your-username/' directory and create a folder named 'tensorflow' and go into the folder. Now download or clone this repository and follow this installation process.
- Windows: Download Git Bash, go to the 'C:/Users/your-username/' directory of your computer, create a folder named 'tensorflow' and go into the folder. Now follow this tutorial or this tutorial
- Build and launch using the instructions above.
- Click 'Change default saved annotation folder' in Menu/File
- Click 'Open Dir'
- Click 'Create RectBox'
- Click and release left mouse to select a region to annotate the rect box
- You can use right mouse to drag the rect box to copy or move it
The annotation will be saved to the folder you specify.
You can refer to the below hotkeys to speed up your workflow.
- Select 'File -> Open Image and Slice' [Ctrl+i]
- Select the desired Satellite Image and then can enter the slice/patch height and width. The default value is 512 pixels.
- Then select 'Start Slicing'
- After Slicing the big image, you can see a new directory on the image's directory and within it, you can see image slices/patches.
- Annotate the images and save the .xml files according to the 'Annotation' section discussed above.
- Select 'File -> Select Directory to Create TFrecords' [Ctrl+t] and select the directory that contains all the .xml files.
- Then TFRecords files for training and testing will be created under TFrecords folder within the directory selected in step 6.
- Select 'Start Training' [Ctrl+Shift+t]
- Select the TFRecord file for training which is 'train.record'
- Select 'detection.pbtxt' and a '.config' file from 'Label-Detect/Training_config' directory. If you want to use Faster R-CNN ResNet-101 then select the corresponding file otherwise you can select the '.config' file for SSD MobileNet.
- Download the Faster R-CNN Resnet-101 model, extract it and select the 'model.ckpt.index' file for the model file. You can also use SSD MobileNet
- If you want to use other models you can download from here and the corresponding .config files from 'tensorflow/models/research/object_detection/samples/configs' or here
- Then you can start training and after the completion of the training you will get 'frozen_inference_graph.pb' file and this file will be used for testing images.
- Here, the training is for three labels which are in 'detection.pbtxt' file. If you want to create your own labels then just edit the detection.pbtxt file. Give an item id starting from value 1 and give it a name. The format must be same as the given 'detectin.pbtxt' file.
- In the config files that are provided in the repository in 'Label-Detect/Training_config', you can find "num_steps: 20000". This is the number of training steps. You can change the steps as you wish.
- Select 'File -> Load Test Image to Get the Results'
- For testing large images, the images must be sliced into small overlapping patches for detection. Therefore, enter the height and width of the slices. The default size is 512 for height and width.
- Then select the 'frozen_inference_graph.pb' file that is created on the training phase.
- Then after some processing time, (slicing, detection of objects, convert local coordinates of the bounding box of small images to the global coordinate of the big image and use non-max suppression to the overlapped detection) the final labeled image with bounding boxes will be uploaded.
Ctrl + u | Load all of the images from a directory |
Ctrl + r | Change the default annotation target dir |
Ctrl + s | Save |
Ctrl + d | Copy the current label and rect box |
Ctrl + i | Open Image and Slice |
Ctrl + t | Select Directory to Create TFrecords |
Ctrl + Shift + t | Start Training |
Ctrl + Shift + w | Load Test Image to Get the Results |
Space | Flag the current image as verified |
w | Create a rect box |
d | Next image |
a | Previous image |
del | Delete the selected rect box |
Ctrl++ | Zoom in |
Ctrl-- | Zoom out |
↑→↓← | Keyboard arrows to move selected rect box |
Verify Image:
When pressing space, the user can flag the image as verified, a green background will appear. This is used when creating a dataset automatically, the user can then through all the pictures and flag them instead of annotate them.
Send a pull request
Tzutalin. LabelImg. Git code (2015). https://github.com/tzutalin/labelImg
App Icon based on Icon by Nick Roach (GPL) <https://www.elegantthemes.com/> <https://www.iconfinder.com/icons/1054978/shop_tag_icon> __