글

Access jupyter notebook using docker

I searched for dev container, not runtime, but couldn't find it. This method uses some tricks - not using the notebook's default port, etc. 1. Run docker container docker run -it -p 8880:8880 --name jpt -v /home/hayoung/Desktop/:/data jupyter/datascience-notebook:latest 2. Check your container's id (Use another terminal, or stop the current container and check) docker ps -a 3. Get inside of the container docker exec -it {your container's id} /bin/bash 4. Run a new notebook jupyter notebook --no-browser --allow-root --port 8880 --ip=0.0.0.0 --NotebookApp.password={your notebook's password hash} --notebook-dir='/' (You can get your hash by running python and executing "from notebook.auth import passwd; passwd()" in the host machine)  ref: https://bio-info.tistory.com/12 https://manvscloud.com/?p=385

Updating git submodule

-  이미 추가된 submodule의 최신 commit으로 업데이트 할 경우 상위 깃: A submodule: B cd B # 현재 최신 커밋이 올라온 브랜치로 변경. 현재 브랜치는 submodule로 생성된 임시(?) 브랜치임 git checkout {branch_name} # 필요시 pull: git pull origin {branch_name} cd .. git add B git commit -m "{commit message}" git push origin {branch_name} submodule 안의 코드를 수정하고, my_branch에 커밋한 뒤 상위 깃에서 add 혹은 git submodule update을 수행해도 변경사항이 적용되지 않는 이유가 my_branch가 아닌 해시로 보이는 다른 브랜치가 생성되어 submodule이 그 브랜치를 추종하고 있기 때문이었음

Save matplotlib figure image

https://stackoverflow.com/questions/8218608/scipy-savefig-without-frames-axes-only-content   import matplotlib . pyplot as plt import cv2 from skimage import measure image = cv2 . imread ( "/data/temp/image.png" ) mask = cv2 . imread ( "/data/temp/mask.png" , - 1 ) * 255 contours = measure . find_contours ( mask , 200 ) fig = plt . figure ( frameon = False ) # fig.set_size_inches(w, h) ax = plt . Axes ( fig , [ 0 ., 0 ., 1 ., 1 .]) ax . set_axis_off () fig .add_axes( ax ) ax . imshow ( image , aspect = "auto" ) for contour in contours : ax . plot ( contour [:, 1 ], contour [:, 0 ], linewidth = 1 , label = "class 1" , color =) ax . legend () fig .savefig( "/data/temp/temp.png" , format = "png" )

Nvidia DALI

+ docker ERROR:  dlopen "libnvcuvid.so" failed! SOLUTION: docker run options: -it --name dali --gpus all -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=video,graphics,utility,compute 참고하면 좋을 코드들 https://www.juanmontesinos.com/posts/2020/07/21/audiovisual-dali https://github.com/NVIDIA/DALI/issues/1464 https://github.com/NVIDIA/DALI/issues/3133

tmux keyboard cursor 사라졌을 때 해결법

type   tput cnorm in terminal ref: https://superuser.com/questions/1547622/tmux-keyboard-cursor-disappears-after-leaving-scroll-mode

Image + bbox using matplotlib / cv2

이미지
import matplotlib.pyplot as plt from matplotlib import patches fig, ax = plt.subplots(1) ax.imshow(IMAGE) ax.add_patch(patches.Rectangle((LEFT_TOP_X_Y), WIDTH, HEIGHT, fill=False, edgecolor='blue') 출처: https://www.delftstack.com/ko/howto/matplotlib/how-to-draw-rectangle-on-image-in-matplotlib/ img = cv2 . rectangle ( img , ( 384 , 0 ), ( 510 , 128 ), ( 0 , 255 , 0 ), 3 ) 출처: https://opencv-python.readthedocs.io/en/latest/doc/03.drawShape/drawShape.html

matplotlib marker 추가/제거

fig = plt.Figure() ax = fig.add_subplot(111) ax.plot(list(range(10)), marker="o") ax.lines[0].set_marker(None) ax.lines[0].set_markevery([5, 7])