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

Run the pretrained model #29

Open
fekenzofugi opened this issue Oct 18, 2024 · 7 comments
Open

Run the pretrained model #29

fekenzofugi opened this issue Oct 18, 2024 · 7 comments

Comments

@fekenzofugi
Copy link

I would like to know how I can run the pretrained model available in this repository. Could you provide detailed instructions on how to set up and run the model?

Thank you in advance for your help!

@ameraner
Copy link
Owner

Hi, have you read and tried the commands here? https://github.com/ameraner/dsen2-cr?tab=readme-ov-file#basic-commands The Readme is currently the only documentation I can provide. I'll close the issue, please open a new specific issue if you have futher issues when running the code.

@fekenzofugi
Copy link
Author

image

This is the error that i'm facing.

@ameraner
Copy link
Owner

looks like the ID is not being loaded properly, maybe the path to the datasetfilelist.csv needs to be adapted? going into debug mode on your IDE where the error happens and tracing back the steps should show you the issue.

@fekenzofugi
Copy link
Author

fekenzofugi commented Oct 18, 2024

image

Model compiled successfully!
Getting file lists
Number of train files found: 0
Number of validation files found: 2
Number of test files found: 0
Predicting using file: model_SARplain.hdf5
Using this model: val
WARNING: Folder {} exists and content may be overwritten!
WARNING: Folder {} exists and content may be overwritten!
Initializing generator for prediction and evaluation
Generator initialized
Storing evaluation metrics at /home/nipe/dsen2-cr/output/valeval.csv
Traceback (most recent call last):
File "dsen2cr_main.py", line 179, in
run_dsen2cr(args.predict_file, args.resume_file)
File "dsen2cr_main.py", line 160, in run_dsen2cr
max_val_sar, scale)
File "/home/nipe/dsen2-cr/Code/dsen2cr_tools.py", line 169, in predict_dsen2cr
for i, (data, y) in enumerate(predict_generator):
File "/home/nipe/anaconda3/envs/dsen2cr_env/lib/python3.7/site-packages/keras/utils/data_utils.py", line 372, in iter
for item in (self[i] for i in range(len(self))):
File "/home/nipe/anaconda3/envs/dsen2cr_env/lib/python3.7/site-packages/keras/utils/data_utils.py", line 372, in
for item in (self[i] for i in range(len(self))):
File "/home/nipe/dsen2-cr/Code/tools/dataIO.py", line 280, in getitem
self.random_crop_paramy[indexes])
File "/home/nipe/dsen2-cr/Code/tools/dataIO.py", line 308, in __data_generation
random_crop_paramy_temp, data_type=3)
File "/home/nipe/dsen2-cr/Code/tools/dataIO.py", line 407, in get_batch
data_image = self.get_data_image(ID, data_type, random_crop_paramx_temp[i], random_crop_paramy_temp[i])
File "/home/nipe/dsen2-cr/Code/tools/dataIO.py", line 354, in get_data_image
data_path = os.path.join(self.input_data_folder, ID[data_type], ID[4]).lstrip()
IndexError: list index out of range

@ameraner
Copy link
Owner

Could you try to change the code here https://github.com/ameraner/dsen2-cr/blob/main/Code/tools/dataIO.py#L23 to

def get_train_val_test_filelists(listpath): 
    with open(listpath) as f: 
        reader = csv.reader(f, delimiter='\t') 
        filelist = list(reader) 
  
        train_filelist = [] 
        val_filelist = [] 
        test_filelist = [] 
        for  f in filelist: 
            line_entries = f[0].split(sep=", ") 
            if line_entries[0] == '1': 
                train_filelist.append(f) 
            if line_entries[0] == '2': 
                val_filelist.append(f) 
            if line_entries[0] == '3': 
                test_filelist.append(f) 
    return  train_filelist, val_filelist, test_filelist 

and see if it helps?

@ameraner ameraner reopened this Oct 21, 2024
@fekenzofugi
Copy link
Author

Thank you very much.
It's working!

@ameraner
Copy link
Owner

great :) feel free to open a Pull Request with the change if you have the chance.

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

2 participants