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

IndexError: list index out of range #7

Open
jinzhenmu opened this issue Apr 13, 2020 · 33 comments
Open

IndexError: list index out of range #7

jinzhenmu opened this issue Apr 13, 2020 · 33 comments

Comments

@jinzhenmu
Copy link

  • python3 test.py -c config_GAN.json

  • 480
    [250000, 500000, 750000]
    Traceback (most recent call last):
    File "test.py", line 96, in
    main(config)
    File "test.py", line 19, in main
    tester.test()
    File "/home/mjz/2D_Detcetion/EESRGAN/trainer/cowc_GAN_FRCNN_trainer.py", line 38, in test
    self.model.test(self.data_loader, train=False, testResult=True)
    File "/home/mjz/2D_Detcetion/EESRGAN/model/ESRGAN_EESN_FRCNN_Model.py", line 273, in test
    evaluate(self.netG, self.netFRCNN, self.targets, self.device)
    File "/usr/local/lib/python3.6/dist-packages/torch/autograd/grad_mode.py", line 49, in decorate_no_grad
    return func(*args, **kwargs)
    File "/home/mjz/2D_Detcetion/EESRGAN/detection/engine.py", line 140, in evaluate
    coco = get_coco_api_from_dataset(data_loader.dataset)
    File "/home/mjz/2D_Detcetion/EESRGAN/detection/coco_utils.py", line 255, in get_coco_api_from_dataset
    return convert_to_coco_api(dataset)
    File "/home/mjz/2D_Detcetion/EESRGAN/detection/coco_utils.py", line 154, in convert_to_coco_api
    img, targets = ds[img_idx]
    File "/home/mjz/2D_Detcetion/EESRGAN/scripts_for_datasets/COWC_EESRGAN_FRCNN_dataset.py", line 32, in getitem
    img_path_gt = os.path.join(self.data_dir_gt, self.imgs_gt[idx])
    IndexError: list index out of range

@Jakaria08
Copy link
Owner

-- Make sure you have .jpg images:

self.imgs_gt = list(sorted(glob.glob(self.data_dir_gt+"*.jpg")))

-- If you have .png images change the image types to .png.

-- Make sure you have correct path here:

"data_dir_GT": "/home/jakaria/Super_Resolution/Datasets/COWC/DetectionPatches_256x256/Potsdam_ISPRS/HR/x4/",

-- Here:
"data_dir_LQ": "/home/jakaria/Super_Resolution/Datasets/COWC/DetectionPatches_256x256/Potsdam_ISPRS/LR/x4/",

-- And here:
"data_dir_Valid": "/home/jakaria/Super_Resolution/Datasets/COWC/DetectionPatches_256x256/Potsdam_ISPRS/LR/x4/valid_img/",

-- Make sure to put ''/" at the end of directory address.

@jinzhenmu
Copy link
Author

Thanks !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • it's nice work for small object detection

  • i will try the code again.

@themousepotato
Copy link

@jinzhenmu Were you able to fix this issue? I'm getting the same error.

@Jakaria08
Copy link
Owner

The problem lies with this variable: self.imgs_gt. The program does not able to get the data somehow. This is the only problem, I think.
Try to print the variable to see what it contains.
Here:

self.imgs_gt = list(sorted(glob.glob(self.data_dir_gt+"*.jpg")))

Try to follow my first comment in this issue. I hope it would help.

@jinzhenmu
Copy link
Author

jinzhenmu commented Oct 9, 2020 via email

@themousepotato
Copy link

themousepotato commented Oct 9, 2020

I just noticed that my error was a little different. For me, it's self.annotation which is empty. Could you please elaborate on how are we generating the validation set? I'd done generate_mod_LR_bic() of scripts_GAN_HR-LR.py (Running other functions leads to error since I don't have all the data). All the data was with me other than /home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved/*.

From the pretrainied weights, I was able to get the following:

        "pretrain_model_G": "/home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved/pretrained_models_EESRGAN_FRCNN/170000_G.pth",
        "pretrain_model_D": "/home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved/pretrained_models_EESRGAN_FRCNN/170000_D.pth",
        "pretrain_model_FRCNN": "/home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved/pretrained_models_EESRGAN_FRCNN/170000_FRCNN.pth",

What should I do for the data other than this in `/home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved/*? @Jakaria08 @jinzhenmu

Edit: I'm trying to reproduce the results using pretrained weights FYI

@cl886699
Copy link

in my case,I put the annotation *.txt files in HR,LR and Bic, but it should be put in HR/x4,after fixed this,I meet RuntimeError: CUDA out of memory.
by the way, how to generating the validation set?

@themousepotato
Copy link

@cl886699 From where did you get those annotation files? Even I don't know how to generate the validation set.

@cl886699
Copy link

@cl886699 From where did you get those annotation files? Even I don't know how to generate the validation set.

mybe copy_folder_name_for_valid_image (line of 92 in scripts_GAN_HR-LR.py) this function can get the validation data.

@themousepotato
Copy link

@cl886699 But I don't have the data for /home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved_ESRGAN/val_images/*/. What should it be? I haven't done any training. I'm trying to reproduce the results using the pretrained weights.

@cl886699
Copy link

@cl886699 But I don't have the data for /home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved_ESRGAN/val_images/*/. What should it be? I haven't done any training. I'm trying to reproduce the results using the pretrained weights.

val_images means validation datasets,you should split datasets to train,val and test, you should do it by yourself. if you just want to test this model, you can choose annother city's data to test

@themousepotato
Copy link

Hey @cl886699, were you able to generate the validation set? I still can't figure that out. I'm also planning to work with the model other than just testing it.

@themousepotato
Copy link

I'm getting this error now. I'd copied the annotation files and placed a single validation image in the folders.

(image-sr) navaneeth@mousebox:~/workspace/image-super-resolution/EESRGAN$ python test.py -c config_GAN.json
400000
[250000, 500000, 750000]
creating index...
index created!
Test:  [0/1]  eta: 0:00:01  model_time: 1.5657 (1.5657)  evaluator_time: 0.0360 (0.0360)  time: 1.7147  data: 0.1107  max mem: 651
Test: Total time: 0:00:01 (1.9105 s / it)
Averaged stats: model_time: 1.5657 (1.5657)  evaluator_time: 0.0360 (0.0360)
Accumulating evaluation results...
DONE (t=0.02s).
IoU metric: bbox
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.752
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Detection started........
1
Traceback (most recent call last):
  File "test.py", line 96, in <module>
    main(config)
  File "test.py", line 19, in main
    tester.test()
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/trainer/cowc_GAN_FRCNN_trainer.py", line 38, in test
    self.model.test(self.data_loader, train=False, testResult=True)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/model/ESRGAN_EESN_FRCNN_Model.py", line 273, in test
    evaluate_save(self.netG, self.netFRCNN, self.targets, self.device, self.config)
  File "/home/navaneeth/anaconda3/envs/image-sr/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 15, in decorate_context
    return func(*args, **kwargs)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/detection/engine.py", line 123, in evaluate_save
    get_prediction(outputs, file_path, config, file_name, img)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/detection/engine.py", line 99, in get_prediction
    draw_detection_boxes(new_class_conf_box, config, file_name, image)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/detection/engine.py", line 86, in draw_detection_boxes
    cv2.imwrite(dest_image_path, image)
cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-njn2fp78/opencv/modules/imgcodecs/src/loadsave.cpp:738: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'

@Jakaria08
Copy link
Owner

Jakaria08 commented Oct 23, 2020

Generated images are stored in this location:

dest_image_path = os.path.join(config['path']['Test_Result_SR'], file_name+'.png')

Make sure the directory path is ok.

Create folders to create this path:

"Test_Result_SR": "/home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved/Test_Result_SR/"

"Test_Result_SR": "/[Your path from root]/[Your path]/[Your path]/EESRGAN/saved/Test_Result_SR/"

I don't have any GPU access now, therefore I am not able to check my code for any issue related to pytorch version mismatch or creation of some folders that are needed to store images. I will check my code in a new GPU machine soon to update the hard-coded portion and pytorch version. I will also add more documentations if possible.

@themousepotato
Copy link

@Jakaria08 I've checked the path and it's fine I think. Thank you for finding time to look at this. I hope you get the GPU access soon :)

@MrCrowbar
Copy link

I'm getting this error now. I'd copied the annotation files and placed a single validation image in the folders.

(image-sr) navaneeth@mousebox:~/workspace/image-super-resolution/EESRGAN$ python test.py -c config_GAN.json
400000
[250000, 500000, 750000]
creating index...
index created!
Test:  [0/1]  eta: 0:00:01  model_time: 1.5657 (1.5657)  evaluator_time: 0.0360 (0.0360)  time: 1.7147  data: 0.1107  max mem: 651
Test: Total time: 0:00:01 (1.9105 s / it)
Averaged stats: model_time: 1.5657 (1.5657)  evaluator_time: 0.0360 (0.0360)
Accumulating evaluation results...
DONE (t=0.02s).
IoU metric: bbox
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.752
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Detection started........
1
Traceback (most recent call last):
  File "test.py", line 96, in <module>
    main(config)
  File "test.py", line 19, in main
    tester.test()
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/trainer/cowc_GAN_FRCNN_trainer.py", line 38, in test
    self.model.test(self.data_loader, train=False, testResult=True)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/model/ESRGAN_EESN_FRCNN_Model.py", line 273, in test
    evaluate_save(self.netG, self.netFRCNN, self.targets, self.device, self.config)
  File "/home/navaneeth/anaconda3/envs/image-sr/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 15, in decorate_context
    return func(*args, **kwargs)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/detection/engine.py", line 123, in evaluate_save
    get_prediction(outputs, file_path, config, file_name, img)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/detection/engine.py", line 99, in get_prediction
    draw_detection_boxes(new_class_conf_box, config, file_name, image)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/detection/engine.py", line 86, in draw_detection_boxes
    cv2.imwrite(dest_image_path, image)
cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-njn2fp78/opencv/modules/imgcodecs/src/loadsave.cpp:738: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'

@themousepotato Did you solve this problem? I'm having the same issue. Thanks!

@MrCrowbar
Copy link

I'm getting this error now. I'd copied the annotation files and placed a single validation image in the folders.

(image-sr) navaneeth@mousebox:~/workspace/image-super-resolution/EESRGAN$ python test.py -c config_GAN.json
400000
[250000, 500000, 750000]
creating index...
index created!
Test:  [0/1]  eta: 0:00:01  model_time: 1.5657 (1.5657)  evaluator_time: 0.0360 (0.0360)  time: 1.7147  data: 0.1107  max mem: 651
Test: Total time: 0:00:01 (1.9105 s / it)
Averaged stats: model_time: 1.5657 (1.5657)  evaluator_time: 0.0360 (0.0360)
Accumulating evaluation results...
DONE (t=0.02s).
IoU metric: bbox
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.752
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Detection started........
1
Traceback (most recent call last):
  File "test.py", line 96, in <module>
    main(config)
  File "test.py", line 19, in main
    tester.test()
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/trainer/cowc_GAN_FRCNN_trainer.py", line 38, in test
    self.model.test(self.data_loader, train=False, testResult=True)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/model/ESRGAN_EESN_FRCNN_Model.py", line 273, in test
    evaluate_save(self.netG, self.netFRCNN, self.targets, self.device, self.config)
  File "/home/navaneeth/anaconda3/envs/image-sr/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 15, in decorate_context
    return func(*args, **kwargs)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/detection/engine.py", line 123, in evaluate_save
    get_prediction(outputs, file_path, config, file_name, img)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/detection/engine.py", line 99, in get_prediction
    draw_detection_boxes(new_class_conf_box, config, file_name, image)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/detection/engine.py", line 86, in draw_detection_boxes
    cv2.imwrite(dest_image_path, image)
cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-njn2fp78/opencv/modules/imgcodecs/src/loadsave.cpp:738: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'

@themousepotato Did you solve this problem? I'm having the same issue. Thanks!

I solved it already, if you need assitance ask me, maybe I can help you :)

@themousepotato
Copy link

@MrCrowbar I haven't solved it. It would be great if you can help. Thanks for reaching out 😅

@themousepotato
Copy link

Ping @MrCrowbar just in case you've forgotten :)

@brenoslinhares
Copy link

Hello guys!
I am using Google Colab to test the algorithm with the pre-trained models. I'm having a problem where to get the validation images from. Also, in the folders
1./content/home/jakaria/Super_Resolution/Datasets/COWC/DetectionPatches_256x256/Potsdam_ISPRS/Bic/x4/valid_img
2. /content/home/jakaria/Super_Resolution/Datasets/COWC/DetectionPatches_256x256/Potsdam_ISPRS/HR/x4/valid_img
3. /content/home/jakaria/Super_Resolution/Datasets/COWC/DetectionPatches_256x256/Potsdam_ISPRS/LR/x4/valid_img

should i put only the validation image or also its .txt file?

In the understanding I got from the project tutorial, I put an HR, LR and Bic image as an example in the valid_img folders after executing the scripts_GAN_HR-LR.py algorithm and also its .txt file, otherwise it would give an error. I ask for help, because the execution result is this:

400000
[250000, 500000, 750000]
creating index...
index created!
Test: [0/2] eta: 0:00:00 model_time: 0.4076 (0.4076) evaluator_time: 0.0020 (0.0020) time: 0.4982 data: 0.0880 max mem: 657
Test: [1/2] eta: 0:00:00 model_time: 0.1743 (0.2910) evaluator_time: 0.0019 (0.0020) time: 0.3399 data: 0.0465 max mem: 660
Test: Total time: 0:00:00 (0.3614 s / it)
Averaged stats: model_time: 0.1743 (0.2910) evaluator_time: 0.0019 (0.0020)
Accumulating evaluation results...
DONE (t=0.00s).
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.822
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.822
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.822
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.822
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.881
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.100
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.900
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.900
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.900
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.889
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Detection started........
1
libpng warning: Image width is zero in IHDR
libpng warning: Image height is zero in IHDR
libpng error: Invalid IHDR data
2
libpng warning: Image width is zero in IHDR
libpng warning: Image height is zero in IHDR
libpng error: Invalid IHDR data
successfully generated the results!

But when I go to the Test_Result_SR folder, the file does not open. I believe it is because of the result at the end of the execution.

@brenoslinhares
Copy link

@MrCrowbar e @Jakaria08 help me. Thank you.

@Jakaria08
Copy link
Owner

Sorry for my late reply. The error you are getting is new to me. I am not sure what is happening. You need both the image and text files for evaluation. I didn't test it on google Colab. I will try to run the code on google Colab if I get time. @brenoslinhares

@brenoslinhares
Copy link

@Jakaria08, I noticed that the line of code that is making the matrix error with number of rows and columns equal to zero is this:

def draw_detection_boxes(new_class_conf_box, config, file_name, image):
source_image_path = os.path.join(config['path']['output_images'], file_name, file_name+'_112000_final_SR.png')

Could you please inform me, how to generate the images for this path?

Thanks!

@brenoslinhares
Copy link

@MrCrowbar, Could you tell me how you fixed your problem in the code, as reported above?

@Lee-Gao
Copy link

Lee-Gao commented Mar 14, 2021

I just noticed that my error was a little different. For me, it's self.annotation which is empty. Could you please elaborate on how are we generating the validation set? I'd done generate_mod_LR_bic() of scripts_GAN_HR-LR.py (Running other functions leads to error since I don't have all the data). All the data was with me other than /home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved/*.

From the pretrainied weights, I was able to get the following:

        "pretrain_model_G": "/home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved/pretrained_models_EESRGAN_FRCNN/170000_G.pth",
        "pretrain_model_D": "/home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved/pretrained_models_EESRGAN_FRCNN/170000_D.pth",
        "pretrain_model_FRCNN": "/home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved/pretrained_models_EESRGAN_FRCNN/170000_FRCNN.pth",

What should I do for the data other than this in `/home/jakaria/Super_Resolution/Filter_Enhance_Detect/saved/*? @Jakaria08 @jinzhenmu

Edit: I'm trying to reproduce the results using pretrained weights FYI

Has the problem you mentioned been resolved?

@RakeshRaj97
Copy link

RakeshRaj97 commented May 13, 2021

21-05-13 21:01:15.778 - INFO: Loading model for G [saved/pretrained_models_EESRGAN_FRCNN/170000_G.pth] ... 21-05-13 21:01:15.891 - INFO: Loading model for D [saved/pretrained_models_EESRGAN_FRCNN/170000_D.pth] ... 21-05-13 21:01:15.926 - INFO: Loading model for D [saved/pretrained_models_EESRGAN_FRCNN/170000_FRCNN.pth] ... 21-05-13 21:01:16.002 - INFO: Number of train images: 1,338, iters: 669 21-05-13 21:01:16.002 - INFO: Total epochs needed: 598 for iters 400,000 21-05-13 21:01:16.034 - INFO: Start training from epoch: 0, iter: 0 Traceback (most recent call last): File "train.py", line 94, in <module> main(config) File "train.py", line 73, in main trainer.train() File "/mnt/6adf827a-6bba-4144-8bbb-298f8389ce17/aerial-object-detection/EESRGAN/trainer/cowc_GAN_FRCNN_trainer.py", line 74, in train for _, (image, targets) in enumerate(self.data_loader): File "/home/rakesh/anaconda3/envs/aerial/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 517, in __next__ data = self._next_data() File "/home/rakesh/anaconda3/envs/aerial/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1199, in _next_data return self._process_data(data) File "/home/rakesh/anaconda3/envs/aerial/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1225, in _process_data data.reraise() File "/home/rakesh/anaconda3/envs/aerial/lib/python3.7/site-packages/torch/_utils.py", line 429, in reraise raise self.exc_type(msg) cv2.error: Caught error in DataLoader worker process 0. Original Traceback (most recent call last): File "/home/rakesh/anaconda3/envs/aerial/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 202, in _worker_loop data = fetcher.fetch(index) File "/home/rakesh/anaconda3/envs/aerial/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/rakesh/anaconda3/envs/aerial/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "/mnt/6adf827a-6bba-4144-8bbb-298f8389ce17/aerial-object-detection/EESRGAN/scripts_for_datasets/COWC_EESRGAN_FRCNN_dataset.py", line 36, in __getitem__ img_gt = cv2.cvtColor(img_gt, cv2.COLOR_BGR2RGB) cv2.error: OpenCV(4.5.2) /tmp/pip-req-build-5wrl9sz4/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
Did someone solved this?

@bibuzz
Copy link

bibuzz commented May 18, 2021

Hello guys!
I am using Google Colab to test the algorithm with the pre-trained models. I'm having a problem where to get the validation images from. Also, in the folders
1./content/home/jakaria/Super_Resolution/Datasets/COWC/DetectionPatches_256x256/Potsdam_ISPRS/Bic/x4/valid_img
2. /content/home/jakaria/Super_Resolution/Datasets/COWC/DetectionPatches_256x256/Potsdam_ISPRS/HR/x4/valid_img
3. /content/home/jakaria/Super_Resolution/Datasets/COWC/DetectionPatches_256x256/Potsdam_ISPRS/LR/x4/valid_img

should i put only the validation image or also its .txt file?

In the understanding I got from the project tutorial, I put an HR, LR and Bic image as an example in the valid_img folders after executing the scripts_GAN_HR-LR.py algorithm and also its .txt file, otherwise it would give an error. I ask for help, because the execution result is this:

400000
[250000, 500000, 750000]
creating index...
index created!
Test: [0/2] eta: 0:00:00 model_time: 0.4076 (0.4076) evaluator_time: 0.0020 (0.0020) time: 0.4982 data: 0.0880 max mem: 657
Test: [1/2] eta: 0:00:00 model_time: 0.1743 (0.2910) evaluator_time: 0.0019 (0.0020) time: 0.3399 data: 0.0465 max mem: 660
Test: Total time: 0:00:00 (0.3614 s / it)
Averaged stats: model_time: 0.1743 (0.2910) evaluator_time: 0.0019 (0.0020)
Accumulating evaluation results...
DONE (t=0.00s).
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.822
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.822
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.822
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.822
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.881
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.100
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.900
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.900
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.900
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.889
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Detection started........
1
libpng warning: Image width is zero in IHDR
libpng warning: Image height is zero in IHDR
libpng error: Invalid IHDR data
2
libpng warning: Image width is zero in IHDR
libpng warning: Image height is zero in IHDR
libpng error: Invalid IHDR data
successfully generated the results!

But when I go to the Test_Result_SR folder, the file does not open. I believe it is because of the result at the end of the execution.

Hi , I am also getting the same error, Did you solve your issue?

@yjg123456
Copy link

File "/home/gfzx/yjg/EESRGAN-master/scripts_for_datasets/COWC_EESRGAN_FRCNN_dataset.py", line 36, in getitem
annotation_path = os.path.join(self.data_dir_lq, self.annotation[idx])

please!!!! i can not get the "annotation_path", its value is empty, how can i get it ????

@yjg123456
Copy link

I'm getting this error now. I'd copied the annotation files and placed a single validation image in the folders.

(image-sr) navaneeth@mousebox:~/workspace/image-super-resolution/EESRGAN$ python test.py -c config_GAN.json
400000
[250000, 500000, 750000]
creating index...
index created!
Test:  [0/1]  eta: 0:00:01  model_time: 1.5657 (1.5657)  evaluator_time: 0.0360 (0.0360)  time: 1.7147  data: 0.1107  max mem: 651
Test: Total time: 0:00:01 (1.9105 s / it)
Averaged stats: model_time: 1.5657 (1.5657)  evaluator_time: 0.0360 (0.0360)
Accumulating evaluation results...
DONE (t=0.02s).
IoU metric: bbox
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.564
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.752
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.750
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Detection started........
1
Traceback (most recent call last):
  File "test.py", line 96, in <module>
    main(config)
  File "test.py", line 19, in main
    tester.test()
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/trainer/cowc_GAN_FRCNN_trainer.py", line 38, in test
    self.model.test(self.data_loader, train=False, testResult=True)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/model/ESRGAN_EESN_FRCNN_Model.py", line 273, in test
    evaluate_save(self.netG, self.netFRCNN, self.targets, self.device, self.config)
  File "/home/navaneeth/anaconda3/envs/image-sr/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 15, in decorate_context
    return func(*args, **kwargs)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/detection/engine.py", line 123, in evaluate_save
    get_prediction(outputs, file_path, config, file_name, img)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/detection/engine.py", line 99, in get_prediction
    draw_detection_boxes(new_class_conf_box, config, file_name, image)
  File "/home/navaneeth/workspace/image-super-resolution/EESRGAN/detection/engine.py", line 86, in draw_detection_boxes
    cv2.imwrite(dest_image_path, image)
cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-njn2fp78/opencv/modules/imgcodecs/src/loadsave.cpp:738: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'

@themousepotato Did you solve this problem? I'm having the same issue. Thanks!

hello , my question is the "annotation_path", its value is empty, can you help me solve it ? thank you!!!

@spacewalk01
Copy link

spacewalk01 commented Jul 13, 2021

@brenoslinhares I have the same problem. I found that there is no code for generating images in output_images. 'output_images' is only mentioned in engine.py. I think the code is incomplete.

@spacewalk01
Copy link

spacewalk01 commented Jul 13, 2021

def draw_detection_boxes(new_class_conf_box, config, file_name, image):
    source_image_path = os.path.join(config['path']['output_images'], file_name, file_name+'_112000_final_SR.png')
    dest_image_path = os.path.join(config['path']['Test_Result_SR'], file_name+'.png')
    image = cv2.imread(source_image_path, 1)

@Jakaria08 You are supposed to generate these images in output_images during test in order to read and label them in draw_detection_boxes function but there is no way to make these output images in your implementation.

@WangZhen1175701153
Copy link

def draw_detection_boxes(new_class_conf_box, config, file_name, image):
    source_image_path = os.path.join(config['path']['output_images'], file_name, file_name+'_112000_final_SR.png')
    dest_image_path = os.path.join(config['path']['Test_Result_SR'], file_name+'.png')
    image = cv2.imread(source_image_path, 1)

@Jakaria08 You are supposed to generate these images in output_images during test in order to read and label them in draw_detection_boxes function but there is no way to make these output images in your implementation.

Hi,I met the same problem with you, how did you solve it?if you have fixed it,could you tell me? please!!!

@Lee-Gao
Copy link

Lee-Gao commented Oct 17, 2021 via email

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