SRGAN icon indicating copy to clipboard operation
SRGAN copied to clipboard

8x upsampling possible?

Open artificialskills opened this issue 7 years ago • 17 comments

Hi, I'd like to train the network on a, 8x down-sampled input/full resolution reference, data set. Is this possible? What modifications are necessary. Thanks a lot.

artificialskills avatar Mar 02 '18 21:03 artificialskills

modify the model and data

zsdonghao avatar Mar 03 '18 10:03 zsdonghao

Can you please be more specific?

artificialskills avatar Mar 03 '18 15:03 artificialskills

for model, add two more sub-pixel convolutional layers. for data, down-sampled the images by 8

zsdonghao avatar Mar 03 '18 17:03 zsdonghao

Ok thanks a lot, so after I add those layers, do I need to add any other plumbing, do I need to change some globals somewhere do use 8 instead of 4?

On Sat, Mar 3, 2018 at 9:59 AM, Hao [email protected] wrote:

for model, add two more sub-pixel convolutional layers. for data, down-sampled the images by 8

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tensorlayer/srgan/issues/65#issuecomment-370167089, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ-yE4WZx84i-n8lUP-6v3NdhIoa_sZHks5tatoHgaJpZM4SagsO .

artificialskills avatar Mar 03 '18 18:03 artificialskills

@artificialskills did you managed to make it work?

perdigas91 avatar Mar 22 '18 09:03 perdigas91

@perdigas91 I didn't try yet, but I'm going to see if I can swing back around and work on it soon, let you know.

artificialskills avatar Mar 22 '18 14:03 artificialskills

Do we need to have different pretrained model for different scale ? like 2x,3x,4x? or, 1 pre-trained model works with other scales ?

rahat-yasir avatar Jun 12 '18 15:06 rahat-yasir

same question with rahat-yasir, if I want to train on my dataset with downsampling factor 2, what modifications (model, parameters, etc) should I make? Thanks!

cauivy avatar Jul 12 '18 03:07 cauivy

@rahat-yasir You need a new model for every scale. @cauivy Adjust model.py by removing one scaling layer

#n = Conv2d(n, 256, (3, 3), (1, 1), act=None, padding='SAME', W_init=w_init, name='n256s1/2')
#n = SubpixelConv2d(n, scale=2, n_out_channel=None, act=tf.nn.relu, name='pixelshufflerx2/2')

In main.py adjust the placeholder variables to fit your desired in and output

t_image = tf.placeholder('float32', [batch_size, 192, 192, 3], name='t_image_input_to_SRGAN_generator')
t_target_image = tf.placeholder('float32', [batch_size, 384, 384, 3], name='t_target_image')

And in utils.py adjust the downsample function

x = imresize(x, size=[192, 192], interp='bicubic', mode=None)

This should be it. Maybe i missed something but don't worry you will get an error if so :)

Obliviously avatar Jul 19 '18 07:07 Obliviously

Thank you very much for your reply!

cauivy avatar Jul 23 '18 03:07 cauivy

@artificialskills To also answer the original question. For 8x upscaling you do it similar, instead of removing a scaling layer you add one. You probably also have to adjust the number of filters in the conv2d layers.

Obliviously avatar Jul 23 '18 09:07 Obliviously

i tried for the 4x upscaling the same program but it throws me alot of exception which i am unable to handle any suggestion

MurtazaNajaf avatar Aug 22 '18 15:08 MurtazaNajaf

I tried 2x upscaling and I found the computation speed is very slow. Is that because the network dimension is 4 times larger than 4x scale's network? Thanks!!!

OdinYue avatar Sep 08 '18 00:09 OdinYue

@Obliviously Thank you for sharing the very concise implementation. I am working on a dataset where the image scale factor from HR/LR is 1.5 and 2.25.
I am having a hard wrapping my head around how would I get it to work on these data. I am limited as the original HR images are in 4:3 aspect ratio and need to be upsampled in the same aspect ratio ..

Any thoughts on how this would come across in the SRGAN model ?

amanmeetgarg avatar Sep 29 '18 00:09 amanmeetgarg

As far as I know you can't do floating point scaling with the given layers. The easiest way of doing it would be to scale it to the the next integer factor and then do a simple bicubic downscaling to your desired size.

The aspect ratio doesnt really matter, because (during training) SRGAN is cropping the image anyway. So this shouldnt concern you.

Obliviously avatar Sep 29 '18 08:09 Obliviously

Hi, also a similar question. I'm working on upscaling by 3x. I have altered my downsample function in utils.py to be

x = imresize(x, size=[144, 144], interp='bicubic', mode=None)

I'm struggling to understand how to change the model to cope with 3x, and what changes need to be made in main.py to account for this. Thanks!!

Ds866 avatar Feb 06 '19 10:02 Ds866

@rahat-yasir You need a new model for every scale. @cauivy Adjust model.py by removing one scaling layer

#n = Conv2d(n, 256, (3, 3), (1, 1), act=None, padding='SAME', W_init=w_init, name='n256s1/2')
#n = SubpixelConv2d(n, scale=2, n_out_channel=None, act=tf.nn.relu, name='pixelshufflerx2/2')

In main.py adjust the placeholder variables to fit your desired in and output

t_image = tf.placeholder('float32', [batch_size, 192, 192, 3], name='t_image_input_to_SRGAN_generator')
t_target_image = tf.placeholder('float32', [batch_size, 384, 384, 3], name='t_target_image')

And in utils.py adjust the downsample function

x = imresize(x, size=[192, 192], interp='bicubic', mode=None)

This should be it. Maybe i missed something but don't worry you will get an error if so :)

Hi @Obliviously I am getting this error when I follow your steps to retrain the model to get 2x: any help, please

ValueError: Dimension 0 in both shapes must be equal, but are 1 and 3. Shapes are [1,1,64,3] and [3,3,64,256]. for 'Assign_169' (op: 'Assign') with input shapes: [1,1,64,3], [3,3,64,256].

Elwarfalli avatar Apr 13 '19 01:04 Elwarfalli