yourusername commited on
Commit
1ed81ba
β€’
1 Parent(s): 68a4df1

:tada: init

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +49 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: Cryptopunks Generator
3
- emoji: πŸ¦€
4
  colorFrom: red
5
  colorTo: indigo
6
  sdk: gradio
 
1
  ---
2
  title: Cryptopunks Generator
3
+ emoji: πŸ§ βž‘οΈπŸ™β€β™€οΈ
4
  colorFrom: red
5
  colorTo: indigo
6
  sdk: gradio
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from huggingface_hub import hf_hub_download
4
+ from torch import nn
5
+ from torchvision.utils import save_image
6
+
7
+
8
+ class Generator(nn.Module):
9
+ def __init__(self, nc=4, nz=100, ngf=64):
10
+ super(Generator, self).__init__()
11
+ self.network = nn.Sequential(
12
+ nn.ConvTranspose2d(nz, ngf * 4, 3, 1, 0, bias=False),
13
+ nn.BatchNorm2d(ngf * 4),
14
+ nn.ReLU(True),
15
+ nn.ConvTranspose2d(ngf * 4, ngf * 2, 3, 2, 1, bias=False),
16
+ nn.BatchNorm2d(ngf * 2),
17
+ nn.ReLU(True),
18
+ nn.ConvTranspose2d(ngf * 2, ngf, 4, 2, 0, bias=False),
19
+ nn.BatchNorm2d(ngf),
20
+ nn.ReLU(True),
21
+ nn.ConvTranspose2d(ngf, nc, 4, 2, 1, bias=False),
22
+ nn.Tanh(),
23
+ )
24
+
25
+ def forward(self, input):
26
+ output = self.network(input)
27
+ return output
28
+
29
+
30
+ model = Generator()
31
+ weights_path = hf_hub_download('nateraw/cryptopunks-gan', 'generator.pth')
32
+ model.load_state_dict(torch.load(weights_path, map_location=torch.device('cpu')))
33
+
34
+
35
+ def predict(text):
36
+ z = torch.randn(64, 100, 1, 1)
37
+ punks = model(z)
38
+ save_image(punks, "punks.png", normalize=True)
39
+ return 'punks.png'
40
+
41
+
42
+ gr.Interface(
43
+ predict,
44
+ inputs="text",
45
+ outputs="image",
46
+ title="InfiniPunks",
47
+ description="These CryptoPunks do not exist.",
48
+ article="<p style='text-align: center'><a href='https://arxiv.org/pdf/1511.06434.pdf'>Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks</a> | <a href='https://github.com/teddykoker/cryptopunks-gan'>Github Repo</a></p>",
49
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ torch
3
+ torchvision