전체 글

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..
Js.Y
Y초보프로그래머