본문 바로가기

전체 글70

[pillow] 이미지 read했을 때 rotation 현상 pillow image read시 rotate현상 problem 예전에 opencv-python을 사용하여면서 IMREAD_UNCHANGED flag로 사용했을 때 image가 rotation되는 현상이 발생했었다. https://shuka.tistory.com/23 [OpenCV] imread IMREAD_UNCHANGED flag 사용시 image rotation opencv imread에서 rotation된 이미지 원래대로 저장하는 방법 opencv에서 imread를 사용하는데 이미지에서 몇몇 장이 갑자기 rotate된 상태가 됐다. img = cv2.imread('test.jpg', cv2.IMREAD_UNCHANGED) cv2.imwrite('result.jpg shuka.tistory.com .. 2023. 11. 30.
python package를 requirements 텍스트로 저장 python package를 requirements 텍스트로 저장하는 방법 프로젝트 작업을 하다 보면 가상 환경을 새로 만들거나 다른 PC로 프로젝트를 옮겨야 할 경우가 발생하기도 하고, 갑자기 필요한 python library가 생겨서 설치를 하면서 requirements.txt에 작성하는 것을 깜빡할 때도 있다. Docker를 사용한다면 해당 container를 image로 만들고 tar파일로 만들어서 python library를 신경쓸 필요가 없는데 아닐 경우 약간 귀찮고 복잡해질 수도 있다. 방법1. pip freeze pip freeze는 현재 환경에서 설치된 python library와 version에 대해 밑의 사진과 같이 출력되는 것을 볼 수 있다. pip freeze 출력된 부분을 복사해.. 2023. 11. 22.
onnxruntime-gpu: Failed to create CUDAExecutionProvider onnxruntime-gpu: Failed to create CUDAExecutionProvider 경고 onnxruntime-gpu를 설치하고 onnx 모델을 테스트 하는데 다음과 같이 'Failed to create CUDAExecutionProvider'했다는 경고가 뜨면서 cpu로 model이 inference되는 상황이 발생했다. [W:onnxruntime:Default, onnxruntime_pybind_state.cc:566 CreateExecutionProviderInstance] Failed to create CUDAExecutionProvider. Please reference https://onnxruntime.ai/docs/reference/execution-providers/ CU.. 2023. 5. 11.
deepspeed를 이용하여 pytorch 모델 학습 방법 Deepspeed란? Deepspeed는 모델을 training/inference 속도를 빠르고 효율적으로 할 수 있도록 도와주는 Microsoft에서 만든 딥러닝 최적화 라이브러리이다. 밑의 링크는 deepspeed에 대한 github 주소이다. https://github.com/microsoft/DeepSpeed GitHub - microsoft/DeepSpeed: DeepSpeed is a deep learning optimization library that makes distributed training and inference ea DeepSpeed is a deep learning optimization library that makes distributed training and infer.. 2023. 4. 27.
How to imshow() webcam using opencv python in docker imshow()를 위한 docker container 실행 docker 안에서 opencv-python과 webcam을 연결해서 cv2.imshow()를 하려면 container를 생성할 때 몇몇 option을 추가해 줘야 한다. 만약 option 없이 docker container 내부에서 imshow()를 할 경우 다음과 같은 에러가 발생한다. 'getStreadmChannelGroup Camera index out of range' # docker container를 만들기 전에 'xhost +'를 terminal에 친다. xhost + # 필수 option -v /tmp/.X11-unix/:/tmp/.X11-unix --env QT_X11_NO_MITSHM=1 --device=/dev/video0.. 2023. 4. 19.
artially initialized module 'cv2' has no attribute '_registerMatType’ 'cv2' has no attribute '_registerMatType’ 오류 발생 opencv-python-headless를 설치하고 다음과 같은 오류가 발생할 수 있다. artially initialized module 'cv2' has no attribute '_registerMatType’ 해결 방법 내가 해결한 방법의 경우는 opencv-python과 opencv-python-headless의 버전을 맞춰주니까 해결이 됐다. opencv-python-headless의 버전을 opencv-python 버전에 맞춰서 다시 설치해주면 된다. 2023. 4. 19.
bash file returns unexpected token `$'do\r' bash file returns unexpected token `$'do\r' 오류 발생 ubuntu에서 shell파일을 실행하려고 하는데 `$'do\r'뿐만 아니라 다른 명령어들 뒤에도 \r이 붙으면서 계속 다음과 같이 오류가 발생했다. bash file returns unexpected token `$'do\r' 해결 방법 vim {shell file} :set ff=unix :wq 2023. 4. 19.
libSM.so.6: cannot open shared object file libSM.so.6: cannot open shared object file 오류 docker에서 opencv-python을 설치하면 libgl.so.2와 libgthread-2.0에 대한 오류는 자주 발생발생했었는데 그다음과 같이 처음 보는 오류가 발생했다. libSM.so.6: cannot open shared object file: No such file or directory 해결 방법 위의 오류를 해결하기 위해서는 다음과 같이 설치를 해주면 된다. apt-get install -y libsm6 libxext6 libxrender-dev 2023. 4. 19.
python yaml file load시 error 발생 python code에서 yaml파일을 load했을 경우 에러 발생 yaml파일을 작성하고 python code로 다음과 같이 load하려고 했다. import yaml with open('train.yaml') as f: yml = yaml.load(f) 그런데 다음과 같은 오류가 발생했다. TypeError: load() missing 1 required positional argument: 'Loader’ yaml.load()시 TypeError 해결 방법 오류 원인은 PyYAML 버전의 문제였다. pip list를 치면 현재 install되어 있는 library list들을 볼 수 있는데 PyYAML version이 6.0으로 기존의 쓰던 version보다 높아지면서 발생한 오류였다. 해결 방법1.. 2023. 2. 22.
Ubuntu terminal을 이용한 파일과 폴더 개수 세기 File의 개수와 Folder의 개수를 세기 위한 명령어 Ubuntu에서 파일 갯수를 확인하는데 한 폴더 안에 있으면 그냥 폴더 정보만 보고 내부의 파일 개수가 몇 개인지 확인할 수 있다. 문제는 폴더의 폴더안에 파일이 있다던지 더 안쪽에 있다던지 아니면 특정 확장자에 대해서만 파일의 개수를 알고 싶으면 폴더 정보만 봐서는 알 수 없다. 그렇다고 항상 필요할 때마다 검색해서 찾아보기도 귀찮아서 정리해봤다. 현재 위치에서 folder 개수 ls -l | grep ^d | wc -l 현재 위치에서 file의 개수 ls -l | grep ^- | wc -l 현재 folder의 하위 folder 개수 find . -type f | wc -l 원하는 folder 위치에서 하위에 있는 특정 file 개수 find .. 2023. 2. 20.
Could not load the Qt platform plugin xcb Could not load the Qt platform plugin ‘xcb’ 오류 발생 python version의 opencv를 사용하기 위해 다음과 같이 패키지를 설치하였다. pip install opencv-python pip install opencv-contrib-python 그런데 다음과 같은 에러가 발생했다. ‘Avalable platform plugins are: xcb, egifs, glfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl.’ plugin ‘xcb’오류 해결 방법 해당 오류에서는 opencv-pytho.. 2023. 2. 10.
timm library로 인한 RuntimeError 발생 RuntimeError 발생 제대로 실행되는 code를 가지고 새롭게 test진행을 하려고 anaconda의 새로운 가상 환경을 만들었다. code를 돌리기 위해 필요한 library들을 설치하고 test를 진행했는데 갑자기 아래와 같이 error가 발생하는 것이다. error message: RuntimeError: Given normalized_shape=[1024], expected input with shape [*, 1024], but got input of size[1] 해결 방법 위의 error을 해결하기 위해 anaconda의 가상 환경도 다시 만들어 보고 pytorch verion과 torchvision version도 여러 번 바꿔가기도 해봤는데 원인은 전혀 다른 library에 대한 .. 2023. 2. 10.
728x90