mdyao / HDR-BiTNet

[TMM 2023] Official Implementation of "Bidirectional Translation Between UHD-HDR and HD-SDR Videos"
MIT License
5 stars 0 forks source link

Not able to run the test #1

Open jasminsehic opened 5 months ago

jasminsehic commented 5 months ago

Hello, thank you for your repository!

I am having trouble executing the test, I was hoping you could provide some guidance @mdyao ?

I got as far as modifying this line to load the SDR file but I then get the following error below. Do you have any advice what I am doing wrong?

image

Original Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\torch\utils\data\_utils\worker.py", line 308, in _worker_loop
    data = fetcher.fetch(index)
  File "C:\Python39\lib\site-packages\torch\utils\data\_utils\fetch.py", line 51, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "C:\Python39\lib\site-packages\torch\utils\data\_utils\fetch.py", line 51, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "C:\Users\Development\HDR-BiTNet\data\JSH_dataset_val.py", line 42, in __getitem__
    S = extrac_structure(HDR_img, SDR_img)
  File "C:\Users\Development\HDR-BiTNet\models\extrac_S.py", line 50, in extrac_structure
    out, HDR, SDR = extract_S(hdr, sdr)
  File "C:\Users\Development\HDR-BiTNet\models\extrac_S.py", line 36, in extract_S
    out = (SDR + HDR)/2
ValueError: operands could not be broadcast together with shapes (1,1,3840,2160) (1,1,1920,1080)
mdyao commented 5 months ago

Hi @jasminsehic, during the validation step, there's no need to extract 'S'. You can simply comment out the code related to 'S' during the validation process.

Feel free to contact me if there remains any questions.

jasminsehic commented 5 months ago

Thank you @mdyao I commented out the code related to S and got a bit further.

image

I have the following testdata files I downloaded from your Google Drive image

When I run python test.py -opt options/test/test.yml I get the following error. Is it possible I have configured something wrong in the test.yml or maybe something wrong with testdata?

24-03-27 20:54:19.219 - INFO: Random seed: 10
24-03-27 20:54:19.413 - INFO: Dataset [JSHDataset - SIDD] is created.
24-03-27 20:54:19.413 - INFO: Number of train images: 39,840, iters: 4,980
24-03-27 20:54:19.413 - INFO: Total epochs needed: 121 for iters 600,000
24-03-27 20:54:19.417 - INFO: Dataset [JSHDataset - SIDD_val] is created.
24-03-27 20:54:19.417 - INFO: Number of val images in [SIDD_val]: 28
24-03-27 20:54:19.735 - INFO: Loading model for G [./model.pth] ...
24-03-27 20:54:19.970 - INFO: Model [InvHDR_Model] is created.
24-03-27 20:54:19.970 - INFO: Start training from epoch: 0, iter: 0
Traceback (most recent call last):
  File "C:\Users\Andrea\Development\HDR-BiTNet\test.py", line 229, in <module>
    main()
  File "C:\Users\Andrea\Development\HDR-BiTNet\test.py", line 217, in main
    curr_psnr = compute_psnr(HDR_pred_ori, HDR_img_ori, 1023)
  File "C:\Users\Andrea\Development\HDR-BiTNet\test.py", line 76, in compute_psnr
    mse = np.mean(np.square(img_orig - img_out))
ValueError: operands could not be broadcast together with shapes (3,7680,4320) (3,3840,2160)

Here is my test.yml


#### general settings

name: InvHDR_ResUnit_test
use_tb_logger: False
model: InvHDR
scale: 2
gpu_ids: [0]

#### datasets

datasets:
  train:
    name: SIDD
    mode: JSH_train
    dataroot_HDR: './train/HDR_youtube_80.mat' # path to training Clean images
    dataroot_SDR: './train/SDR_youtube_80.mat' # path to training Noisy images

    use_shuffle: true
    n_workers: 8  # per GPU
    batch_size: 8
    use_flip: true
    use_rot: true

  val:
    name: SIDD_val
    mode: JSH_val
    dataroot_SDR: './testdata/testset_SDR.mat' # path to validation Clean images
    dataroot_HDR: './testdata/testset_HDR.mat' # path to validation Noisy images

#### network structures

network_G:
  which_model_G:
      subnet_type: Resnet
      subnet_type_sgt: AFF
  in_nc: 3
  out_nc: 3
  block_num: [8, 8]
  scale: 2

#### path

path:
  root:
  pretrain_model_G: './model.pth'
  strict_load: true
  resume_state: ~

#### training settings: learning rate scheme, loss

train:
  lr_G: !!float 1e-4
  beta1: 0.9
  beta2: 0.999
  niter: 600000
  warmup_iter: -1  # no warm up

  lr_scheme: MultiStepLR
  lr_steps: [50000, 100000, 150000, 200000, 500000]
  lr_gamma: 0.5

  pixel_criterion_forw: l2
  pixel_criterion_back: l1

  manual_seed: 10

  val_freq: !!float 2000

  vgg16_model:

  lambda_fit_forw: 10
  lambda_vgg_forw: 0.
  lambda_structure_forw: 1
  lambda_orth_forw: 1

  lambda_rec_back: 1
  lambda_structure_back: 1
  lambda_orth_back: 1

  weight_decay_G: !!float 1e-8
  gradient_clipping: 10

#### logger

logger:
  print_freq: 1
  save_checkpoint_freq: !!float 5000
mdyao commented 5 months ago

Hi @jasminsehic.

Based on the error message from the code, it seems that the resolution of img_orig is twice that of 4K, while img_out is at 4K resolution.

My code aims to convert LR-SDR to HR-HDR (or vice versa), thus involving changes in resolution.

The expected input-output scenario should be as follows:

  1. When converting from LR-SDR to HR-HDR, the network's input should be one frame of LR-SDR, and the output should be one frame of HR-HDR.
  2. When converting from HR-HDR to LR-SDR, the network's input should be one frame of HR-HDR, and the output should be one frame of LR-SDR.
  3. When converting from HR-HDR to HR-HDR,the network's input should be one frame of HR-HDR, and the output should be one frame of HR-HDR.

Currently, I'm not convenient to run the code. Could you please help verify the resolutions of the ''input frame'', img_orig, and img_out?

I think the solution is concealed within the resolution.

Thank you!

daliv06 commented 1 month ago

hello! I checked the shape of these data, and found that in the get_current_visuals, the shape of self.fake.H is already (3,7680,4320), which causes the shape of the later HDR_pred to also change, which is inconsistent with the shape of the HDR_img_ori (3, 3840, 2160), how to solve this? Could this be a problem with net_G structure? image image image