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

Can I test all the images in one folder? #10

Open
circlebig opened this issue Jun 3, 2024 · 8 comments
Open

Can I test all the images in one folder? #10

circlebig opened this issue Jun 3, 2024 · 8 comments

Comments

@circlebig
Copy link

I don't know how to test my images in one folder.
I will use your pretrained model.
Can you help how can I use your model to train my images?

@ming053l
Copy link
Owner

ming053l commented Jun 3, 2024

Hi,

You can run the following script:

python drct/test.py -opt options/test/DRCT_SRx4_ImageNet-pretrain.yml

and, please see the configuration file,
options/test/DRCT_SRx4_ImageNet-pretrain.yml

First, please change the dataroot_lq to your image file folder. And comment out dataroot_gt

 test_1:
    name: DIV2K_valid
    type: PairedImageDataset
    #dataroot_gt: "/work/ming0531/DRCT/DRCT/datasets/DIV2K/DIV2K_valid_HR_rotated/"
    dataroot_lq: "/work/ming0531/DRCT/DRCT/datasets/DIV2K/DIV2K_valid_LR_bicubic/"
    io_backend:
      type: disk
    num_worker_per_gpu: 4
    batch_size_per_gpu: 1

Then, change the location of pretrained model

path:
  pretrain_network_g: /work/ming0531/DRCT/models/DRCT-L.pth
  strict_load_g: true
  param_key_g: 'params_ema'

Or, you can refer to the following configuration

name: test_DRCT-L_SRx4_NTIRE_rotate_270_300000_1_test
model_type: DRCTModel
scale: 4
num_gpu: 1  # set num_gpu: 0 for cpu mode
manual_seed: 0

datasets:

  test_1:
    name: DIV2K_valid
    type: SingleImageDataset
    #dataroot_gt: "/work/ming0531/DRCT/data/DIV2K/DIV2K_valid_HR_rotated/rotated_270/"
    dataroot_lq: "/work/ming0531/DRCT/data/test/DIV2K_test_LR_bicubic/rotated_270/"
    io_backend:
      type: disk
    num_worker_per_gpu: 4
    batch_size_per_gpu: 1

  # test_2:  # the 2nd test dataset
  #   name: Set14
  #   type: PairedImageDataset
  #   dataroot_gt: ./datasets/Set14/GTmod4
  #   dataroot_lq: ./datasets/Set14/LRbicx4
  #   io_backend:
  #     type: disk

  # test_3:
  #   name: Urban100
  #   type: PairedImageDataset
  #   dataroot_gt: ./datasets/urban100/GTmod4
  #   dataroot_lq: ./datasets/urban100/LRbicx4
  #   io_backend:
  #     type: disk

  # test_4:
  #    name: BSDS100
  #    type: PairedImageDataset
  #    dataroot_gt: ./datasets/BSDS100/GTmod4
  #    dataroot_lq: ./datasets/BSDS100/LRbicx4
  #    io_backend:
  #      type: disk

  # test_5:
  #     name: Manga109
  #     type: PairedImageDataset
  #     dataroot_gt: ./datasets/manga109/GTmod4
  #     dataroot_lq: ./datasets/manga109/LRbicx4
  #     io_backend:
  #       type: disk

# network structures
network_g:
  type: DRCT
  upscale: 4
  in_chans: 3
  img_size: 64
  window_size: 16
  compress_ratio: 3
  squeeze_factor: 30
  conv_scale: 0.01
  overlap_ratio: 0.5
  img_range: 1.
  depths: [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]
  embed_dim: 180
  num_heads: [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]
  gc: 32
  mlp_ratio: 2
  upsampler: 'pixelshuffle'
  resi_connection: '1conv'
# path
path:
  pretrain_network_g : "/work/ming0531/DRCT/experiments/train_DRCT-L_SRx4_NTIRE_1e5_resume_archived_20240315_162311/models/net_g_250000.pth"
  strict_load_g: true
  resume_state: ~

# validation settings
val:
  save_img: true
  suffix: ~  # add suffix to saved images, if None, use exp name

@circlebig
Copy link
Author

Thank you. After I changed like that, self.gt_folder, self.lq_folder = opt['dataroot_gt'], opt['dataroot_lq']
KeyError: 'dataroot_gt' error is in dataroot_gt..

@circlebig
Copy link
Author

circlebig commented Jun 3, 2024

oh after I change to type: SingleImageDataset it worked. But tisn't any result image in results folder

name: DRCT_SRx4_ImageNet-pretrain
model_type: DRCTModel
scale: 4
num_gpu: 1 # set num_gpu: 0 for cpu mode
manual_seed: 0

datasets:
test_1: # the 1st test dataset
name: Set5
type: SingleImageDataset
#dataroot_gt: ./datasets/Set5/GTmod4
dataroot_lq: ./datasets
io_backend:
type: disk

network structures

network_g:
type: DRCT
upscale: 4
in_chans: 3
img_size: 64
window_size: 16
compress_ratio: 3
squeeze_factor: 30
conv_scale: 0.01
overlap_ratio: 0.5
img_range: 1.
depths: [6, 6, 6, 6, 6, 6]
embed_dim: 180
num_heads: [6, 6, 6, 6, 6, 6]
mlp_ratio: 2
upsampler: 'pixelshuffle'
resi_connection: '1conv'

path

path:
pretrain_network_g: ./experiments/pretrained_models/DRCT_SRx4_ImageNet-pretrain.pth
strict_load_g: true
param_key_g: 'params_ema'

validation settings

val:
save_img: true
suffix: ~ # add suffix to saved images, if None, use exp name

metrics:
psnr: # metric name, can be arbitrary
type: calculate_psnr
crop_border: 4
test_y_channel: true
ssim:
type: calculate_ssim
crop_border: 4
test_y_channel: true
This is my yml file

@ming053l
Copy link
Owner

ming053l commented Jun 3, 2024

hi, the output file may be in this folder?

.DRCT/results

@circlebig
Copy link
Author

스크린샷 2024-06-03 175542
there is only the log file. Visualization folder is empty

@ming053l
Copy link
Owner

ming053l commented Jun 3, 2024

@circlebig

hi, sorry for inconvenice. I have updated the inference.py at our repository, please try it! It should can work.

It is modified from BasicSR

You just need to change 'input_dir', 'output_dir' and 'model_path'

python inference.py --input_dir [input_dir ] --output_dir [input_dir ] --model_path[model_path]

@circlebig
Copy link
Author

Thank you very much. Can I try this model with any size of images?

@ming053l
Copy link
Owner

ming053l commented Jun 7, 2024

@circlebig hi, I uploaded the 'inference.py' in the repository, now you can try it again!

i have fixed up some bugs. I ignored the tiling process in the previous version.

Now you can run it easily, it works on my computer (any size of images are acceptable for DRCT)

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