MixNMatch icon indicating copy to clipboard operation
MixNMatch copied to clipboard

image resize

Open longw010 opened this issue 3 years ago • 6 comments

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!

longw010 avatar Aug 22 '20 22:08 longw010

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!

liuhao-lh avatar Apr 27 '21 06:04 liuhao-lh

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.

Yuheng-Li avatar Apr 27 '21 18:04 Yuheng-Li

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.

liuhao-lh avatar Apr 30 '21 02:04 liuhao-lh

@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 avatar Oct 26 '21 14:10 loucif01

@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.

nahidalam avatar Apr 14 '22 02:04 nahidalam

@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.

darwinOne avatar Jan 27 '23 07:01 darwinOne