Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading images error #3

Open
zhangyumo95 opened this issue Jul 13, 2021 · 4 comments
Open

Loading images error #3

zhangyumo95 opened this issue Jul 13, 2021 · 4 comments

Comments

@zhangyumo95
Copy link

Traceback (most recent call last):
File "run_training.py", line 263, in
workers=args.workers)
File "run_training.py", line 104, in run_training
batch_idx, data = next(dataloader_inf)
File "run_training.py", line 93, in get_data_inf
for out in enumerate(dataloader):
File "/home/ty/anaconda3/envs/mmdet211/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 435, in next
data = self._next_data()
File "/home/ty/anaconda3/envs/mmdet211/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1085, in _next_data
return self._process_data(data)
File "/home/ty/anaconda3/envs/mmdet211/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1111, in _process_data
data.reraise()
File "/home/ty/anaconda3/envs/mmdet211/lib/python3.7/site-packages/torch/_utils.py", line 428, in reraise
raise self.exc_type(msg)
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/ty/anaconda3/envs/mmdet211/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 198, in _worker_loop
data = fetcher.fetch(index)
File "/home/ty/anaconda3/envs/mmdet211/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/ty/anaconda3/envs/mmdet211/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/work/Anomaly_det/pytorch-cutpaste-master/dataset.py", line 43, in getitem
img = self.transform(img)
File "/home/ty/anaconda3/envs/mmdet211/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 67, in call
img = t(img)
File "/home/work/Anomaly_det/pytorch-cutpaste-master/cutpaste.py", line 143, in call
org, cutpaste_normal = self.normal(img)
File "/home/work/Anomaly_det/pytorch-cutpaste-master/cutpaste.py", line 68, in call
patch = self.colorJitter(patch)
File "/home/ty/anaconda3/envs/mmdet211/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/ty/anaconda3/envs/mmdet211/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 1115, in forward
img = F.adjust_hue(img, hue_factor)
File "/home/ty/anaconda3/envs/mmdet211/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 712, in adjust_hue
return F_pil.adjust_hue(img, hue_factor)
File "/home/ty/anaconda3/envs/mmdet211/lib/python3.7/site-packages/torchvision/transforms/functional_pil.py", line 197, in adjust_hue
np_h = np.array(h, dtype=np.uint8)
TypeError: array() takes 1 positional argument but 2 were given

@Runinho
Copy link
Owner

Runinho commented Jul 22, 2021

strange Error. I would check 2 things:

  1. Check if the dataloader can load the images:
from dataset import MVTecAT
from matplot.pyplot import plt

test_data= MVTecAT("Data", "metal_nut")

img = test_data[0]
plt.imshow(test_data[0])
  1. Check if ColorJitter is working on PIL Images as expected:
from torchvision import transforms

colorJitter = transforms.ColorJitter(brightness = 0.1,
                                                      contrast = 0.1,
                                                      saturation = 0.1,
                                                      hue = 0.1)

# load some PIL image into img (you can also just use the code from above)
color_jittered_img = colorJitter(img)
plt.imshow(color_jittered_img)

In both cases you should see an image plot. Let me know if this works

@mouxinyue1
Copy link

from dataset import MVTecAT
from matplot.pyplot import plt

test_data= MVTecAT("Data", "metal_nut")

img = test_data[0]
plt.imshow(test_data[0])

Has this problem been solved?I have the same problem

@Runinho
Copy link
Owner

Runinho commented Jul 9, 2022

TypeError: array() takes 1 positional argument but 2 were given

Maybe this issue is related to: pytorch/pytorch#61125 (comment)

@danielsoy
Copy link

size arg missing error:

test_data= MVTecAT("Data", "metal_nut",1)

worked 4 me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants