파이썬 멀티 스레딩과 멀티 프로세싱 파이썬 멀티 스레딩 print(f"{os.getpid()} process | {threading.get_ident()} url : {url}") os.getpid() ⇒ 현재 프로세스 아이디 리턴 → 프로세스는 각각의 아이디가 존재 == pid(하나의 프로그램) 코루틴을 사용하지 않은 일반 코드 → 싱글 스레드에서 동작 코루틴을 사용한 코드(비동기적 동작) 시간 초 차이!!! 코루틴을 사용한 코드가 같은 상황에서 훨씬 효율이 좋다! aiohttp에서 제공하는 코루틴 function 자체가 없다면 어떻게 동시성 처리를 할 것인가? 만약 동기적으로 코드를 작성하고, 동시성 프로그래밍을 하려면 어떻게 해야할 것인가?? ⇒ 멀티 스레딩 사용!! 파이썬 멀티 스레딩 파이썬 멀티..
파이썬 코루틴과 비동기 함수(운영체제 개념과 코루틴) I/O 바운드 & CPU 바운드, 블로킹 CPU 바운드 프로그램이 실행될 때, 실행 속도가 CPU 속도에 의해 제한됨을 의미 정말 복잡한 수학 수식을 계산하는 경우, 컴퓨터의 실행속도가 느려진다. 예시 : CPU가 과한 연산을 막는다! def cpu_bound_func(number: int): total = 1 arrange = range(1, number+1) for i in arrange: for j in arrange: for k in arrange: total *= i*j*k if __name__ == "__main__": result = cpu_bound_func(100) print(result) ⇒ 10은 연산이 되지만, 100은 연산이 되..
파이썬 판다스로 엑셀 만들기 !pip install xlwt !pip install openpyxl import pandas as pd import openpyxl # print(create_csv_data) df = pd.DataFrame(annotation_cnt, columns=['파일명','바운딩박스','키포인트','잘림','가림','보임']) display(pd.DataFrame(df)) df.to_excel('/content/annotation_cnt_re.xlsx',sheet_name = 'count_list') 이렇게 변환된당 annotation_cnt는 엑셀로 만들어줄 리스트 인데, annotation_cnt = [[줄하나],[줄 둘]~~~] 이런식으로 append 해주어서 df에 넣으면..
PILLOW 라이브러리 공식 홈페이지 https://pillow.readthedocs.io/en/stable/ Pillow Pillow is the friendly PIL fork by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lundh and Contributors. Pillow for enterprise is available via the Tidelift Subscription... pillow.readthedocs.io CV 데이터를 이용해 바운딩, 폴리곤, 키포인트 이미지 위에 라벨링 값 나타내는 방법 바운딩 박스 그리기 import json from PIL import Image, ImageDraw im..