↓폴밍끼 유튜브 채널 자세히보기

AI/Deep Learning

IAT 에러 해결법

폴밍끼 2023. 3. 8. 20:24
728x90

어쩌구 저쩌구 ~~dataloader/lol.py 에러 어쩌구 저쩌구

lol.py 로 가보자

    def get_params(self, low):
        self.w, self.h = low.size
        print("#"*30,self.h)
        self.crop_height = random.randint(self.h/2, self.h) #random.randint(self.MinCropHeight, self.MaxCropHeight)
        self.crop_width = random.randint(self.w/2, self.w) #random.randint(self.MinCropWidth,self.MaxCropWidth)

self.h 출력해봄

######## Start IAT Training #########
the epoch is: 0
############################## 1626
############################## 1080
############################## 1080
############################## 1080
############################## 1626
############################## 1080
############################## 1624
############################## 1080
############################## 1626
############################## 1080
############################## 1080
############################## 1080
############################## 1080
############################## 1631
############################## 1620
############################## 1080
############################## 1080
############################## 1080
############################## 1623
Traceback (most recent call last):
  File "train_lol_v2.py", line 93, in <module>

잘 나옴

Original Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
    data = fetcher.fetch(index)
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/vblab_data/Illumination-Adaptive-Transformer/IAT_enhance/data_loaders/lol.py", line 79, in __getitem__
    data_lowlight, data_highlight = self.Random_Crop(data_lowlight, data_highlight)
  File "/vblab_data/Illumination-Adaptive-Transformer/IAT_enhance/data_loaders/lol.py", line 63, in Random_Crop
    self.i,self.j = self.get_params((low))
  File "/vblab_data/Illumination-Adaptive-Transformer/IAT_enhance/data_loaders/lol.py", line 54, in get_params
    self.crop_width = random.randint(self.w/2, self.w) #random.randint(self.MinCropWidth,self.MaxCropWidth)
  File "/opt/conda/lib/python3.8/random.py", line 248, in randint
    return self.randrange(a, b+1)
  File "/opt/conda/lib/python3.8/random.py", line 212, in randrange
    raise ValueError("non-integer arg 1 for randrange()")
ValueError: non-integer arg 1 for randrange()
    def get_params(self, low):
        self.w, self.h = low.size
        # print("#"*30,self.h)
        self.crop_height = random.randint(self.h/2, self.h) #random.randint(self.MinCropHeight, self.MaxCropHeight)
        self.crop_width = random.randint(self.w/2, self.w) #random.randint(self.MinCropWidth,self.MaxCropWidth)

self.h/2 , self.w/2 에서 non-integer였덨 것. 그래서 self.h//2 , self.w//2 로 바꿨으나 아래와 같은 에러 나옴.

RuntimeError: stack expects each tensor to be equal size, but got [3, 1080, 1606] at entry 0 and [3, 1080, 1620] at entry 1

결국 데이터셋 내의 이미지 사이즈가 다 달라서 생긴 문제여서 resize로 사이즈 다 맞춰줘야게씀