bhadresh-savani commited on
Commit
b72b9a6
1 Parent(s): 931b968

added files

Browse files
Files changed (5) hide show
  1. app.py +23 -0
  2. requirements.txt +1 -0
  3. sample.jpg +0 -0
  4. sample2.jpg +0 -0
  5. sample3.jpg +0 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from torchvision.transforms import Compose, Resize, ToTensor, Normalize
3
+ from PIL import Image
4
+ from torchvision.utils import save_image
5
+
6
+ from huggan.pytorch.pix2pix.modeling_pix2pix import GeneratorUNet
7
+
8
+ transform = Compose(
9
+ [
10
+ Resize((256, 256), Image.BICUBIC),
11
+ ToTensor(),
12
+ Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
13
+ ]
14
+ )
15
+ model = GeneratorUNet.from_pretrained('huggan/pix2pix-map')
16
+
17
+ def predict_fn(img):
18
+ inp = transform(img).unsqueeze(0)
19
+ out = model(inp)
20
+ save_image(out, 'out.png', normalize=True)
21
+ return 'out.png'
22
+
23
+ gr.Interface(predict_fn, inputs=gr.inputs.Image(type='pil'), outputs='image', examples=[['sample.jpg'], ['sample2.jpg'], ['sample3.jpg']]).launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ git+https://github.com/huggingface/community-events@main
sample.jpg ADDED
sample2.jpg ADDED
sample3.jpg ADDED