geninhu commited on
Commit
8da29f5
1 Parent(s): c5c634d

Update README.md

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