분류 전체보기

torch.text를 사용할 때 생긴 에러 - Solution 기존 rnn.pack_padded_sequence()의 인자로 주던 CUDA vector(text_lengths in below code)를 cpu()형태로 변환 packed_embedded = nn.utils.rnn.pack_padded_sequence(embedded, text_lengths.cpu()) https://github.com/bentrevett/pytorch-sentiment-analysis/issues/93 Got error" 'lengths' argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor " · Issue #93 · bentrevett/pyt..
대다수 Pytorch, Cuda 간 버전 차로 인한 문제 nvcc -V, nvidia-smi 등으로 CUDA 버전을 확인 한 후, 알맞은 Pytorch를 설치한다. 아래처럼 간단하게 python 테스트했을 때, True가 리턴되어야 함 >>> import torch >>> print(torch.cuda.is_available()) True 설치 방법은 아래 command 참조(Version은 다음 링크 참고) ==> https://download.pytorch.org/whl/torch_stable.html https://download.pytorch.org/whl/torch_stable.html download.pytorch.org pip install torch==1.7.1+cu110 torchvisi..
Error 1 Pytorch 코드를 돌리는 도중에 자꾸 다음과 같은 에러가 발생한다. ERROR: Unexpected bus error encountered in worker. This might be caused by insufficient shared memory (shm). 해결법을 찾아보니깐 Docker Container를 사용할 때, 컨테이너 안에서 코드를 돌리니 메모리 관련 크기가 작다며, 다음 option("--ipc=host")을 주어서, 컨테이너를 다시 실행시키면 해결된다고 한다. docker run --gpus all -it -p 8888:8888 -p 6006:6006 --ipc=host 하지만, 나같은 경우엔 서버가 회사 Docker기도 하고, 함부로 옵션을 건드려서 현재 컨테이너를..
정규표현식 예제 def is_time(input): dateRegex = re.compile(r"\d{2}:\d{2}:\d{2}|\d{2}:\d{2}")# XX:XX/ XX:XX:XX 타입 if dateRegex.fullmatch(input): result = True else: result = False return result def is_key(input): if input.count(":")==1: dateRegex = re.compile(r"(^.*.\:$)")# ":"로 끝나는 경우 if dateRegex.fullmatch(input): result = True else: result = False else: result = False return result def is_value(input..
Sequence based approach LayoutLM, LAMBERT와 같이 2D positional embedding을 input token에 추가한 BERT기반 모델 접근법 단점) 데이터셋 의존도가 높고, 컴퓨팅 파워도 요구함 Graph based approach BERTGrid, Chargrid, 각 문서를 Graph화 하고, 텍스트나 텍스트라인을 노드화, 관련 RoI visual 정보나 positional 정보까지 노드화 하여 그래프를 구성할 수 있고, GCN이나 attention network을 통해 각 이웃 노드간의 관계를 학습할 수 있음 단점) sequence based approach보다 성능이 다소 떨어짐 BERT와 같은 강력한 token embedding이 불가능함 (BERTGri..
LayoutLMv3 to pre-train multimodal Transformers for Document AI with unified text and image masking LayoutLMv3 is pre-trained with a word-patch alignment objective to learn cross-modal alignment by predicting whether the corresponding image patch of a text word is masked. Contribution LayoutLMv3 : first multimodal model that doesn’t rely on a pre-trained CNN or Faster R-CNN backbone → save param..
import os import numpy as np from IPython.display import Image def get_files(path): files = os.listdir(path) img_path =[] gt_path = [] for file in files: if file.split(".")[-1] in ["jpg"]: img_path.append(path+"/"+file) gt_path.append(path+"/"+file.split(".")[0]+".txt") return img_path , gt_path def is_on_same_line(box_a, box_b, min_y_overlap_ratio=0.8): """Check if two boxes are on the same lin..
reverse_dict= dict(map(reversed,pratice_dict.items()))
huggingface처럼 큰 모델이 올라가는 경우, git lfs로 대용량 파일을 올리고, 다운받을 수 있다. 나는 Ubuntu 를 사용중이며, 내가 구성한 anaconda 환경에서 git lfs를 설치하고 huggingface로부터 대용량 파일을 받아보자. Install curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash sudo apt install git-lfs Download #내가 다운받고자 하는 폴더 안에서 $ git lfs install git clone [huggingface주소] ex) git clone https://huggingface.co/microsoft/layout..
보통 nvidia-smi로 GPU 사용량을 체크하는데, 그 외에 현재 떠있는 메모리나 프로세스 전반의 사용량을 확인하고 싶을 때는 htop 명령어를 사용하면 된다.
VSCODE로 파일을 관리할 때, 파일의 생성 시간, 수정시간을 확인하고 싶은데 관련된 확장 프로그램을 찾으니 아래 결과가 나왔다. 윈도우처럼 디렉토리 탐색기 사이드에 생성 시간이 표시되면 좋겠지만 그런 방식은 아직 못찾음. 현재로는 아래와 같이 파일 속성을 확인하는 정도로 파일 크기, 생성 날짜, 수정된 날짜 등을 확인할 수 있다. 설치방법 확장 프로그램 설치 다음 톱니바퀴에서 확장 탭을 누르거나 ctrl+shift+x를 누르면 아래와 같은 화면이 뜬다. 여기다가 file properties viewer를 검색하면 다음 프로그램이 나오는데, 이를 설치해주면 된다. 이를 설치해주고 난 후, 원하는 파일을 우클릭하여 아래와 같이 View file properties로 파일속성을 확인할 수 있다.
Json포맷으로 된 bbox 값이 중구난방으로 나열된 경우, 내가 원하는 순서대로 정렬하기 위한 코드 TL(Top Left) -> TR(Top Right) -> BR(Bottom Right) -> BL(Bottom Left) 순서 def coord_adjust(coord): """ coord : np.array [[xA,yA], [xB,yB], [xC,yC], [xD,yD]] """ distance = [] for idx, c in enumerate(coord): x = c[0] y = c[1] zero_distance = x+y distance.append([idx,zero_distance]) distance = sorted(distance, key=itemgetter(1)) left_top = coo..
https://docs.luxonis.com/en/latest/pages/tutorials/creating-custom-nn-models/#kornia Run your own CV functions on-device — DepthAI documentation | Luxonis When exporting the model to onnx, PyTorch isn’t very efficient. It creates tons unnecessary operations/layers which increases the size of your network (which can lead to lower FPS). That’s why we recommend using onnx-simplifier, a simple pytho..
이미지 내 특정 색을 다른 색으로 변경하고 싶을 때 출처 : https://stackoverflow.com/questions/62648862/how-can-i-change-the-hue-of-a-certain-area-with-opencv-python How can I change the hue of a certain area with OpenCV-Python i want to edit the hsv value of a certain area The picture I want to change color of I to change all the purple parts of the image to green. Here is the result I made in an image editing software..
Js.Y
'분류 전체보기' 카테고리의 글 목록 (9 Page)