mmaaz60 / EdgeNeXt

[CADL'22, ECCVW] Official repository of paper titled "EdgeNeXt: Efficiently Amalgamated CNN-Transformer Architecture for Mobile Vision Applications".
MIT License
351 stars 40 forks source link

Can I learn with Gray Scale Image or other size Images? #11

Closed ajw1587 closed 1 year ago

ajw1587 commented 2 years ago

Hello. I did a model test and the performance is very good. I'd like to learn with a different data set. Can I learn Gray Scale Image or other sizes of Image (64x64x1)??

mmaaz60 commented 2 years ago

Hi @ajw1587,

Thank you for your interest in our work. Yes, our model can be used with gray scale images (input channels = 1), however for this you need to modify some of the network configurations. Specifically, in_chans=1 should be passed while creating the network in model.py. Also, you have to set the command line parameter --input_size to 64 in order to train at 64x64 resolution. By default the network trains at 256x256 resolution. I hope this will help.

ajw1587 commented 2 years ago

Thank you. Now I'm trying to learn by modifying various settings. However, an error occurs in the DataLoader part (the 140th line of utils.py) as shown below.

DataLoader part (the 140th line of utils.py)

for obj in iterable: ★ Error!

    data_time.update(time.time() - end)

    yield obj

    iter_time.update(time.time() - end)

    if i % print_freq == 0 or i == len(iterable) - 1:

        eta_seconds = iter_time.global_avg * (len(iterable) - i)

        eta_string = str(datetime.timedelta(seconds=int(eta_seconds)))

                        ⋮

Error Message TypeError: Caught TypeError in DataLoader worker process 0. Original Traceback (most recent call last): File "C:\Users\TEST\anaconda3\envs\edgenext\lib\site-packages\torch\utils\data\_utils\worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "C:\Users\TEST\anaconda3\envs\edgenext\lib\site-packages\torch\utils\data\_utils\fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "C:\Users\TEST\anaconda3\envs\edgenext\lib\site-packages\torch\utils\data\_utils\fetch.py", line 49, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "C:\Users\TEST\anaconda3\envs\edgenext\lib\site-packages\torchvision\datasets\folder.py", line 231, in __getitem__ path, target = self.samples[index] TypeError: list indices must be integers or slices, not tuple python-BaseException

mmaaz60 commented 2 years ago

Hi,

It looks like the dataset loading problem. Our EdgeNeXt is using PyTroch ImageFolder to load ImageNet dataset. Firstly, make sure that you data is in correct format (e.g. each class has a separate directory for images). Secondly, ImageFolder assumes that the images have 3 channels, so you have to modify it a little to work with gray scale images. The discussion might be helpful in this regard. Thirdly, you may have to modify some of the transformations used for gray scale images.

ajw1587 commented 2 years ago

Thank you for your answer. Could you tell me what kind of pre-processing techniques you used in the original code?

mmaaz60 commented 2 years ago

Hi @ajw1587,

Please refer to the Section 4.2 of our paper. Thanks

ajw1587 commented 2 years ago

Thank you! I've only read about the model structure, but I'll have to read it carefully.