Comments (5)
maybe you can try this code:
# Normalization parameters for pre-trained PyTorch models
mean = np.array([0.485, 0.456, 0.406])
std = np.array([0.229, 0.224, 0.225])
def denormalize(tensors):
""" Denormalizes image tensors using mean and std """
for c in range(3):
tensors[:, c].mul_(std[c]).add_(mean[c])
return torch.clamp(tensors, 0, 255)
if batches_done % opt.sample_interval == 0:
# Save image grid with upsampled inputs and SRGAN outputs
imgs_lr = nn.functional.interpolate(imgs_lr, scale_factor=4)
img_grid = denormalize(torch.cat((imgs_lr, gen_hr), -1))
save_image(img_grid, "images/training/%d.png" % batches_done, nrow=1, normalize=False)
```
in srgan.py
```
class ImageDataset(Dataset):
def __init__(self, root, hr_shape):
hr_height, hr_width = hr_shape
# Transforms for low resolution images and high resolution images
self.lr_transform = transforms.Compose(
[
transforms.Resize((hr_height // 4, hr_height // 4), Image.BICUBIC),
transforms.ToTensor(),
transforms.Normalize(mean, std),
]
)
self.hr_transform = transforms.Compose(
[
transforms.Resize((hr_height, hr_height), Image.BICUBIC),
transforms.ToTensor(),
transforms.Normalize(mean, std),
]
)
self.files = sorted(glob.glob(root + "/*.*"))
def __getitem__(self, index):
img = Image.open(self.files[index % len(self.files)])
img_lr = self.lr_transform(img)
img_hr = self.hr_transform(img)
return {"lr": img_lr, "hr": img_hr}
def __len__(self):
return len(self.files)
```
in datasets.py
from pytorch-gan.
@YUFEI96HE Hm, not sure. Would have to investigate this. Have you tried https://github.com/eriklindernoren/PyTorch-GAN/blob/master/implementations/esrgan/esrgan.py? Should produce better results.
from pytorch-gan.
Good day! I have the same problem, was it managed somehow?
from pytorch-gan.
Good day! I have the same problem, was it managed somehow?
I speculate that the ratio between pixel-wise loss and perceptual loss is too small. You should increase the weight of the pixel-wise loss or decrease the weight of the perceptual loss. I've also encountered this situation. If you have a solution, please let me know. Thank you!
from pytorch-gan.
Alternatively, there is another approach. I speculate that increasing the warmup_batches to ten times its original value might alleviate this issue.
from pytorch-gan.
Related Issues (20)
- plot gradient norm and weight clipping for each layer
- Gradient of a Discriminator in optimizing a Generator HOT 3
- when to save model for inference
- AAE in data augmentation
- buffer in the cyclegan HOT 1
- how test image on original size? (UNIT)
- Can I specify the number of images to be generated? HOT 1
- Query: DCGAN Saving Weights AND Parallelization
- Question about error for context encoder HOT 1
- Query: WGAN-GP FID SCORE (PyTorch) HOT 2
- Cannot download facades dataset for Pix2Pix HOT 4
- A little mistake in acgan HOT 1
- ESRGAN results HOT 2
- Quote GAN HOT 1
- clip_value in WGANGP not used
- ESRGAN datasets.py problem
- 我长期研究和改进GAN,如果对GAN或者深度学习感兴趣的可以联系我,联系方式,wechat: lovedaixiaobaby HOT 2
- Dataset Download Link was changed HOT 1
- Is it possible for the AI (GAN Generative Adversarial Network) to generate exploit codes (in this first version only python) automatically? SueGAN HOT 1
- How to draw the architecture diagram ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch-gan.