We developed a semi-auto labelling tool that automatically labels images for a single class using a pretrained model.
- The tool currently supports the YOLOv5 model as an input model in the form of a
.pt
weight file. We plan to add support for more models in the future. - Presently, only classification for one class is supported, but future versions will include support for multiple classes.
- The output format is YOLO Darknet, though future versions may support other output formats as well.
-
Open a terminal (PowerShell or any other) and navigate to the repository path.
-
Create a new environment using Conda or any environment manager (optional but recommended).
-
If using
pip
, run the following command:pip install -r requirements.txt
If using Conda, create a new environment with the required packages using:
conda env create -f environments.yml
-
Rename your model weights file (in
.pt
extension) tomodel.pt
and place it in themodel
folder of the repository. (The default model included is for bees classification). -
Input your images into the
input
folder of the repository. -
Put the class name in
class_list.txt
. (Important!) -
Run the following command in the terminal:
python run.py
Optional Arguments:
-s
,--image_size
: Set the image size (single integer, default is 640).-c
,--conf_thres
: Set the confidence threshold (default is 0.35).-a
,--auto_annot
: Choose whether to run the auto annotator or not (Takes 'yes' or 'no', default is 'no').
Example with optional arguments:
python run.py -s 800 -c 0.4 -a yes
-
An interactive window will open as shown below:
-
Perform the labeling operations using the following keybindings:
- Right-click mouse: Remove a label
- Left-click: Draw a new label
- Q: Quit
- E: Reveal edges
- W/S: Navigate classes
- A/D: Navigate images
-
After quitting, the labeled output will be available in YOLO Darknet format in the
output/Yolo_darknet
folder. -
To clean up the output, you can run the following command (Make sure to save the output elsewhere before running this command!):
python clean_up.py
Link: scholar2001/semi_labelling
-
Pull the Image:
-
Pull the Docker image to your local system using the following command:
docker pull scholar2001/semi_labelling:latest
-
-
Install VcXsrv Windows X Server:
- Before running the image, install VcXsrv Windows X Server from here. This X Server allows us to share an X11-session on a Windows host, enabling GUI support in Docker Containers on Windows.
-
Run the Image:
-
Execute the command below to run the image, mapping input and output folders, and setting the DISPLAY environment variable:
docker run -it -v path/to/image/input/folder:/app/input -v path/to/output/folder:/app/output -e DISPLAY=host.docker.internal:0 -v /tmp/.X11-unix:/tmp/.X11-unix scholar2001/semi_labelling:latest
Replace
path/to/image/input/folder
andpath/to/output/folder
with the respective paths on your local system. -
To use the Semi_Labelling tool on other operating systems, you need to forward the X11-Session to display the GUI.
Kindly refer to the documentation or instructions for your specific operating system on how to forward the X11-Session. This will enable you to run the tool with a GUI interface.
For further details and usage instructions, visit the Docker Hub repository: scholar2001/semi_labelling
Note: The instructions provided here assume you have Docker installed and properly configured on your system. Ensure that you have the required permissions and access to the input and output folders on your local system.
The code for run.py
(which includes the GUI interface of the labeller) is based on this repository by Cartucho: https://github.com/Cartucho/OpenLabeling/blob/master/main/main.py