标注数据集
https://github.com/wkentaro/labelme
笔者:macox
终端代码安装:
brew install qt qt4 || brew install pyqt # qt4 is deprecated(显示报错找不到qt4就直接pyqt4)
pip install labelme
Run** labelme –help **for detail.
from matplotlib.backends import _macosx
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
解决方法:
vim ~/.matplotlib/matplotlibrc
然后输入以下内容:
backend: TkAgg
注:
$ vi myfile
进入vi之后,是处于「命令行模式」,您要切换到「插入模式」才能够输入文字
i: 「命令行模式」→「插入模式」
ESC: 「插入模式」→「命令行模式」
Traceback (most recent call last):
File "/usr/local/bin/labelme", line 7, in <module>
from labelme.app import main
File "/Library/Python/2.7/site-packages/labelme/app.py", line 37, in <module>
from PyQt4.QtGui import *
ImportError: No module named PyQt4.QtGui
解决方法:
**brew uninstall PyQt5
labelme –help**
报错:ImportError: cannot import name QtCore
* brew install PyQt5 *
如果上面的这个方法后还不行就将下面的代码加入~/.bash_profile中:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
Run** labelme –help **for detail.
Bad key "ckend" on line 1 in
/Users/muaxiu/.matplotlib/matplotlibrc.
You probably need to get an updated matplotlibrc file from
http://github.com/matplotlib/matplotlib/blob/master/matplotlibrc.template
or from the matplotlib source distribution
usage: labelme [-h] [-O OUTPUT] [filename]
positional arguments:
filename image or label filename
optional arguments:
-h, --help show this help message and exit
-O OUTPUT, --output OUTPUT
output label name
打开labelme可视化窗口
labelme # Open GUI
用labelme打开指定文件
labelme static/apc2016_obj3.jpg # Specify file
用labelme打开指定文件退出后保存为XX.json文件
labelme static/apc2016_obj3.jpg -O static/apc2016_obj3.json # Close window after the save
快速查看json文件,可以使用实用程序脚本:
labelme_draw_json static/apc2016_obj3.json
**Convert to Dataset
To convert the json to set of image and label, you can run following:**
labelme_json_to_dataset static/apc2016_obj3.json
即可得到一个文件夹,有四个文件,*.png,info.yaml,label.png, label_viz.png。
其中label.png即是我们要的label_data.
看起来是全黑的,然而读到像素中,是可以看到对相同类别的文件进行标注了。
笔者还安装了labelImg,综合考量选择了Labelme,以下是LabelImg的安装过程
原作者github:https://github.com/tzutalin/labelImg#macos
安装参考:http://blog.csdn.net/roguesir/article/details/73647695
macOS
Python 2 + Qt4
brew install qt qt4
brew install libxml2
make qt4py2
python labelImg.py
python labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]
笔者电脑/装载软件:
Mac os
python2.7.13
brew install cartr/qt4/pyqt
配置环境变量
whichpython/usr/bin/python w h i c h p y t h o n / u s r / b i n / p y t h o n which brew
/usr/local/bin/brew
PyQt4是通过brew安装的,明显这两个路径不一致,导致问题,解决如下:
cd/usr/local/lib/python2.7/site−packages c d / u s r / l o c a l / l i b / p y t h o n 2.7 / s i t e − p a c k a g e s ls
open /.bashprofile将下面的代码加入~/.bashprofile中:exportPYTHONPATH=/usr/local/lib/python2.7/site−packages: o p e n / . b a s h p r o f i l e 将 下 面 的 代 码 加 入 ~ / . b a s h p r o f i l e 中 : e x p o r t P Y T H O N P A T H = / u s r / l o c a l / l i b / p y t h o n 2.7 / s i t e − p a c k a g e s : PYTHONPATH
然后关闭terminal,重新开启,进入python中import:
这样,PyQt4就装好了。
sudo pip install lxml
sudo pip install labelImg
文件夹内:shift+command+G
前往/usr/local/bin/labelImg
打开labelImg
from PyQt4.QtGui import *
ImportError: No module named PyQt4.QtGui
cd /usr/local/lib/python2.7/site-packages
ls
既有PyQt4也有PyQt5
pip uninstall 所有刚刚装的重新装一遍
**解决:**Pyqt5并不兼容pyqt4,我觉得你需要把pyqt5改成pyqt4,brew uninstall qt5,先把pyqt5卸掉,然后在装pyqt4试试
1.利用上述方式,创建启动。
2.击菜单上Change default saved annotation folder
3.点击’Open Dir’
4.点击 ‘Create RectBox’
5.点击左键,选择一个区域来用矩形框注释
6.用右键,拖拽矩形框,复制或移动
这个注释将被存储到你指定的文件夹。
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
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
⇒ python
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
from PyQt4 import QtCore, QtGui ,QtNetwork
quit()