Giter Site home page Giter Site logo

videnn's Introduction

ViDeNN: Deep Blind Video Denoising

This repository contains my master thesis project called ViDeNN - Deep Blind Video Denoising.

Paper

http://openaccess.thecvf.com/content_CVPRW_2019/papers/NTIRE/Claus_ViDeNN_Deep_Blind_Video_Denoising_CVPRW_2019_paper.pdf

Introduction

With this pretrained tensorflow model you will be able to denoise videos affected by different types of degradation, such as Additive White Gaussian Noise and videos in Low-Light conditions. The latter has been tested only on one particular camera raw data, so it might not work on different sources. ViDeNN works in blind conditions, it does not require any information over the content of the input noisy video. IMPORTANT! If you want to denoise data affected by Gaussian noise (AWGN), it has to be clipped between 0 and 255 before denoising it, otherwise you will get strange artifacts in your denoised output.

Quickstart

Installation

  1. Clone or download and uncompress this repo.
  2. Open a terminal to the downloaded directory.
  3. Using a Python version under or equal to 3.6 (<= Python3.6) install the dependencies: pip install -r requirements.txt

If you intend to use your graphic card (GPU) to make the process faster, don't forget to install the related API (e.g CUDA for NVIDIA devices).

Video Denoising

  1. As the denoiser works only with image sequences, you must export them into a directory first. You can do it with any editing software. Prefer non-destructive formats like png.

    • Using ffmpeg: ffmpeg -nostats -loglevel 0 -i /path/to/my/video /path/to/my/images/%04d.png
  2. Run the denoiser: python main_ViDeNN.py --use_gpu=1 --checkpoint_dir=ckpt_videnn --save_dir='/path/to/my/denoised_images' --test_dir='/path/to/my/images/'

    • --use_gpy:
      • 0: CPU (default)
      • 1: GPU (faster but will be used only if the device has enough memory)
    • --checkpoint_dir:
      • ckpt_vidcnn: uses a mixture of noises, containing AWGN, realistic and low-light noise but can generate some artefacts.
      • ckpt_vidcnn-g: trained with AWGN only, with standard deviation in range [0:55].
  3. You should see your images being processed.

⚠️ The network has not been trained for general-purpose denoising of compressed (h264, h265 ecc) videos. The denoising process requires a lot of memory, if you don't have a GPU with enough memory available, try to set --use_gpu=0 and denoise using CPU, or downscale/crop the video.

Use denoised output

Once the denoising is achieved, you can use the image sequence as it is in an editing software but it could be very heavy to handle. The best solution is to encode the images back to the source format with any encoder or editor.

Using ffmpeg: ffmpeg -i /path/to/my/denoised_images/%04d.png /path/to/denoised.mp4

Train the model

Architecture

ViDeNN is a fully convolutional neural network and can denoise all different sizes of video, depending on the available memory on your machine.

Requirements

from apt:
ffmpeg
unrar

You need at least 25GB of free disk space for training. The code has been tested with Python 2.7. Edit : As of 20th May, this code works with Python 3 as well.

Windows Users

Please check this issue #19 if you have problems with the code. The code has been developed and tested on Linux/Ubuntu, but Windows has a different path structure, using \ instead of /.

Training

The training process is divided in two steps (see the paper for more details)

  1. Spatial-CNN training
 $ cd Spatial-CNN
 $ sh dataset_preparation.sh
  • The dataset preparation script downloads the image dataset and prepare the correct folder structure, running it once is enough.
 $ python add_noise_spatialCNN.py
  • This script creates clean-noisy samples adding noise. Currently AWGN noise is implemented. (There is also realistic_noise function if you want to play with it).
 $ python generate_patches_spatialCNN.py
  • This script generates the 50x50 clean-noisy patches which will be used for training. They will be stored in two big binary files, which will be loaded in your ram during training.
 $ python main_spatialCNN.py
  • This starts training, storing a checkpoint every epoch. Check the available arguments with python main_spatialCNN.py -h if you want to set the number of epochs, learning rate, batch size etc. If you want to fine tune the pre-trained AWGN model use:
 python main_spatialCNN.py --checkpoint_dir=ckpt_awgn --epoch=500
  1. Temp3-CNN training
 $ cd Temp3-CNN
 $ python add_noise_temp3-CNN.py --download_videos=1
  • This will automatically download the videos used for training. If you want to run it a second time just set --download_videos=0 .
 $ cd ../Spatial-CNN
 $ python main_spatialCNN.py --phase=test_temp
  • This will spatially denoise the frames we previously generated, which will be used to train Temp3-CNN.
 $ cd ../Temp3-CNN
 $ python generate_patches_temp3CNN.py
  • This script generates triplets of 50x50 clean-noisy patches from 3 consecutive frames which will be used for temporal denoising training.
 $ python main_temp3CNN.py
  • This starts training, storing a checkpoint every epoch. Check the available arguments with python main_spatialCNN.py -h if you want to set the number of epochs, learning rate, batch size etc.

Testing

Important: the network has not been trained for general-purpose denoising of compressed (h264, h265 ecc) videos. If the output includes some artifacts try to use the other checkpoint, modifying the last line of the script with --checkpoint_dir='./ckpt_vidcnn-g'. The denoising process requires a lot of memory, if you don't have a GPU with enough memory available, try to set --use_gpu=0 and denoise using CPU, or downscale/crop the video. If you have a noisy video file, you can use the script calling it in a terminal:

$ sh denoise.sh video_file_path

It will first extract all the frames using FFmpeg and then start ViDeNN to perform blind video denoising.

Future development

  • Dynamic loading of training data to overcome memory limitations.
  • Porting to Keras and Tensorflow 2.0

Issues?

Feel free to open an issue if you have any problem, I will do my best to help you.

videnn's People

Contributors

clausmichele avatar ojasviyadav avatar tilix4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

videnn's Issues

about add noise

Hi,when run python add_noise_spatialCNN.py and python add_noise_temp3-CNN.py ,the added noise type is gaussian noise only,doesn't add realistic noise.May I ask if the pre-training model you provided is also trained with gaussian noise only?
The description in your paper is 'Half of the images are being added with AWGN with σ=[0,55]. The second half are processed with equation 2 which is the realistic noise model, with Analog Gain Ag=[0,64] and Digital Gain Dg=[0,32]'.

Denoise code

I see that in your code you are using
noisyin2[0,:,:,0:3] = out[0,0] noisyin2[0,:,:,3:6] = out[0,0] noisyin2[0,:,:,6:] = out[0,1]

in class Videnn, denoise...
why not adding the third frame output and repeating 1st frame???

The denoising effect is abnormal

when run ‘python main_ViDeNN.py --use_gpu=1 --checkpoint_dir=ckpt_videnn --save_dir='./test_data/result/frame1_videnn' --test_dir='./test_data/test/frame1'’,the image after denoising is abnormal.
original image
02991
denoised iamge
0000
excuse me, what is the reason?

De-noising effect not visible

I tried to use the model to denoise an analog video feed. The results are not convincing, in fact I don't see any difference between noisy and denoised images. Are the additional steps to take to improve the performance?

Here one example

noisy_1
denoised_1

Another example
noisy_2
denoised_2

As the images before and after are fine (without the noise lines), I was expecting that the temporal denoising removes these lines. Is this a wrong expectation?

There is questions about adding noise

Hello ! Your work is excellent ! I have some questions about adding noise to clean image. Should I first change the range[0,255] to [0,1] ? And then add noise at pixel level?

Use pathlib for paths (and drop python2 support)

As you probably know, Python 2 is deprecated. Also, pathlib is a great way to handle paths and because I've faced issues with paths using two different OS, I'd like to fix them using this lib, which means dropping python2 support.

If you agree I'll propose a PR.

Test has no attribute 'astype'

Hi,

While executing the following command:

$ python main.py --ckpt_dir=./ckpt_vidcnn-g --use_gpu=0

I get the following error:

CPU

[*] Initialize model successfully...
[*] Reading checkpoint...
Traceback (most recent call last):
  File "main.py", line 57, in <module>
    tf.app.run()
  File "C:\Users\nag\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
    _sys.exit(main(argv))
  File "main.py", line 53, in main
    vidcnn_test(model)
  File "main.py", line 32, in vidcnn_test
    vidcnn.test(noisy_files, orig_files, ckpt_dir=args.ckpt_dir, save_dir='./data/denoised')
  File "D:\00-code\VidCNN---Learning-Blind-Video-Denoising\model_vidcnn.py", line 64, in test
    test = test.astype(np.float32) / 255.0
AttributeError: 'NoneType' object has no attribute 'astype'

However, if I execute:

$ sh denoise.sh

It runs normally:

VidCNN - Learning Blind Video Denoising
[*] Insert the video file name you want to denoise:
icuts-video-1-suture_left.mov
mkdir: cannot create directory ‘noisy’: File exists
[*] Extracting frames to the Noisy folder...
ffmpeg version N-92539-g1035206102 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181017
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg--enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 24.101 / 56. 24.101
  libavcodec     58. 40.100 / 58. 40.100
  libavformat    58. 23.100 / 58. 23.100
  libavdevice    58.  6.100 / 58.  6.100
  libavfilter     7. 46.100 /  7. 46.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './icuts-video-1-suture_left.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    encoder         : Lavf56.15.102
  Duration: 00:00:20.25, start: 0.000000, bitrate: 1239 kb/s
    Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 1237 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 2997 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> png (native))
Press [q] to stop, [?] for help
Output #0, image2, to './noisy/%04d.png':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    encoder         : Lavf58.23.100
    Stream #0:0(eng): Video: png, rgb24, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.40.100 png
frame=  374 fps=116 q=-0.0 Lsize=N/A time=00:00:12.47 bitrate=N/A speed=3.88x
video:84405kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

The video that I want to denoise, is extracted into frames in the following directory:
..\VidCNN---Learning-Blind-Video-Denoising\noisy

Please guide me in executing the program through the script main.py

Thank you!

Realistic Noise Model

Hi~

When I use the function "realistic_noise()", there is a problem of divided by 0.

M=np.sqrt( ((Ag*Dg)/(Nsat*image)+(Dg**2)*((Ag * CT1 + CT2)**2)))

How to calculate it if there is a pixel with value 0?

IndexError: list index out of range

I upgraded the code to tensorflow 2 with tf_upgrade_v2 because I wasn't able to run the code without, then I've been able to download and generate noised images and train the spatialCNN to an average PSNR of 32.34 following your steps up to python main_spatialCNN.py --phase=test_temp
Then I got this outputs:

F:\MyData\Git\ViDeNN-2\Spatial-CNN>python main_spatialCNN.py --phase=test_temp
2021-06-04 07:48:16.916830: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll
GPU

2021-06-04 07:48:28.745326: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-06-04 07:48:28.768121: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library nvcuda.dll
2021-06-04 07:48:28.837217: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1733] Found device 0 with properties:
pciBusID: 0000:07:00.0 name: NVIDIA GeForce RTX 3080 computeCapability: 8.6
coreClock: 1.785GHz coreCount: 68 deviceMemorySize: 10.00GiB deviceMemoryBandwidth: 707.88GiB/s
2021-06-04 07:48:28.837354: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll
2021-06-04 07:48:29.497184: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublas64_11.dll
2021-06-04 07:48:29.497294: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cublasLt64_11.dll
2021-06-04 07:48:29.937941: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cufft64_10.dll
2021-06-04 07:48:30.017723: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library curand64_10.dll
2021-06-04 07:48:30.298235: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cusolver64_11.dll
2021-06-04 07:48:30.580547: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cusparse64_11.dll
2021-06-04 07:48:30.612636: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudnn64_8.dll
2021-06-04 07:48:30.625687: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1871] Adding visible gpu devices: 0
2021-06-04 07:48:33.146814: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1258] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-06-04 07:48:33.146933: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1264]      0
2021-06-04 07:48:33.147929: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1277] 0:   N
2021-06-04 07:48:33.186170: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1418] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 7168 MB memory) -> physical GPU (device: 0, name: NVIDIA GeForce RTX 3080, pci bus id: 0000:07:00.0, compute capability: 8.6)
F:\python3.9\lib\site-packages\tensorflow\python\keras\legacy_tf_layers\convolutional.py:414: UserWarning: `tf.layers.conv2d` is deprecated and will be removed in a future version. Please Use `tf.keras.layers.Conv2D` instead.
  warnings.warn('`tf.layers.conv2d` is deprecated and '
F:\python3.9\lib\site-packages\tensorflow\python\keras\engine\base_layer_v1.py:1692: UserWarning: `layer.apply` is deprecated and will be removed in a future version. Please use `layer.__call__` method instead.
  warnings.warn('`layer.apply` is deprecated and '
F:\python3.9\lib\site-packages\tensorflow\python\keras\legacy_tf_layers\normalization.py:307: UserWarning: `tf.layers.batch_normalization` is deprecated and will be removed in a future version. Please use `tf.keras.layers.BatchNormalization` instead. In particular, `tf.control_dependencies(tf.GraphKeys.UPDATE_OPS)` should not be used (consult the `tf.keras.layers.BatchNormalization` documentation).
  warnings.warn(
2021-06-04 07:48:33.383608: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1733] Found device 0 with properties:
pciBusID: 0000:07:00.0 name: NVIDIA GeForce RTX 3080 computeCapability: 8.6
coreClock: 1.785GHz coreCount: 68 deviceMemorySize: 10.00GiB deviceMemoryBandwidth: 707.88GiB/s
2021-06-04 07:48:33.383739: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1871] Adding visible gpu devices: 0
WARNING:tensorflow:From F:\python3.9\lib\site-packages\tensorflow\python\keras\layers\normalization.py:534: _colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
W0604 07:48:33.418567 10008 deprecation.py:330] From F:\python3.9\lib\site-packages\tensorflow\python\keras\layers\normalization.py:534: _colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
[*] Initialize model successfully...
[*] Reading checkpoint...
INFO:tensorflow:Restoring parameters from ./ckpt\Spatial-CNN-276150
I0604 07:48:37.203566 10008 saver.py:1298] Restoring parameters from ./ckpt\Spatial-CNN-276150
 [*] Load weights SUCCESS...
Traceback (most recent call last):
  File "F:\MyData\Git\ViDeNN-2\Spatial-CNN\main_spatialCNN.py", line 101, in <module>
    tf.compat.v1.app.run()
  File "F:\python3.9\lib\site-packages\tensorflow\python\platform\app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "F:\python3.9\lib\site-packages\absl\app.py", line 303, in run
    _run_main(main, args)
  File "F:\python3.9\lib\site-packages\absl\app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "F:\MyData\Git\ViDeNN-2\Spatial-CNN\main_spatialCNN.py", line 80, in main
    denoiser_for_temp3_training(model)
  File "F:\MyData\Git\ViDeNN-2\Spatial-CNN\main_spatialCNN.py", line 58, in denoiser_for_temp3_training
    denoiser.test(noisy_eval_files, eval_files, ckpt_dir=args.ckpt_dir, save_dir='../Temp3-CNN/data/train/denoised/')
  File "F:\MyData\Git\ViDeNN-2\Spatial-CNN\model_spatialCNN.py", line 135, in test
    noisy = cv2.imread(eval_data_noisy[idx])
IndexError: list index out of range

Do you have an idea of what is the problem ?

Not work for single image

hi~

in you paper ,you said "this architecture can achieve state-of-art results for Gaussian denoising" in 3.1. Spatial Denoising CNN. But I received weak denoising effect while only try three frames of same images with Gaussian noise.

Could you explain this situation, thanks very much!

unexpected keyword "labels"

Going through the documentation, when I get to running main_temp3CNN.py I get the following errors.

2023-09-27 01:16:46.861651: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0.
2023-09-27 01:16:46.911723: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-09-27 01:16:47.934225: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
GPU

2023-09-27 01:16:51.034872: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:47] Overriding orig_value setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0.
2023-09-27 01:16:51.034925: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1639] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 28359 MB memory: -> device: 0, name: NVIDIA A100-SXM4-40GB, pci bus id: 0000:00:04.0, compute capability: 8.0
/content/drive/MyDrive/ViDeNN/Temp3-CNN/model_temp3CNN.py:16: UserWarning: tf.layers.conv2d is deprecated and will be removed in a future version. Please Use tf.keras.layers.Conv2D instead.
output = tf.compat.v1.layers.conv2d(input, 128, 3, padding='same', activation=tf.nn.leaky_relu)
/content/drive/MyDrive/ViDeNN/Temp3-CNN/model_temp3CNN.py:19: UserWarning: tf.layers.conv2d is deprecated and will be removed in a future version. Please Use tf.keras.layers.Conv2D instead.
output = tf.compat.v1.layers.conv2d(output, 64, 3, padding='same', name='conv%d' % layers, use_bias=False)
/content/drive/MyDrive/ViDeNN/Temp3-CNN/model_temp3CNN.py:22: UserWarning: tf.layers.conv2d is deprecated and will be removed in a future version. Please Use tf.keras.layers.Conv2D instead.
output = tf.compat.v1.layers.conv2d(output, output_channels, 3, padding='same', use_bias=False)
Traceback (most recent call last):
File "/content/drive/MyDrive/ViDeNN/Temp3-CNN/main_temp3CNN.py", line 96, in
tf.compat.v1.app.run()
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/platform/app.py", line 36, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/usr/local/lib/python3.10/dist-packages/absl/app.py", line 308, in run
_run_main(main, args)
File "/usr/local/lib/python3.10/dist-packages/absl/app.py", line 254, in run_main
sys.exit(main(argv))
File "/content/drive/MyDrive/ViDeNN/Temp3-CNN/main_temp3CNN.py", line 74, in main
model = TemporalDenoiser(sess)
File "/content/drive/MyDrive/ViDeNN/Temp3-CNN/model_temp3CNN.py", line 42, in init
self.eva_psnr = tf_psnr(self.Y, self.Y
[:,:,:,3:6])
File "/content/drive/MyDrive/ViDeNN/Temp3-CNN/utilis.py", line 89, in tf_psnr
mse = tf.losses.mean_squared_error(labels=im2 * 255.0, predictions=im1 * 255.0)
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/util/dispatch.py", line 1170, in op_dispatch_handler
result = api_dispatcher.Dispatch(args, kwargs)
TypeError: Got an unexpected keyword argument 'labels'

Everything up until this step worked fine. Any idea what could be the issue?

Strange artefact

I finally been able to train you models on windows and to test a video denoising and I get those strange circle artefact:

https://ibb.co/v1nZY5J

Do you see what is causing them ?

How to use your own checkpoint

I am trying to locate the checkpoint created after you train the model on your own data.

I have tried to test the model with the checkpoint that gets stored during training for Spatial-CNN as well as Temp3-CNN folder.

I'm just a little unsure where exactly does the checkpoint get stored in the format that can be used with main_VideNN.py to test the denoising.

No test data in the specified folder

Thanks for putting out your trained model!

I'm trying to denoise a video that I have. I forked-cloned your repo and then I placed my video in the ../VidCNN---Learning-Blind-Video-Denoising directory and then ran the scrip as follows:

$ sh denoise.sh
VidCNN - Learning Blind Video Denoising
[] Insert the video file name you want to denoise:
icuts-video-1-suture_left
[
] Extracting frames to the Noisy folder...
ffmpeg version N-92539-g1035206102 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20181017
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 24.101 / 56. 24.101
libavcodec 58. 40.100 / 58. 40.100
libavformat 58. 23.100 / 58. 23.100
libavdevice 58. 6.100 / 58. 6.100
libavfilter 7. 46.100 / 7. 46.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
./icuts-video-1-suture_left: No such file or directory
[*] Denoising frames, will be stored in ./data/denoised/
GPU

[*] Initialize model successfully...
[!] Folder with original files not found, PSNR values will be WRONG!
Traceback (most recent call last):
File "main.py", line 48, in
tf.app.run()
File "C:\Users\nag\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
_sys.exit(main(argv))
File "main.py", line 38, in main
vidcnn_test(model)
File "main.py", line 23, in vidcnn_test
vidcnn.test(noisy_files, orig_files, ckpt_dir=args.ckpt_dir, save_dir='./data/denoised')
File "D:\00-code\VidCNN---Learning-Blind-Video-Denoising\model_vidcnn.py", line 48, in test
assert len(noisy_data) != 0, '[!] No test data in the specified folder! Check that contains an original and noisy folder.'
AssertionError: [!] No test data in the specified folder! Check that contains an original and noisy folder.

I get this assertion error. Do I need to place the file in another folder? Please help me out. Thanks in advance!

There are some weird things?

Thanks for your trained model, and I run it on my own video.

As a result, there are some weird things on the image, as shown in the figure.

noisynoisy
denoiseddenoised
noisynoisy
denoisedenoise

What's that? Can you help me?

No Testing Data

I have trained as per the instructions, everything has worked up until the point of testing. No matter what directory I point to I get the following errors:

[] Initialize model successfully...
[
] No original frames found, not printing PSNR values...
2023-09-27 13:54:01.654208: W tensorflow/c/c_api.cc:304] Operation '{name:'temp-block20/conv2d/kernel/Assign' id:1149 op device:{requested: '', assigned: ''} def:{{{node temp-block20/conv2d/kernel/Assign}} = AssignVariableOp[_has_manual_control_dependencies=true, dtype=DT_FLOAT, validate_shape=false](temp-block20/conv2d/kernel, temp-block20/conv2d/kernel/Initializer/stateless_random_uniform)}}' was changed by setting attribute after it was run by a session. This mutation will have no effect, and will trigger an error in the future. Either don't modify nodes after running them or create a new session.
Traceback (most recent call last):
File "/content/drive/MyDrive/ViDeNN/main_ViDeNN.py", line 54, in
tf.compat.v1.app.run()
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/platform/app.py", line 36, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/usr/local/lib/python3.10/dist-packages/absl/app.py", line 308, in run
_run_main(main, args)
File "/usr/local/lib/python3.10/dist-packages/absl/app.py", line 254, in _run_main
sys.exit(main(argv))
File "/content/drive/MyDrive/ViDeNN/main_ViDeNN.py", line 44, in main
ViDeNNDenoise(model)
File "/content/drive/MyDrive/ViDeNN/main_ViDeNN.py", line 31, in ViDeNNDenoise
ViDeNN.denoise(eval_files, eval_files_noisy, print_psnr, args.ckpt_dir, args.save_dir)
File "/content/drive/MyDrive/ViDeNN/model_ViDeNN.py", line 52, in denoise
assert len(eval_files) != 0, '[!] No testing data!'
AssertionError: [!] No testing data!

Am I missing something?

Improve documentation for artists

Hi!

I'm a video artist and tool developer but I've never run a CNN before. Your work is very powerful and I'd like to contribute in my scope.
I've finally managed to make it work after a long roaming time. And the issues I've faced are mostly about a not very user friendly documentation.

I'd propose some improvements, if you accept them I can propose a PR later.

Setup

  • Precise we must use a python <= 3.6 because tensorflow 1.4 isn't available either way.
  • Explicitly say we don't have to train the model ourselves, I've spent a lot of time trying to achieve this step before understanding everything is already there. And I couldn't guess because I'm not familiar with all of these concepts and files.
  • Create a requirements.txt file for pip installation.

Runtime

  • Add a warning if the GPU has been selected but because of not enough memory available, it fell back on the CPU.

NB: I've faced some issues with the paths using the command-line. I'd like to propose a little refactor using pathlib, which makes it only python3 but is efficient. But it's for another issue if you agree.

TensorFlow runtime exception

when I run this command: python main_ViDeNN.py --use_gpu=1 --checkpoint_dir=ckpt_videnn --save_dir='./data/denoised' --test_dir='./data'

I get this exception:
libcublas.so.8.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime

my environment configuration:
tensorflow-gpu == 1.4
cuda 11.2
nvidia driver: 460.39 (GTX 1080)

Traceback:
Traceback (most recent call last):
File "/home/xiangshouyan/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/203.7148.72/plugins/python/helpers/pydev/pydevd.py", line 1477, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/xiangshouyan/anaconda3/envs/ViDeNN/src/video_denoise_ViDeNN/main_ViDeNN.py", line 8, in
import tensorflow as tf
File "/home/xiangshouyan/anaconda3/envs/ViDeNN/lib/python2.7/site-packages/tensorflow/init.py", line 24, in
from tensorflow.python import *
File "/home/xiangshouyan/anaconda3/envs/ViDeNN/lib/python2.7/site-packages/tensorflow/python/init.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "/home/xiangshouyan/anaconda3/envs/ViDeNN/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 72, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/xiangshouyan/anaconda3/envs/ViDeNN/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/xiangshouyan/anaconda3/envs/ViDeNN/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/xiangshouyan/anaconda3/envs/ViDeNN/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory

image

Artifacts when denoising AWGN

Hi! I'm getting loads of artifacts when denoising sequences with AWGN (see a couple of examples of sequences from the DAVIS dataset below) Is this normal? Thanks

image

image

About the Denoised Picture

There are a number of shining white spots in most of pictures in file'denoised' ,I want to know the reasons why they exist.

can I transform the model ViDeNN-tensorflow-0 to onnx?

I am trying to use the model in a video process engine to verify it, before that I need to transform the model into onnx
Can I use a python script like this:

import re
import os
import torch
from utils.network_srmd import SRMD as net

n_channels = 3            # fixed
nc = 128                  # fixed, number of channels
nb = 12                   # fixed, number of conv layers

model_list = ['srmd_x2', 'srmd_x3', 'srmd_x4', 'srmdnf_x2', 'srmdnf_x3', 'srmdnf_x4']
model_pool = 'model_zoo'
output_model_pool = 'onnx_models'


for model_name in model_list:
    sf = [int(s) for s in re.findall(r'\d+', model_name)][0]  # scale factor
    in_nc = 18 if 'nf' in model_name else 19
    model_path = os.path.join(model_pool, model_name+'.pth')
    
    model = net(in_nc=in_nc, out_nc=n_channels, nc=nc, nb=nb, upscale=sf, act_mode='R', upsample_mode='pixelshuffle')
    model.load_state_dict(torch.load(model_path), strict=False)
    model.eval()
    for k, v in model.named_parameters():
        v.requires_grad = False
    x = torch.randn((1, 3, 1, 1))
    k_pca = torch.randn(1, 15, 1, 1)
    m = k_pca.repeat(1, 1, x.size()[-2], x.size()[-1])
    x = torch.cat((x, m), 1)
    if 'nf' not in model_name:  # noise-free SR
        noise_level = torch.zeros(1, 1, 1, 1)
        x = torch.cat((x, noise_level), 1)
    torch_out = torch.onnx._export(model, x, os.path.join(output_model_pool, model_name+".onnx"), export_params=True)
    print("Convert "+ model_name+" success!")

Artifacts even with ckpt_vidcnn-g

Hi!

I used ckpt_vidcnn but it was generating too many artefacts. I read your comments about clipping and my video is in 8bit depth then it cannot be >255 and I still got few artifacts with ckpt_vidcnn-g (I cropped the output):

You can see the foot of the lamp and the top.

Denoised:

denoised.mp4

Source:

source.mp4

(Even with the compression the denoised output is brilliant!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.