Tensorflow

[object detection] Local에서 vscode를 이용해서 설치하기

jasonshin 2021. 12. 29. 10:25

오브젝트 디텍션을 하기 위한 전체 설정 웹사이트

 

https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html

 

Installation — TensorFlow 2 Object Detection API tutorial documentation

Anaconda Python 3.8 (Optional) Although having Anaconda is not a requirement in order to install and use TensorFlow, I suggest doing so, due to it’s intuitive way of managing packages and setting up new virtual environments. Anaconda is a pretty useful t

tensorflow-object-detection-api-tutorial.readthedocs.io

1. vscode anaconda base환경 터미널에서 아래 코드 실행해서 텐서플로 설치

conda create -n tensorflow pip python=3.9

2. tensorlow환경에서 아래 코드 실행해서 팩키지 설치

pip install --ignore-installed --upgrade tensorflow==2.5.0

3. 아래 코드 실행후 설치 확인

  • python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
    

4. TensorFlow 이름으로 폴더 생성 (e.g. C:\Users\sglvladi\Documents\TensorFlow)

  • From your Terminal cd into the TensorFlow directory.
  • To download the models you can either use Git to clone the TensorFlow Models repository inside the TensorFlow folder, or you can simply download it as a ZIP and extract its contents inside the TensorFlow folder. To keep things consistent, in the latter case you will have to rename the extracted folder models-master to models.
  • You should now have a single folder named models under your TensorFlow folder, which contains another 4 folders as such:
    TensorFlow/
    └─ models/
       ├─ community/
       ├─ official/
       ├─ orbit/
       ├─ research/
       └── ...​

5. vscode에서 경로이동 

cd 주소복사

 

6. 아래 코드 실행

protoc object_detection/protos/*.proto --python_out=.

 

7. 시스템 환경 변수 설정

환경변수에 path에서 bin이 있어야 한다.

 

8. 아래 설치

pip install cython
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI

9. window powershell에서 (cp명령은 리눅스 명령이라 vscode에서 실행안됨)
Tensorflow\models\research 경로로 설정 <= 폴더에 가서 경로복사 한후 cd 주소붙여넣기
아래 코드 실행

cp object_detection/packages/tf2/setup.py .


10. 파일주소 복사하고 vscode에서 Tensorflow\models\research경로로 설정
아래 코드 실행

python -m pip install --use-feature=2020-resolver .

11. vscode에 

python object_detection/builders/model_builder_tf2_test.py

를 넣어서 테스트. 

 

12. 아래 클릭해서 환경 변경

13(완료). 내가 만든 tensorflow환경으로 선택 

 

(참고)

 

 

반응형