tamarott / SinGAN

Official pytorch implementation of the paper: "SinGAN: Learning a Generative Model from a Single Natural Image"
https://tamarott.github.io/SinGAN.htm
Other
3.3k stars 612 forks source link

Question about calculating how the number of scales is calculated #123

Open LeviDPC opened 4 years ago

LeviDPC commented 4 years ago

Hey,

Thanks for making such an interesting and cool project. I'm trying to understand how the number of scales used in SinGAN is calculated. This code is from functions.py and I mostly understand what is going on but I have one point of confusion. In the first line why is 1 added onto the opt.num_scales variable. As far as I can tell if you don't add the one you usually end up with a scale_factor that is less than 0.75 but closser to it than the value that you get for scale factor if you do add the one.

opt.num_scales = math.ceil((math.log(math.pow(opt.min_size / (min(real_.shape[2], real_.shape[3])), 1), opt.scale_factor_init))) _**+ 1**_
scale2stop = math.ceil(math.log(min([opt.max_size, max([real_.shape[2], real_.shape[3]])]) / max([real_.shape[2], real_.shape[3]]),opt.scale_factor_init))
opt.stop_scale = opt.num_scales - scale2stop
opt.scale1 = min(opt.max_size / max([real_.shape[2], real_.shape[3]]),1)  # min(250/max([real_.shape[0],real_.shape[1]]),1)
real = imresize(real_, opt.scale1, opt)
#opt.scale_factor = math.pow(opt.min_size / (real.shape[2]), 1 / (opt.stop_scale))
opt.scale_factor = math.pow(opt.min_size/(min(real.shape[2],real.shape[3])),1/(opt.stop_scale))

Thanks! Clefspear99

venkycode commented 3 years ago

Adding to this, i couldn't find where the max_size parameter of opt is initialised. Can you point me to the initialisation in code if you are aware about this?

LeviDPC commented 3 years ago

Adding to this, i couldn't find where the max_size parameter of opt is initialised. Can you point me to the initialisation in code if you are aware about this?

Check out the config.py file. It's in there