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.31k stars 611 forks source link

Number of scale in SinGAN #76

Open lyphilong opened 4 years ago

lyphilong commented 4 years ago

Hello, Thanks for the interesting paper and codes.

I have a question. How do you known number of scale in SinGAN?

Thanks

Lotayou commented 4 years ago

Check this:

# In SINGAN.functions.py

def adjust_scales2image(real_,opt):
    #opt.num_scales = int((math.log(math.pow(opt.min_size / (real_.shape[2]), 1), opt.scale_factor_init))) + 1
    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

Basically you start from the original resolution and scale down by 0.75 until the long side of the downscaled image hits 25.