[MAC] LABELIMG 설치하고 실행하기 (for YOLO)

Nanyoung Kim
5 min readOct 31, 2020

앞의 포스팅에서 ffmpeg 를 통해 동영상에서 추출한 jpg 파일에 라벨링을 해보자.

참고 — https://nero.devstory.co.kr/post/pj-too-real-03/

  1. git clone labelimg

https://github.com/tzutalin/labelImg 로 이동해서 레포지토리를 클론한다.

git clone https://github.com/tzutalin/labelImg.git

2. 설치 환경

  • 위와 같이 설치한다.

그런데 두번째 라인인 ‘pip3 install pipenv’ 에서 아래와 같은 에러가 발생했다.

ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.pytest-astropy 0.8.0 requires pytest-cov>=2.0, which is not installed.pytest-astropy 0.8.0 requires pytest-filter-subpackage>=0.1, which is not installed.pytest-remotedata 0.3.2 requires pytest>=3.1, but you'll have pytest 0.0.0 which is incompatible.pytest-openfiles 0.5.0 requires pytest>=4.6, but you'll have pytest 0.0.0 which is incompatible.pytest-doctestplus 0.8.0 requires pytest>=4.0, but you'll have pytest 0.0.0 which is incompatible.pytest-astropy 0.8.0 requires pytest>=4.6, but you'll have pytest 0.0.0 which is incompatible.pytest-astropy-header 0.1.2 requires pytest>=2.8, but you'll have pytest 0.0.0 which is incompatible.python -m pip install --upgrade pip
pip install example --use-feature=2020-resolver

위와 같이 터미널에 입력한 후 다시 ‘pip3 install pipenv’를 입력하면 성공적으로 설치된다.

3.ModuleNotFoundError: No module named ‘libs.resources’ 에러 해결

python3 labelImg.py 

에서 모듈이 없다는 에러가 발생했다.

pyrcc5 -o libs/resources.py resources.qrc

위의 라인을 터미널에 타이핑하고 다시 labelImg.py를 실행시키면

프로그램이 열리는 것을 확인할 수 있다.

4. 클론한 lagelImg 폴더 안의 data/predefined_classes.txt 를 수정한다.

본인은 신호등 검출을 목적으로 하기 때문에

아래와 같이 신호등 클래스 1개를 지정했다.

5. 이미지 resize

  • 원본 크기가 1080 x 1920 으로 크기 때문에 학습에 시간이 많이 소요된다.
  • 크기를 1/10로 줄여보자
  • ModuleNotFoundError: No module named ‘PIL’ 이라는 에러가 나온다면 아래와 같이 모듈을 설치해준다.
pip install pillow 

-

import osimport globfrom PIL import Imagefiles = glob.glob('~/*.jpg')for f in files:img = Image.open(f)img_resize = img.resize((int(img.width / 10), int(img.height / 10)))title, ext = os.path.splitext(f)img_resize.save(title + '_resize' + ext)

--

--