huawei-noah / Pretrained-IPT

Apache License 2.0
421 stars 62 forks source link

How to get Single Image Inference (output) for Deraining and Denoising #25

Open GitarthVaishnav opened 2 years ago

GitarthVaishnav commented 2 years ago

Thank you for sharing the good work!

I was trying to get deraining and denoising output (inference) on single image of my choice, but was not able to do the same.

The steps I performed are: Added a folder /Pretrained-IPT-main/test_data/Images Added this 'Images' in the init.py of /Pretrained-IPT-main/data/ Added the pretrained deraining model to the /Pretrained-IPT-main/pretrained_model/ folder

Used the following code: python main.py --dir_data /Pretrained-IPT-main/test_data/ --data_test 'Images' --pretrain /Pretrained-IPT-main/pretrained_model/IPT_derain.pt --scale 1 --derain_test 1 --test_only

This is giving the following output:

Requirement already satisfied: einops in /usr/local/lib/python3.7/dist-packages (0.3.2)
Making model...

Evaluation:
0it [00:00, ?it/s]
[Images x1] PSNR: nan (Best: nan @epoch 1)
Forward: 0.38s

Saving...
Total: 0.38s

There is no derained image being stored in any folder, instead a couple of folders are being created: /Pretrained-IPT-main/test_data/benchmark/Images/bin (empty) /Pretrained-IPT-main/test_data/DIV2K /Pretrained-IPT-main/test_data/DIV2K/DIV2K_train_HR (empty) /Pretrained-IPT-main/test_data/DIV2K/bin /Pretrained-IPT-main/test_data/DIV2K/bin/DIV2K_train_HR (empty)

Request you to let me know what am I doing wrong, and how can I get inference (output) on a single image for deraining and denoising.

HantingChen commented 2 years ago

For derain:

python main.py --dir_data $DATA_PATH --pretrain $MODEL_PATH --scale 1 --derain

So if you want to get the deraining results, you may set the arg: --derain instead of --derain_test 1

GitarthVaishnav commented 2 years ago

I tried this, but it is finding TrainL dataset to work.

I want to use my own single image and get deraining result on that single image.

How can I do that?

Request you to let me know.

image

HantingChen commented 2 years ago

You can modify :

        self.derain_dataroot = os.path.join(args.dir_data, "RainTrainL")
        self.derain_img_list = search(self.derain_dataroot, "rainstreak")
        self.derain_test = os.path.join(args.dir_data, "Rain100L")
        self.derain_lr_test = search(self.derain_test, "rain")
        self.derain_hr_test = [path.replace("rainy/","no") for path in self.derain_lr_test]

in Lines to:

        self.derain_lr_test = search(self.derain_test, "")
        self.derain_hr_test = search(self.derain_test, "")

Moreover, you may set the arg --save_results to save the output images.