딥러닝 모델에서 cpu, gpu 사용 operation 확인을 위한 프로파일링
프로파일링을 사용하면 어디에서 cpu를 사용하는지 gpu를 사용하는지 얼만큼 사용하는지 알 수 있다.
딥러닝 모델에서 cpu, gpu 사용 operation 확인을 위한 프로파일링
프로파일링을 사용하면 어디에서 cpu를 사용하는지 gpu를 사용하는지 얼만큼 사용하는지 알 수 있다.
도커 실행
docker run --gpus all --name <container name> -it -p 8888:8888 -v </path:/path> <image name> /bin/bash
--gpus all : 컨테이너 gpu 사용
--name : 컨테이너 이름 설정
-p : 접속 포트 설정
-v : 폴더 마운트 설정
--shm-size=8G : 컨테이너 메모리 사용량 설정
도커 컨테이너 접속
docker attach <container name>
컨테이너 종료하지 않고 나가기
ctrl + P + Q
컨테이너 종료 후 나가기
ctrl + D
컨테이너 IPAddress 확인
docker inspect CONTAINER_ID
도커 파일 및 폴더 복사
docker cp /path/foo.txt mycontainername:/path/foo.txt
[docker] 도커 commit, push, pull (0) | 2022.09.29 |
---|
실행중인 컨테이너 commit 하기
docker commit <컨테이너 이름> <이미지 이름>
저장된 이미지 확인
docker images
도커 cloud에 login 하기
docker login
도커 이미지에 태그 달기
docker tag <이미지 이름> <도커 로그인 아이디/이미지 이름>
태그가 적용되어 있는 이미지를 도커 cloud에 push 하기
docker push <도커 로그인 아이디/이미지 이름>
도커 hub에 들어가서 push된 이미지 확인
1. docker hub에 로그인이 되지 않을 경우
2. user name과 docker hub 에 로그인된 ID가 일치하지 않을 경우
docker info | grep Username
로그인되어 있지 않다면 아무것도 출력되지 않음 로그인되어 있다면 Username이 출력됨
- 로그인과 username 맞는 지 확인
로그인 되어 있지 않다면 다시 로그인 하고 username이 다르다면 로그아웃하고 다시 로그인해주자
docker logout
docker login
[docker] 도커 명령어 (0) | 2022.09.29 |
---|
환경 및 준비 : windows 10, tesseract 4.x, jTessBoxEditor, pytessract
pretrained model인 traineddata 는 크게 2종류가 있다.
tessdata_best/kor.traineddata : best model (약 12M)
tessdata_fast/kor.traineddata : integer model (약 1.6M)
https://github.com/tesseract-ocr
* pytesseract 설치 참고
https://wandukong.tistory.com/9
best model confidence 값이 약간 더 높지만 큰차이가 없다.
jTessBoxEditor로 추가 학습할 이미지와 box파일을 만들어 준다.
바탕체 10point로 진행해 보았다.
generate를 눌러서 파일을 생성해준다.
한글을 영어로 바꿔 준다.
kor.batang.exp0.box 파일과 kor.batang.exp0.tif 파일을 Tesseract-OCR 폴더로 복사한다.
.\tesseract kor.batang.exp0.tif kor.batang.exp0 -l kor --psm 6 lstm.train
cmd창에서 명령어를 실행하면 kor.batang.exp0.lstmf 파일이 생성된다.
.\combine_tessdata -e tessdata/kor.traineddata kor.lstm
위와 같이 4가지 파일이 있으면 학습 준비 완료
체크포인트가 저장될 model_output 폴더를 생성해준다.
.\lstmtraining --model_output .\model_output/output --continue_from kor.lstm --train_listfile text.training_file.txt --traineddata tessdata/kor.traineddata --debug_interval -1 --max_iterations 1000
--model_output : Base path of output model files/checkpoints.
--continue_from : Path to previous checkpoint from which to continue training or fine tune.
--train_listfile : Filename of a file listing training data files.
--traineddata : Path to the starter traineddata file that contains the unicharset, recoder and optional language model.
--debug_interval : If non-zero, show visual debugging every this many iterations.
--max_iterations : Stop training after this many iterations.
위 명령어를 통해 fine tune 학습을 진행 할 수 있다.
* Failed to load list of training filenames from text.training_file.txt 오류가 난다면
Tesseract-OCR 폴더내에 text.training_file.txt 파일을 생성해주고
아래와 같이 kor.batang.exp0.lstmf 파일명을 적어주고 저장한다.
* Compute CTC targets failed for kor.batang.exp0.lstmf! 오류가 난다면
jTessBoxEditor 에서 data 생성할때 글자수를 좀 줄여서 다시 만든다.
위와 같이 글자수를 줄여 학습에 성공했다.
*22-09-23 수정
이상하게 jTessBoxEditor로 box file을 만들면 잘안되는경우가 많았다.
Wordstr로 했을때 성공률이 더 높았음으로 wordstr로 box file 만드는 것을 추천한다.
tesseract kor.batang.exp0.tif kor.batang.exp0 -l kor --psm 6 wordstrbox
만들어진 box file을 열어서 확인 해보고 틀린 한글이 있으면 수정한 후에 lstmf 파일을 만들어 준다.
model_output 폴더에 저장된 checkpoint들
.\lstmtraining --stop_training --continue_from .\model_output/output_17.051000_547_1000.checkpoint --traineddata tessdata/kor.traineddata --model_output .\model_output/new_kor.traineddata
--continue_from 에 변환할 체크포인트 파일명을 넣고
--model_output 에 생성될 traineddata 파일명을 넣어준다 여기서는 new_kor.traineddata 를 사용했다.
약 12M 의 finetuning 된 traineddata가 생성 되었다.
이 파일을 Tesseract-OCR/tessdata 폴더로 이동하여 TEST를 해보자
인식은 잘 되나 conf값이 하락하였다.
체크포인트 파일명 output 뒤에오는 숫자가 loss값인데 아직 학습이 덜 되어서 정확도가 낮다.
이어서 training을 시켜주자.
.\lstmtraining --model_output .\model_output/output --continue_from .\model_output/output_17.051000_547_1000.checkpoint --train_listfile text.training_file.txt --traineddata tessdata/kor.traineddata --debug_interval -1 --max_iterations 5000
--continue_from 에 이어서 학습할 체크포인트 파일명을 넣어 준다.
--max_iterations 에 기존보다 더 큰 숫자를 넣어 준다.
0.006 까지 내려갔다. traineddata로 변환하자
.\lstmtraining --stop_training --continue_from .\model_output/output_0.006000_547_1600.checkpoint --traineddata tessdata/kor.traineddata --model_output .\model_output/new_kor2.traineddata
integer 형으로도 변환
.\lstmtraining --stop_training --continue_from .\model_output/output_0.006000_547_1600.checkpoint --traineddata tessdata/kor.traineddata --model_output .\model_output/new_kor2_int.traineddata --convert_to_int True
뒤에 --convert_to_int True 를 붙여준다
12M -> 2.1M 로 용량이 줄었다.
conf 값이 더 떨어졌다...
integer model에선 더 좋게 나왔다.
tesseract 한글 모델 fine tuning하고 TEST하는 방법을 알아보았다.
결과적으로 성능이 떨어졌지만 이후 여러 다른 방법으로 시도해본결과 소폭 상승하기도 하였다.
기타 삽질
jTessboxEditor를 사용하여 추가학습 data를 만들때 같은 글자만 사용하는 것 보단 다양한 글자를 사용할때 좋았다.
LSTM training을 할때 항상 마지막 체크포인트가 최고 성능을 내지는 않았다.
폰트 크기에 따라서 confidence 값 차이가 있었다.
여러개 폰트를 추가해서 fine tune 해봤을때 성능이 좋아지는 경우도 있었지만 안좋아지는 경우도 많았다.
성능을 끌어 올리려면 다양한 조합으로 많은 시도를 해봐야 할 것 같다.
tesseract-OCR windows LSTM finetuning 학습 (0) | 2022.09.16 |
---|---|
[스크랩] 인공지능, 목적을 이루려 스스로 언어 개발... 사람은 이해 못해 (1) | 2017.06.27 |
환경 : windows 10, tesseract 4.x
Tesseract-OCR 폴더에 위 두파일을 복사
.\tesseract eng.arial.exp0.tif eng.arial.exp0 -l eng --psm 6 lstm.train
.\combine_tessdata -e tessdata/eng.traineddata eng.lstm
.\lstmtraining --model_output .\model_output/output --continue_from eng.lstm --train_listfile text.training_file.txt --traineddata tessdata/eng.traineddata --debug_interval -1 --max_iterations 400
--traineddata : Path to the starter traineddata file that contains the unicharset, recoder and optional language model.
--model_output : Base path of output model files/checkpoints.
--continue_from : Path to previous checkpoint from which to continue training or fine tune.
--train_listfile : Filename of a file listing training data files.
--debug_interval : If non-zero, show visual debugging every this many iterations.
--max_iterations : Stop training after this many iterations.
- model_output 폴더
* Compute CTC targets failed for eng.arial.exp0.lstmf! 에러가 나면 jTessBoxEditor로 .tif만들때 글자수를 줄여보자
너무 길거나 많으면 error가 나는듯 하다.
.\lstmtraining --model_output .\model_output/output --continue_from .\model_output/output_0.361000_12_400.checkpoint --train_listfile text.training_file.txt --traineddata tessdata/eng.traineddata --debug_interval -1 --max_iterations 1000
--continue_from : 이어서 학습시작할 checkpoint 파일 경로
--max_iterations : 이전보다 더 늘려준다
.\lstmtraining --stop_training --continue_from .\model_output/output_0.361000_12_400.checkpoint --traineddata tessdata/eng.traineddata --model_output .\model_output/new_eng.traineddata
.\lstmtraining --stop_training --continue_from .\model_output/output_0.361000_12_400.checkpoint --traineddata tessdata/eng.traineddata --model_output .\model_output/new_eng.traineddata --convert_to_int True
명령어 뒤에 --convert_to_int True 를 추가한다.
15M -> 5M로 줄어든 모습
참고
https://tesseract-ocr.github.io/tessdoc/tess4/TrainingTesseract-4.00.html
Tesseract 한글 fine tune 학습하기 (0) | 2022.09.20 |
---|---|
[스크랩] 인공지능, 목적을 이루려 스스로 언어 개발... 사람은 이해 못해 (1) | 2017.06.27 |
전국대학교 학식메뉴를 api로 제공하는 밥대생의 api를 사용하려고 하는데 자꾸 오류가 난다...
구글링을 해봐도 같은 오류가 나거나 나랑은 상관이 없는... postman이나 Rstudio를 통해 요청했을때는 응답이 잘오는데
문제가 뭘까... ㅜ 어렵다 node.js
1) 코드
2) 오류 메세지
---------------------------------------------------------------------------------------------------------------------------------------------------------------
getaddrinfo ENOTFOUND 는 도메인을 못 찾는 에러다.
해결 -> host 에 bds.bablabs.com 만 적고 나머지를 path로 옴겨서 실행
이제 err: connect ETIMEDOUT 52.78.147.197:8000 라는 오류가 떳다 이건 또 뭐지...ㅜ
---------------------------------------------------------------------------------------------------------------------------------------------------------------
connect ETIMEDOUT 은 해당 주소로 연결 조차 안된다는 오류이다.
원인은 여러가지일 수 있다 내 서버에서 해당 서로 가는게 막혔거나(흔치 않음)
목적지 서버의 도메인이나 포트를 잘못 적었거나, 목적지 서버에서 방화벽에서 걸렸거나 등등
해결 -> port : null; 로 바꿈으로써 해결 됐다.
이제 응답 내용이 잘 오지만 한글 인코딩 문제가..... ㅠㅠ
빅데이터 분석에 필요한 기초 수학을 익히기 위해 책을 샀다.
아이패드로 읽으러고 리디북스에서 E-book으로 구입!
통계를 위한 기초 수학 지식을 쌓기 위해 KOCW에서 선형대수 강의를 듣기로 하였다.
<선형대수> 유경렬 한양대학교
15차수에 걸쳐서 있으니 하루에 1회차씩 들어서 방학동안 잘 듣고 이해하도록 해야겟다.
빅데이터 취업관련 필요 직무역량 (0) | 2017.07.03 |
---|
접속이 잘되던 서버가 접속이 안된다..........ㅠㅠ
Amazon EC2 forum에 질문 올렸으니 기다려 봐야지
어렵다 AWS....