mpamt commited on
Commit
d004917
1 Parent(s): 7957c63

Initial Commit

Browse files
Files changed (2) hide show
  1. app.py +37 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import hf_hub_download
3
+ import torch
4
+ import matplotlib.pyplot as plt
5
+ import numpy as np
6
+
7
+ path = hf_hub_download('huggan/ArtGAN', 'ArtGAN.pt')
8
+ model = torch.load(path)
9
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
10
+
11
+ def generate(seed):
12
+ with torch.no_grad():
13
+ noise = torch.randn(seed, 100, 1, 1, device=device)
14
+ with torch.no_grad():
15
+ art = model(noise).detach().cpu()
16
+ gen = np.transpose(art[-1], (1, 2, 0))
17
+ fig = plt.figure(figsize=(5, 5))
18
+ plt.imshow(gen)
19
+ plt.axis('off')
20
+ return fig
21
+
22
+ gr.Interface(
23
+ fn=generate,
24
+ inputs=[
25
+ gr.inputs.Slider
26
+ (
27
+ label='noise',
28
+ minimum=10,
29
+ maximum=100,
30
+ step=1,
31
+ default=25
32
+ )
33
+ ],
34
+ outputs=gr.outputs.Image(type='plot'),
35
+ title='ArtGAN',
36
+ description='Generate A Abract Art Using ArtGAN',
37
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio==2.6.4
2
+ huggingface_hub==0.5.1
3
+ matplotlib==3.5.0
4
+ numpy==1.21.4
5
+ torch==1.11.0+cu113