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

image resize #16

Open
longw010 opened this issue Aug 22, 2020 · 6 comments
Open

image resize #16

longw010 opened this issue Aug 22, 2020 · 6 comments

Comments

@longw010
Copy link

Hey,

Thanks for the great work and releasing the code. I was wondering how to set the ratio(76/64) at the resize part here https://github.com/Yuheng-Li/MixNMatch/blob/21095b3581c7d47f67ed1bb360ca8ac3db6c299f/code/datasets.py#L57 ,

To extend the work to other image size for training, which resize ratio would be recommended?

Thanks!

@liuhao-lh
Copy link

Hey,

Thanks for the great work and releasing the code. I was wondering how to set the ratio(76/64) at the resize part here

https://github.com/Yuheng-Li/MixNMatch/blob/21095b3581c7d47f67ed1bb360ca8ac3db6c299f/code/datasets.py#L57

,
To extend the work to other image size for training, which resize ratio would be recommended?

Thanks!

May I ask whether you have solved this question? I also wonder why. Thanks!

@Yuheng-Li
Copy link
Collaborator

Hi,

The code is based upon FineGAN ( https://github.com/kkanshul/finegan ) , and this ratio is used there.
I did not try the other resolutions, but I recommend use the same ratio for the other resolution training.

@liuhao-lh
Copy link

Hi,

The code is based upon FineGAN ( https://github.com/kkanshul/finegan ) , and this ratio is used there.
I did not try the other resolutions, but I recommend use the same ratio for the other resolution training.

Thanks! Got it.

@loucif01
Copy link

@Yuheng-Li , @liuhao-lh do we have to use images with same resolution as those used in your dataset? because i still have error which i think related to image size, can you take a look at this error please:

Traceback (most recent call last):
File "train_first_stage.py", line 418, in
trainer = Trainer(output_dir)
File "train_first_stage.py", line 141, in init
self.fixed_image = self.prepare_data( next(iter(self.dataloader)) )[1]
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 521, in next
data = self._next_data()
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 561, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/content/MixNMatch/code/datasets.py", line 188, in getitem
return self.iterator(index)
File "/content/MixNMatch/code/datasets.py", line 163, in prepair_training_pairs
bbox, self.transform, normalize=self.norm)
File "/content/MixNMatch/code/datasets.py", line 44, in get_imgs
cimg = transform(cimg)
File "/usr/local/lib/python3.7/dist-packages/torchvision/transforms/transforms.py", line 60, in call
img = t(img)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/torchvision/transforms/transforms.py", line 297, in forward
return F.resize(img, self.size, self.interpolation, self.max_size, self.antialias)
File "/usr/local/lib/python3.7/dist-packages/torchvision/transforms/functional.py", line 401, in resize
return F_pil.resize(img, size=size, interpolation=pil_interpolation, max_size=max_size)
File "/usr/local/lib/python3.7/dist-packages/torchvision/transforms/functional_pil.py", line 222, in resize
new_short, new_long = size, int(size * long / short)
ZeroDivisionError: division by zero

@nahidalam
Copy link

nahidalam commented Apr 14, 2022

@loucif01 were you able to solve it. I am trying to train it on a custom dataset and my image of dimension 419 × 612. I am getting same exact error as yours.

@darwinOne
Copy link

darwinOne commented Jan 27, 2023

@Yuheng-Li , @liuhao-lh do we have to use images with same resolution as those used in your dataset? because i still have error which i think related to image size, can you take a look at this error please:

Traceback (most recent call last): File "train_first_stage.py", line 418, in trainer = Trainer(output_dir) File "train_first_stage.py", line 141, in init self.fixed_image = self.prepare_data( next(iter(self.dataloader)) )[1] File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 521, in next data = self._next_data() File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 561, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/content/MixNMatch/code/datasets.py", line 188, in getitem return self.iterator(index) File "/content/MixNMatch/code/datasets.py", line 163, in prepair_training_pairs bbox, self.transform, normalize=self.norm) File "/content/MixNMatch/code/datasets.py", line 44, in get_imgs cimg = transform(cimg) File "/usr/local/lib/python3.7/dist-packages/torchvision/transforms/transforms.py", line 60, in call img = t(img) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, **kwargs) File "/usr/local/lib/python3.7/dist-packages/torchvision/transforms/transforms.py", line 297, in forward return F.resize(img, self.size, self.interpolation, self.max_size, self.antialias) File "/usr/local/lib/python3.7/dist-packages/torchvision/transforms/functional.py", line 401, in resize return F_pil.resize(img, size=size, interpolation=pil_interpolation, max_size=max_size) File "/usr/local/lib/python3.7/dist-packages/torchvision/transforms/functional_pil.py", line 222, in resize new_short, new_long = size, int(size * long / short) ZeroDivisionError: division by zero

@loucif01 I also had this problem (ZeroDivisionError: division by zero), I resolved it by changing the bbox value and it worked for 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

6 participants