Getting error in Dataset loader

PPB: <p>I am trying to implement this following code on my system.</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://github.com/dvlab-research/Simple-SR">
  <header class="source">
      <img src="https://github.githubassets.com/favicons/favicon.svg" class="site-icon" width="32" height="32">

      <a href="https://github.com/dvlab-research/Simple-SR" target="_blank" rel="noopener nofollow ugc">GitHub</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/344;"><img src="https://opengraph.githubassets.com/8302f6c16d0c0274158840f198aaa534768d72ebc61e20ef5f9ac9676229395e/dvlab-research/Simple-SR" class="thumbnail" width="690" height="345"></div>

<h3><a href="https://github.com/dvlab-research/Simple-SR" target="_blank" rel="noopener nofollow ugc">GitHub - dvlab-research/Simple-SR: Include MuCAN, LAPAR, etc.</a></h3>

  <p>Include MuCAN, LAPAR, etc. Contribute to dvlab-research/Simple-SR development by creating an account on GitHub.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
<p>
In the original code, they used two datasets named “DIV2k” and “Flicker2K”  for training. But I want to use only the DIV2K dataset  for training. To do so, I have first divide the dataset images into sub-images and then change the <strong>init</strong>.py file accordingly:</p>
<pre><code class="lang-auto"> from easydict import EasyDict as edict
 import importlib
 import os
from utils.common import scandir
dataset_root = os.path.dirname(os.path.abspath(__file__))
print(dataset_root)
dataset_filenames = [
os.path.splitext(os.path.basename(v))[0] for v in scandir(dataset_root)
    if v.endswith('_dataset.py')
 ]
dataset_modules = [
       importlib.import_module(f'datasets.{file_name}')
       for file_name in dataset_filenames
]
class DATASET:
     LEGAL = ['DIV2K', 'Flickr2K', 'Set5', 'Set14', 'BSDS100', 'Urban100', 'Manga109']
    # training dataset
DIV2K = edict()
**DIV2K.TRAIN = edict()**
**DIV2K.TRAIN.HRx2 = '/home/BebyGAN/Simple-SR-master/datasets/DIV2K/DIV2K_train_HR_sub'**
**DIV2K.TRAIN.HRx3 = '/home/BebyGAN/Simple-SR-master/datasets/DIV2K/DIV2K_train_HR_sub'**
**DIV2K.TRAIN.HRx4 = '/home/BebyGAN/Simple-SR-master/datasets/DIV2K/DIV2K_train_HR_sub'**
**DIV2K.TRAIN.LRx2 = '/home/BebyGAN/Simple-SR-master/datasets/DIV2K/DIV2K_train_LR_bicubic_sub/X2'**
**DIV2K.TRAIN.LRx3 = '/home/BebyGAN/Simple-SR-master/datasets/DIV2K/DIV2K_train_LR_bicubic_sub/X3'**
**DIV2K.TRAIN.LRx4 = '/home/BebyGAN/Simple-SR-master/datasets/DIV2K/DIV2K_train_LR_bicubic_sub/X4' # testing dataset**
Set5 = edict()
Set5.VAL = edict()
Set5.VAL.HRx2 = None
Set5.VAL.HRx3 = None
Set5.VAL.HRx4 = None
Set5.VAL.LRx2 = None
Set5.VAL.LRx3 = None
Set5.VAL.LRx4 = None
Set14 = edict()
Set14.VAL = edict()
Set14.VAL.HRx2 = None
Set14.VAL.HRx3 = None
Set14.VAL.HRx4 = None
Set14.VAL.LRx2 = None
Set14.VAL.LRx3 = None
Set14.VAL.LRx4 = None
 BSDS100 = edict()
BSDS100.VAL = edict()
BSDS100.VAL.HRx2 = '/data/liwenbo/datasets/benchmark_SR/BSDS100/HR/modX2'
BSDS100.VAL.HRx3 = '/data/liwenbo/datasets/benchmark_SR/BSDS100/HR/modX3'
BSDS100.VAL.HRx4 = '/data/liwenbo/datasets/benchmark_SR/BSDS100/HR/modX4'
BSDS100.VAL.LRx2 = '/data/liwenbo/datasets/benchmark_SR/BSDS100/LR_bicubic/X2'
BSDS100.VAL.LRx3 = '/data/liwenbo/datasets/benchmark_SR/BSDS100/LR_bicubic/X3'
BSDS100.VAL.LRx4 = '/data/liwenbo/datasets/benchmark_SR/BSDS100/LR_bicubic/X4'
Urban100 = edict()
Urban100.VAL = edict()
Urban100.VAL.HRx2 = None
Urban100.VAL.HRx3 = None
Urban100.VAL.HRx4 = None
Urban100.VAL.LRx2 = None
Urban100.VAL.LRx3 = None
Urban100.VAL.LRx4 = None
Manga109 = edict()
Manga109.VAL = dict()
Manga109.VAL.HRx2 = None
Manga109.VAL.HRx3 = None
Manga109.VAL.HRx4 = None
Manga109.VAL.LRx2 = None
Manga109.VAL.LRx3 = None
Manga109.VAL.LRx4 = None
def get_dataset(config):
     dataset_type = config.TYPE
     dataset_cls = None
      for module in _dataset_modules:
         dataset_cls = getattr(module, dataset_type, None)
         if dataset_cls is not None:
            break
         if dataset_cls is None:
            raise ValueError(f'Dataset {dataset_type} is not found.')
  hr_paths = []
  lr_paths = []
D = DATASET()
for dataset, split in zip(config.DATASETS, config.SPLITS):
    if dataset not in D.LEGAL or split not in eval('D.%s' % dataset):
        raise ValueError('Illegal dataset.')
    hr_paths.append(eval('D.%s.%s.HRx%d' % (dataset, split, config.SCALE)))
    lr_paths.append(eval('D.%s.%s.LRx%d' % (dataset, split, config.SCALE)))
return dataset_cls(hr_paths, lr_paths, config)`
</code></pre>
<p>The config.py file is changed accordingly as shown in below:</p>
<pre><code class="lang-auto">from easydict import EasyDict as edict

class Config:
# dataset
DATASET = edict()
DATASET.TYPE = 'MixDataset'
DATASET.DATASETS = ['DIV2K']
DATASET.SPLITS = ['TRAIN']
DATASET.PHASE = 'train'
DATASET.INPUT_HEIGHT = 48
DATASET.INPUT_WIDTH = 48
DATASET.SCALE = 4
DATASET.REPEAT = 1
DATASET.VALUE_RANGE = 255.0
DATASET.SEED = 100`
</code></pre>
<p>But, I have got the following error:</p>
<blockquote>
<p>Traceback (most recent call last):<br>
File “train.py”, line 17, in <br>
from dataset import get_dataset<br>
File “/home/BebyGAN/Simple-SR-master/exps/BebyGAN/…/…/dataset/<strong>init</strong>.py”, line 16, in <br>
for file_name in dataset_filenames<br>
File “/home/BebyGAN/Simple-SR-master/exps/BebyGAN/…/…/dataset/<strong>init</strong>.py”, line 16, in <br>
for file_name in dataset_filenames<br>
File “/home/anaconda3/envs/Bebygan/lib/python3.6/importlib/<strong>init</strong>.py”, line 126, in import_module<br>
return _bootstrap._gcd_import(name[level:], package, level)<br>
<strong>ModuleNotFoundError: No module named 'datasets.mix_dataset</strong>’</p>
</blockquote>
<p>Please help me solve this error <a class="mention" href="/u/ptrblck">@ptrblck</a> . I have used the same packages mentioned in the code’s requirement file.</p>

ptrblck: <p><code>dataset_filenames</code> apparently contains <code>mix_dataset</code> which <code>importlib.import_module</code> cannot load so make sure to pass only valid names to:</p>
<pre><code class="lang-python">dataset_filenames = [
os.path.splitext(os.path.basename(v))[0] for v in scandir(dataset_root)
    if v.endswith('_dataset.py')
 ]
dataset_modules = [
       importlib.import_module(f'datasets.{file_name}')
       for file_name in dataset_filenames
]
</code></pre>

PPB: <p><img src="https://discuss.pytorch.org/uploads/default/original/3X/6/5/6553f03cad19b3ec0d98a84dc68e320a070fded6.png" alt="1" data-base62-sha1="eso3PpVFkn5NXqD98bR6J7rnJbw" width="267" height="111"><br>
The file name is same as mix_dataset.py as shown in the image.</p>

ptrblck: <p>I guess <code>import datasets.mix_dataset</code> doesn’t work so check the module name, folder name etc. and make sure you can import the file.</p>