본문 바로가기

python

(27)
[flask] json 객체 등 javascript에서 flask, python으로 데이터 보내기 https://sncap.tistory.com/963
[socket 통신] python. int 혹은 float을 little endian 방식의 bytearray로 변환해 전송하기 struct라는 내장 모듈을 활용한다!! import sturct a = 34531 byte_a = struct.pack('
[error handling] python generator, fit_generator를 썼을 때 loss가 변하지 않고 학습이 되지 않을 때, 시계열 데이터 학습 실수 제너레이터 구현과 상관없이 시계열 데이터의 학습 방법을 잘 몰라서 발생한 실수였다. 윈도우 사이즈가 10인경우 t ~ t+10, t+1 ~ t+11, t+2 ~ t+12 ... 이런식으로 데이터가 구성되고 가령, t ~ t+10, t+2 ~ t+12, t+5 ~ t+15, ... t+1 ~ t+11, t+3 ~ t+13, t+4 ~ t+14, ... 이런식으로 구성된다. 그런데 내가 구성한 방식은... 이런 시계열 순서를 무시하고 train/test를 먼저 분리한 후 t~t+10, t+1~t+11 ... 은 train으로 t+20~t+30, t+21~t+31 ... 은 test로 해서 겹치는 데이터가 없어진다. 즉 1초대 부터 10초대까지의 데이터는 3초대부터 13초대까지의 데이터와 겹치게 마련이고 그게..
[error handling] 0xc10100be python write video, cv2 video write가 안될때 0xc10100be 에러가 뜨면서 저장한 비디오가 실행이 안된다. 저장도 거의 안 된다. 6KB, 1KB 이런 식이다. 이럴 경우 어떻게 해결해야하나? 문제 원인) 바보 같은 실수를 한 게 gframe을 저장하려고 했단 것이다. frame은 (640, 480, 3)의 형태고 gframe은 (640, 480)이다. 흑백의 채널이 없는 이미지는 out.write(gframe)이 안 먹는다. 해결책 그냥 3채널의 frame을 write하자. https://github.com/ContinuumIO/anaconda-issues/issues/223 opencv - not writing output with cv2.VideoWriter.write · Issue #223 · ContinuumIO/anaconda-iss..
python으로 폴더 지우기 (os, shutil) 파일을 지울 때는 os.remove를 사용하는데. 이걸 폴더에 사용하면 안 먹힌다. import os folder = '/temp/blar' os.remove(folder) 에러가 난다. 폴더는 어떤 방식으로 지울까?? 2가지 방법이 있다. 1. os.rmdir import os folder = '/temp/blar' os.rmdir(folder) 2. shutil.rmtree 1 번 방법이 안 통할 때가 있다. 폴더내에 또 파일들이 들어있을 경우다. 그럴 경우 이 방법을 쓴다. shutil.rmtree(folder, ignore_errors=True)
[flask] python 파일 업로드/다운로드 예제 flask Post 방식으로 이미지를 업로드/다운로드 할 수 있는 좋은 메뉴얼 github.com/neltia/flask-project neltia/flask-project flask web site. Contribute to neltia/flask-project development by creating an account on GitHub. github.com blog.naver.com/PostView.nhn?blogId=dsz08082&logNo=221868934940&parentCategoryNo=&categoryNo=134&viewDate=&isShowPopularPosts=false&from=postView [Python Flask] #10 파이썬 플라스크 파일 업로드 / 다운로드 #10 FT..
[pytorch] DistributedDataParallel vs DataParallel 차이 The difference between DistributedDataParallel and DataParallel is: DistributedDataParallel uses multiprocessing where a process is created for each GPU, while DataParallel uses multithreading. By using multiprocessing, each GPU has its dedicated process, this avoids the performance overhead caused by GIL of Python interpreter. If you use DistributedDataParallel, you could use torch.distributed...
[aws] mac os, linux에서 안전하게 jupyter 서버 접속하기 AWS를 이용할 때 AWS의 서버를 Remote 서버라 하고, Local 환경을 클라이언트 라고 하자. 1. 클라이언트에서 ssh로 Remote Sever에 접속한다! 2. Remote 서버에서 Jupyter 서버를 실행시켜 준다. 적당한 port로 (ex : 5000) 3. 그 후 클라이언트에서 새로운 터미널 창을 열고 ssh로 주피터 서버에 접속해준다. 이때 -i 다음에 오는 것은 private key 경로이고, -L 다음에 오는건 클라인트에서 접속할 port:Jupyter 서버 IP:Jupyter 서버 port 이다. 이후에 것은 1번에서 사용한 명령어와 유사하다. ssh -i ~/mykeypair.pem -N -f -L 8888:localhost:8888 ubuntu@ec2-###-##-##-##..

728x90