Skip to content

Commit

Permalink
Update issue templates
Browse files Browse the repository at this point in the history
  • Loading branch information
nurpax authored Mar 18, 2021
1 parent 2506395 commit d4b2afe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. In '...' directory, run command '...'
2. See error (please copy&paste full log and stacktraces).
2. See error (copy&paste full log, including exceptions and **stacktraces**).

Please copy&paste text instead of screenshots for better searchability.

Expand Down

2 comments on commit d4b2afe

@hamedsarlak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import torch
from torchvision.utils import save_image
import legacy

مسیر مدل پیش‌آموزش دیده

network_pkl = "models/ffhq.pkl"

بارگذاری مدل

print('Loading networks from "%s"...' % network_pkl)
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
with open(network_pkl, 'rb') as f:
G = legacy.load_network_pkl(f)['G_ema'].to(device) # type: ignore

تولید تصویر

z = torch.randn([1, G.z_dim]).to(device) # latent vector
label = torch.zeros([1, G.c_dim]).to(device) # class label
img = G(z, label, truncation_psi=0.5, noise_mode='const')

ذخیره تصویر

img = (img + 1) * (255 / 2)
img = img.clamp(0, 255).to(torch.uint8)
img = img.permute(0, 2, 3, 1) # NCHW -> NHWC
img = img[0].cpu().numpy()

ذخیره تصویر به عنوان فایل

save_image(torch.Tensor(img).permute(2, 0, 1), 'generated_image.png')

print("Image generated and saved as generated_image.png")

@hamedsarlak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

سلام

Please sign in to comment.