일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- pandas
- 핑거스타일
- Numpy
- error
- Docker
- VS Code
- nvidia-smi
- pytorch
- windows forms
- JSON
- SSH
- 오류
- Selenium
- Linux
- C++
- YOLO
- 컨테이너
- label
- 기타 연주
- 채보
- paramiko
- Visual Studio
- C#
- 프로그래머스
- mysql
- C
- pip
- Python
- ubuntu
- OpenCV
- Today
- Total
목록Python (117)
기계는 거짓말하지 않는다
Python의 paramiko 모듈을 이용하여 원격 서버에 SSH 접속 후,passwd와 같이 명령어를 여러 번 주고받아야 할 경우에 간단하게 사용할 수 있는 방법이다.import paramikoimport timedef instance_change_password(function_args: dict): ''' args server_ip, user_name, server_password, new_password ''' client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(function_args['server_ip'],..
Creating a tensor from a list of numpy.ndarrays is extremely slow.Please consider converting the list to a single numpy.ndarray with numpy.array()before converting to a tensor.PyTorch에서 List에 다수의 numpy.ndarray가 있을 경우 torch.tensor로 변환하는 경우 발생한다.이렇게 하면 성능이 저하될 수 있고, List를 단일 numpy.ndarray로 변환 후 tensor로 다시 변환하여야 한다.import numpy as npimport torchdef convert_to_tensor(list_of_arrays): # 리스트를 numpy..
Python logging 모듈의 logger를 설정하는 간단한 예제 함수 코드이다.경로와 loglevel은 필요에 따라 수정하면 된다.import loggingimport datetimeimport osdef setup_logger(log_file_name = "proccess.log", log_name = "logger", log_dir_root_path = "./logs"): current_date = datetime.datetime.now().strftime("%Y%m%d") log_dir = f"{log_dir_root_path}/{current_date}" os.makedirs(log_dir, exist_ok=True) # log file path setting ..
Python torch 프레임워크 실행 시 다음과 같은 오류가 발생한 경우Could not load library libcudnn_cnn_train.so.8. Error: /usr/local/cuda-12.2/lib64/libcudnn_cnn_train.so.8: undefined symbol: _ZN5cudnn3cnn34layerNormFwd_execute_internal_implERKNS_7backend11VariantPackEP11CUstream_stRNS0_18LayerNormFwdParamsERKNS1_20NormForwardOperationEmb, version libcudnn_cnn_infer.so.8Traceback (most recent call last): File "/python_p..
아래 예시는 실제 프레임 수가 15개 이하인 MP4 파일을 삭제한다.opencv-python 라이브러리가 필요하며, 각 비디오 파일의 총 프레임 수를 확인하여 삭제한다.import osimport globimport cv2import timeimport datetime# 디렉터리 경로 변경 필요directory = '/path/directory'count = 0delete_count = 0start_time = time.time()mp4_files = glob.glob(os.path.join(directory, '*.mp4'))for file in mp4_files: try: count += 1 # 비디오 파일 읽기 video = cv2.VideoCapture(..
YOLO 텍스트로 된 라벨 bbox를 이용하여 object들을 crop 하여 이미지로 저장하는 코드이다.확장자나 경로는 사용자에 맞게 바꿔야 한다.이미지, 라벨 이름의 짝과 개수가 맞는지는 코드 실행 전 검사하여야 한다.import cv2import osimport globdef get_x_y_points(point1_x, point1_y, point2_x, point2_y): xmin, ymin, xmax, ymax = 0, 0, 0, 0 if point1_x point2_x and point1_y point2_y: xmin = point1_x ymin = point2_y xmax = point2_x ymax = point1_y ..
Python에서 하위 디렉터리들의 깊이를 알 수 없으며 각각 다른 깊이를 가지고 있고,파일 경로들을 디렉터리 별로 묶고 싶을 경우 간단하게 사용할 수 있는 방법이다.import osdef find_files_by_directory(directory, extensions): files_by_directory = {} # dictionary에 저장 for root, dirs, files in os.walk(directory): matched_files = [os.path.join(root, file) for file in files if file.endswith(extensions)] if matched_files: files_by_directory[r..