Unconditional Image Generation
PyTorch
huggan
gan
File size: 2,185 Bytes
3642089
 
 
 
 
 
 
 
 
 
82a7af9
3642089
 
 
 
 
06862c6
3642089
 
 
 
3fdff12
 
 
 
 
 
 
 
 
 
 
 
 
 
a29c3a1
3fdff12
 
 
 
 
 
 
 
3642089
 
 
 
 
 
 
 
 
 
 
 
64d244f
3642089
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
tags:
- huggan
- gan
# See a list of available tags here:
# https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts#L12
# task: unconditional-image-generation or conditional-image-generation or image-to-image
license: mit
---

# Generate fauvism still life image using FastGAN

## Model description

[FastGAN model](https://arxiv.org/abs/2101.04775) is a Generative Adversarial Networks (GAN) training on a small amount of high-fidelity images with minimum computing cost. Using a skip-layer channel-wise excitation module and a self-supervised discriminator trained as a feature-encoder, the model was able to converge after some hours of training for either 100 high-quality images or 1000 images datasets.

This model was trained on a dataset of 124 high-quality Fauvism painting images.

#### How to use

```python
# Clone this model 
git clone https://huggingface.co/huggan/fastgan-few-shot-fauvism-still-life/

def load_generator(model_name_or_path):
    generator = Generator(in_channels=256, out_channels=3)
    generator = generator.from_pretrained(model_name_or_path, in_channels=256, out_channels=3)
    _ = generator.eval()

    return generator
    
def _denormalize(input: torch.Tensor) -> torch.Tensor:
    return (input * 127.5) + 127.5
    
# Load generator
generator = load_generator("huggan/fastgan-few-shot-fauvism-still-life")

# Generate a random noise image
noise = torch.zeros(1, 256, 1, 1, device=device).normal_(0.0, 1.0)
with torch.no_grad():
  gan_images, _ = generator(noise)
  
gan_images = _denormalize(gan_images.detach())
save_image(gan_images, "sample.png", nrow=1, normalize=True)
```

#### Limitations and bias

* Converge faster and better with small datasets (less than 1000 samples)

## Training data

[few-shot-fauvism-still-life](https://huggingface.co/datasets/huggan/few-shot-fauvism-still-life)

## Generated Images

![Example image](example.png)

### BibTeX entry and citation info

```bibtex
@article{FastGAN,
  title={Towards Faster and Stabilized GAN Training for High-fidelity Few-shot Image Synthesis},
  author={Bingchen Liu, Yizhe Zhu, Kunpeng Song, Ahmed Elgammal},
  journal={ICLR},
  year={2021}
}
```