Unconditional Image Generation
PyTorch
huggan
gan
geninhu commited on
Commit
3fdff12
1 Parent(s): 06862c6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -1
README.md CHANGED
@@ -19,7 +19,29 @@ This model was trained on a dataset of 124 high-quality Fauvism painting images.
19
  #### How to use
20
 
21
  ```python
22
- # You can include sample code which will be formatted
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  ```
24
 
25
  #### Limitations and bias
 
19
  #### How to use
20
 
21
  ```python
22
+ # Clone this model
23
+ git clone https://huggingface.co/huggan/fastgan-few-shot-fauvism-still-life/
24
+
25
+ def load_generator(model_name_or_path):
26
+ generator = Generator(in_channels=256, out_channels=3)
27
+ generator = generator.from_pretrained(model_name_or_path, in_channels=256, out_channels=3)
28
+ _ = generator.eval()
29
+
30
+ return generator
31
+
32
+ def _denormalize(input: torch.Tensor) -> torch.Tensor:
33
+ return (input * 127.5) + 127.5
34
+
35
+ # Load generator
36
+ generator = load_generator("fastgan-few-shot-fauvism-still-life")
37
+
38
+ # Generate a random noise image
39
+ noise = torch.zeros(1, 256, 1, 1, device=device).normal_(0.0, 1.0)
40
+ with torch.no_grad():
41
+ gan_images, _ = generator(noise)
42
+
43
+ gan_images = _denormalize(gan_images.detach())
44
+ save_image(gan_images, "sample.png", nrow=1, normalize=True)
45
  ```
46
 
47
  #### Limitations and bias