|
| 1 | +LabelImg |
| 2 | +======== |
| 3 | + |
| 4 | +.. image:: https://img.shields.io/pypi/v/labelimg.svg |
| 5 | + :target: https://pypi.python.org/pypi/labelimg |
| 6 | + |
| 7 | +.. image:: https://img.shields.io/travis/tzutalin/labelImg.svg |
| 8 | + :target: https://travis-ci.org/tzutalin/labelImg |
| 9 | + |
| 10 | +.. image:: /resources/icons/app.png |
| 11 | + :width: 200px |
| 12 | + :align: center |
| 13 | + |
| 14 | +LabelImg is a graphical image annotation tool. |
| 15 | + |
| 16 | +It is written in Python and uses Qt for its graphical interface. |
| 17 | + |
| 18 | +Annotations are saved as XML files in PASCAL VOC format, the format used |
| 19 | +by `ImageNet <http://www.image-net.org/>`__. Besides, it also supports YOLO format |
| 20 | + |
| 21 | +.. image:: https://raw.githubusercontent.com/tzutalin/labelImg/master/demo/demo3.jpg |
| 22 | + :alt: Demo Image |
| 23 | + |
| 24 | +.. image:: https://raw.githubusercontent.com/tzutalin/labelImg/master/demo/demo.jpg |
| 25 | + :alt: Demo Image |
| 26 | + |
| 27 | +`Watch a demo video <https://youtu.be/p0nR2YsCY_U>`__ |
| 28 | + |
| 29 | +Installation |
| 30 | +------------------ |
| 31 | + |
| 32 | + |
| 33 | +Build from source |
| 34 | +~~~~~~~~~~~~~~~~~ |
| 35 | + |
| 36 | +Linux/Ubuntu/Mac requires at least `Python |
| 37 | +2.6 <https://www.python.org/getit/>`__ and has been tested with `PyQt |
| 38 | +4.8 <https://www.riverbankcomputing.com/software/pyqt/intro>`__. However, `Python |
| 39 | +3 or above <https://www.python.org/getit/>`__ and `PyQt5 <https://pypi.org/project/PyQt5/>`__ are strongly recommended. |
| 40 | + |
| 41 | + |
| 42 | +Ubuntu Linux |
| 43 | +^^^^^^^^^^^^ |
| 44 | + |
| 45 | +Python 3 + Qt5 |
| 46 | + |
| 47 | +.. code:: shell |
| 48 | + |
| 49 | + sudo apt-get install pyqt5-dev-tools |
| 50 | + sudo pip3 install -r requirements/requirements-linux-python3.txt |
| 51 | + make qt5py3 |
| 52 | + python3 labelImg.py |
| 53 | + python3 labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE] |
| 54 | + |
| 55 | +macOS |
| 56 | +^^^^^ |
| 57 | + |
| 58 | +Python 3 + Qt5 |
| 59 | + |
| 60 | +.. code:: shell |
| 61 | + |
| 62 | + brew install qt # Install qt-5.x.x by Homebrew |
| 63 | + brew install libxml2 |
| 64 | + |
| 65 | + or using pip |
| 66 | + |
| 67 | + pip3 install pyqt5 lxml # Install qt and lxml by pip |
| 68 | + |
| 69 | + make qt5py3 |
| 70 | + python3 labelImg.py |
| 71 | + python3 labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE] |
| 72 | + |
| 73 | + |
| 74 | +Python 3 Virtualenv (Recommended) |
| 75 | + |
| 76 | +Virtualenv can avoid a lot of the QT / Python version issues |
| 77 | + |
| 78 | +.. code:: shell |
| 79 | + |
| 80 | + brew install python3 |
| 81 | + pip3 install pipenv |
| 82 | + pipenv run pip install pyqt5==5.12.1 lxml |
| 83 | + pipenv run make qt5py3 |
| 84 | + pipenv run python3 labelImg.py |
| 85 | + [Optional] rm -rf build dist; python setup.py py2app -A;mv "dist/labelImg.app" /Applications |
| 86 | + |
| 87 | +Note: The Last command gives you a nice .app file with a new SVG Icon in your /Applications folder. You can consider using the script: build-tools/build-for-macos.sh |
| 88 | + |
| 89 | + |
| 90 | +Windows |
| 91 | +^^^^^^^ |
| 92 | + |
| 93 | +Install `Python <https://www.python.org/downloads/windows/>`__, |
| 94 | +`PyQt5 <https://www.riverbankcomputing.com/software/pyqt/download5>`__ |
| 95 | +and `install lxml <http://lxml.de/installation.html>`__. |
| 96 | + |
| 97 | +Open cmd and go to the `labelImg <#labelimg>`__ directory |
| 98 | + |
| 99 | +.. code:: shell |
| 100 | + |
| 101 | + pyrcc4 -o libs/resources.py resources.qrc |
| 102 | + For pyqt5, pyrcc5 -o libs/resources.py resources.qrc |
| 103 | + |
| 104 | + python labelImg.py |
| 105 | + python labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE] |
| 106 | + |
| 107 | +Windows + Anaconda |
| 108 | +^^^^^^^^^^^^^^^^^^ |
| 109 | + |
| 110 | +Download and install `Anaconda <https://www.anaconda.com/download/#download>`__ (Python 3+) |
| 111 | + |
| 112 | +Open the Anaconda Prompt and go to the `labelImg <#labelimg>`__ directory |
| 113 | + |
| 114 | +.. code:: shell |
| 115 | + |
| 116 | + conda install pyqt=5 |
| 117 | + conda install -c anaconda lxml |
| 118 | + pyrcc5 -o libs/resources.py resources.qrc |
| 119 | + python labelImg.py |
| 120 | + python labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE] |
| 121 | + |
| 122 | +Get from PyPI but only python3.0 or above |
| 123 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 124 | +This is the simplest (one-command) install method on modern Linux distributions such as Ubuntu and Fedora. |
| 125 | + |
| 126 | +.. code:: shell |
| 127 | + |
| 128 | + pip3 install labelImg |
| 129 | + labelImg |
| 130 | + labelImg [IMAGE_PATH] [PRE-DEFINED CLASS FILE] |
| 131 | + |
| 132 | + |
| 133 | +Use Docker |
| 134 | +~~~~~~~~~~~~~~~~~ |
| 135 | +.. code:: shell |
| 136 | + |
| 137 | + docker run -it \ |
| 138 | + --user $(id -u) \ |
| 139 | + -e DISPLAY=unix$DISPLAY \ |
| 140 | + --workdir=$(pwd) \ |
| 141 | + --volume="/home/$USER:/home/$USER" \ |
| 142 | + --volume="/etc/group:/etc/group:ro" \ |
| 143 | + --volume="/etc/passwd:/etc/passwd:ro" \ |
| 144 | + --volume="/etc/shadow:/etc/shadow:ro" \ |
| 145 | + --volume="/etc/sudoers.d:/etc/sudoers.d:ro" \ |
| 146 | + -v /tmp/.X11-unix:/tmp/.X11-unix \ |
| 147 | + tzutalin/py2qt4 |
| 148 | + |
| 149 | + make qt4py2;./labelImg.py |
| 150 | + |
| 151 | +You can pull the image which has all of the installed and required dependencies. `Watch a demo video <https://youtu.be/nw1GexJzbCI>`__ |
| 152 | + |
| 153 | + |
| 154 | +Usage |
| 155 | +----- |
| 156 | + |
| 157 | +Steps (PascalVOC) |
| 158 | +~~~~~~~~~~~~~~~~~ |
| 159 | + |
| 160 | +1. Build and launch using the instructions above. |
| 161 | +2. Click 'Change default saved annotation folder' in Menu/File |
| 162 | +3. Click 'Open Dir' |
| 163 | +4. Click 'Create RectBox' |
| 164 | +5. Click and release left mouse to select a region to annotate the rect |
| 165 | + box |
| 166 | +6. You can use right mouse to drag the rect box to copy or move it |
| 167 | + |
| 168 | +The annotation will be saved to the folder you specify. |
| 169 | + |
| 170 | +You can refer to the below hotkeys to speed up your workflow. |
| 171 | + |
| 172 | +Steps (YOLO) |
| 173 | +~~~~~~~~~~~~ |
| 174 | + |
| 175 | +1. In ``data/predefined_classes.txt`` define the list of classes that will be used for your training. |
| 176 | + |
| 177 | +2. Build and launch using the instructions above. |
| 178 | + |
| 179 | +3. Right below "Save" button in the toolbar, click "PascalVOC" button to switch to YOLO format. |
| 180 | + |
| 181 | +4. You may use Open/OpenDIR to process single or multiple images. When finished with a single image, click save. |
| 182 | + |
| 183 | +A txt file of YOLO format will be saved in the same folder as your image with same name. A file named "classes.txt" is saved to that folder too. "classes.txt" defines the list of class names that your YOLO label refers to. |
| 184 | + |
| 185 | +Note: |
| 186 | + |
| 187 | +- Your label list shall not change in the middle of processing a list of images. When you save an image, classes.txt will also get updated, while previous annotations will not be updated. |
| 188 | + |
| 189 | +- You shouldn't use "default class" function when saving to YOLO format, it will not be referred. |
| 190 | + |
| 191 | +- When saving as YOLO format, "difficult" flag is discarded. |
| 192 | + |
| 193 | +Create pre-defined classes |
| 194 | +~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 195 | + |
| 196 | +You can edit the |
| 197 | +`data/predefined\_classes.txt <https://github.com/tzutalin/labelImg/blob/master/data/predefined_classes.txt>`__ |
| 198 | +to load pre-defined classes |
| 199 | + |
| 200 | +Hotkeys |
| 201 | +~~~~~~~ |
| 202 | + |
| 203 | ++--------------------+--------------------------------------------+ |
| 204 | +| Ctrl + u | Load all of the images from a directory | |
| 205 | ++--------------------+--------------------------------------------+ |
| 206 | +| Ctrl + r | Change the default annotation target dir | |
| 207 | ++--------------------+--------------------------------------------+ |
| 208 | +| Ctrl + s | Save | |
| 209 | ++--------------------+--------------------------------------------+ |
| 210 | +| Ctrl + d | Copy the current label and rect box | |
| 211 | ++--------------------+--------------------------------------------+ |
| 212 | +| Ctrl + Shift + d | Delete the current image | |
| 213 | ++--------------------+--------------------------------------------+ |
| 214 | +| Space | Flag the current image as verified | |
| 215 | ++--------------------+--------------------------------------------+ |
| 216 | +| w | Create a rect box | |
| 217 | ++--------------------+--------------------------------------------+ |
| 218 | +| d | Next image | |
| 219 | ++--------------------+--------------------------------------------+ |
| 220 | +| a | Previous image | |
| 221 | ++--------------------+--------------------------------------------+ |
| 222 | +| del | Delete the selected rect box | |
| 223 | ++--------------------+--------------------------------------------+ |
| 224 | +| Ctrl++ | Zoom in | |
| 225 | ++--------------------+--------------------------------------------+ |
| 226 | +| Ctrl-- | Zoom out | |
| 227 | ++--------------------+--------------------------------------------+ |
| 228 | +| ↑→↓← | Keyboard arrows to move selected rect box | |
| 229 | ++--------------------+--------------------------------------------+ |
| 230 | + |
| 231 | +**Verify Image:** |
| 232 | + |
| 233 | +When pressing space, the user can flag the image as verified, a green background will appear. |
| 234 | +This is used when creating a dataset automatically, the user can then through all the pictures and flag them instead of annotate them. |
| 235 | + |
| 236 | +**Difficult:** |
| 237 | + |
| 238 | +The difficult field is set to 1 indicates that the object has been annotated as "difficult", for example, an object which is clearly visible but difficult to recognize without substantial use of context. |
| 239 | +According to your deep neural network implementation, you can include or exclude difficult objects during training. |
| 240 | + |
| 241 | +How to reset the settings |
| 242 | +~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 243 | + |
| 244 | +In case there are issues with loading the classes, you can either: |
| 245 | + |
| 246 | +1. From the top menu of the labelimg click on Menu/File/Reset All |
| 247 | +2. Remove the `.labelImgSettings.pkl` from your home directory. In Linux and Mac you can do: |
| 248 | + `rm ~/.labelImgSettings.pkl` |
| 249 | + |
| 250 | + |
| 251 | +How to contribute |
| 252 | +~~~~~~~~~~~~~~~~~ |
| 253 | + |
| 254 | +Send a pull request |
| 255 | + |
| 256 | +License |
| 257 | +~~~~~~~ |
| 258 | +`Free software: MIT license <https://github.com/tzutalin/labelImg/blob/master/LICENSE>`_ |
| 259 | + |
| 260 | +Citation: Tzutalin. LabelImg. Git code (2015). https://github.com/tzutalin/labelImg |
| 261 | + |
| 262 | +Related and additional tools |
| 263 | +~~~~~~~ |
| 264 | + |
| 265 | +1. `ImageNet Utils <https://github.com/tzutalin/ImageNet_Utils>`__ to |
| 266 | + download image, create a label text for machine learning, etc |
| 267 | +2. `Use Docker to run labelImg <https://hub.docker.com/r/tzutalin/py2qt4>`__ |
| 268 | +3. `Generating the PASCAL VOC TFRecord files <https://github.com/tensorflow/models/blob/4f32535fe7040bb1e429ad0e3c948a492a89482d/research/object_detection/g3doc/preparing_inputs.md#generating-the-pascal-voc-tfrecord-files>`__ |
| 269 | +4. `App Icon based on Icon by Nick Roach (GPL) <https://www.elegantthemes.com/>`__ |
| 270 | +5. `Setup python development in vscode <https://tzutalin.blogspot.com/2019/04/set-up-visual-studio-code-for-python-in.html>`__ |
| 271 | +6. `The link of this project on iHub platform <https://code.ihub.org.cn/projects/260/repository/labelImg>`__ |
| 272 | +7. `Convert annotation files to CSV format or format for Google Cloud AutoML <https://github.com/tzutalin/labelImg/tree/master/tools>`__ |
| 273 | + |
| 274 | + |
| 275 | + |
| 276 | +Stargazers over time |
| 277 | +~~~~~~~~~~~~~~~~~~~~ |
| 278 | + |
| 279 | +.. image:: https://starchart.cc/tzutalin/labelImg.svg |
| 280 | + |
0 commit comments