Closed DGUnggi closed 4 weeks ago
I just modified front section of train() function.
num_samples should be a positive integer value, but got num_samples=0
I think you should check the path of your dataset and dataloader to make sure you load it right.
@xuhangc
Thank you for your replying.
However, as you can see this root@817071d8d489:/workspace/flare-removal# python train.py MODEL.FILM: target Image path: dataset/Flickr24K Image size: 512 Image path: dataset/Flickr24K Loaded 0 images. Base Image Loaded with examples: 0
There is no Flickr24K dataset. I downloaded Flare7k dataset from your github, but there is no file named 'Flickr24k'
Also, i have an another question. To train and test my custom dataset, what should i prepare? I only have dataset images.
Flare7K dataset only contains flare images, so we use the Flickr24K dataset link as the background images to generate flare-corrupted/flare-free pairs as the training dataset. This part of the function is implemented in our dataloader. If your custom dataset only contains flare images or only contains background images, you can modify flare image path and background image path in the config.py. If your custom dataset already contains paired flare-corrupted/flare-free images, you need to modify the corresponding part of generating paired data in the dataloader.
@Jiang-maomao I only have unpaired(single) flare images. you say that i only need to modify flare image path? I also have an another question, too. There is no pre-trained model, right? It means that i should train the model with Flare7K and Flickr24K dataset and test with my custom images?
@Jiang-maomao I only have unpaired(single) flare images. you say that i only need to modify flare image path? I also have an another question, too. There is no pre-trained model, right? It means that i should train the model with Flare7K and Flickr24K dataset and test with my custom images?
Yes, and you can use three data combination methods to generate flare-corrupted/flare-free pairs as train dataset:
@Jiang-maomao Thank you for your answering! This is config.py code You said that i can train the model with Flare7K and Flickr24K, so Where should I put the dataset path in each? Can you explain by considering two images below?
and this is the file hierarchy
@Jiang-maomao Thank you for your answering! This is config.py code You said that i can train the model with Flare7K and Flickr24K, so Where should I put the dataset path in each? Can you explain by considering two images below?
and this is the file hierarchy
hey, here is dataset path in config.py:
I want to test a model by using my custom dataset. However, i think that training a model with Flare7k dataset must be needed. Therefore, i uploaded Flare7k dataset in working directory and execute with a command line
python train.py
There is an error belowroot@817071d8d489:/workspace/flare-removal# python train.py MODEL.FILM: target Image path: dataset/Flickr24K Image size: 512 Image path: dataset/Flickr24K Loaded 0 images. Base Image Loaded with examples: 0 test dataset/Flare7k/Scattering_Flare/Compound_Flare Scattering Flare Image: Flare7K_scattering is loaded successfully with examples 5000 Now we have 5000 scattering flare images Reflective Flare Image: Flare7K_reflective is loaded successfully with examples 2000 Now we have 2000 refelctive flare images Traceback (most recent call last): File "/workspace/flare-removal/train.py", line 339, in <module> train() File "/workspace/flare-removal/train.py", line 55, in train trainloader = DataLoader(dataset=train_dataset, batch_size=opt.OPTIM.BATCH_SIZE, shuffle=True, num_workers=32, File "/opt/conda/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 350, in __init__ sampler = RandomSampler(dataset, generator=generator) # type: ignore[arg-type] File "/opt/conda/lib/python3.9/site-packages/torch/utils/data/sampler.py", line 143, in __init__ raise ValueError(f"num_samples should be a positive integer value, but got num_samples={self.num_samples}") ValueError: num_samples should be a positive integer value, but got num_samples=0
Also, this is the train.py code. `import warnings
import torch.optim as optim from accelerate import Accelerator from torch.utils.data import DataLoader from torchmetrics.functional import peak_signal_noise_ratio, structural_similarity_index_measure from torchmetrics.image.lpip import LearnedPerceptualImagePatchSimilarity
from tqdm import tqdm
from config import Config from data import get_validation_data from models import from utils import
from data.dataset_RGB import Flare_Pair_Loader
warnings.filterwarnings('ignore')
opt = Config('config.yml') print(f"MODEL.FILM: {opt.MODEL.FILM}")
seed_everything(opt.OPTIM.SEED)
if not os.path.exists(opt.TRAINING.SAVE_DIR): os.makedirs(opt.TRAINING.SAVE_DIR)
def train():
Accelerate
if name == 'main': train() ` In summarize, i want to use flare-removal model for my custom dataset. But i don't know how to do this. Please let me know how to use this model and utilize github code.