Update README.md
Browse files
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 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|