mlnotes commited on
Commit
ba4694b
1 Parent(s): ae999d7

Add application with examples

Browse files
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Stylish_ape
3
  emoji: 😻
4
  colorFrom: yellow
5
  colorTo: purple
 
1
  ---
2
+ title: Stylish APE
3
  emoji: 😻
4
  colorFrom: yellow
5
  colorTo: purple
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # %%
2
+ import gradio as gr
3
+
4
+ example_generated_ape_super = "examples/generated_ape_super_resolution.jpg"
5
+ example_generated_ape = "examples/generated_ape.png"
6
+ example_stylish_ape = "examples/stylish_ape.png"
7
+ example_style_starry_night = "examples/starry_night.jpeg"
8
+ examples = [
9
+ [example_generated_ape, example_style_starry_night, False],
10
+ ["examples/another_generated_ape.png", "examples/The Scream (1893) by Edvard Munch.jpg", False],
11
+ ["examples/ape02.png", "examples/Self-Portrait Without a Beard (1889) by Vincent van Gogh.jpg", True],
12
+ ["examples/ape03.png", "examples/Oberon, Titania, and Puck with Fairies Dancing (1786) by William Blake.jpg", True],
13
+ ]
14
+
15
+ ape_gen = gr.Interface.load("spaces/ykilcher/apes")
16
+ super_resolution = gr.Interface.load("spaces/akhaliq/SwinIR")
17
+ style_transfer = gr.Interface.load("spaces/aravinds1811/neural-style-transfer")
18
+
19
+ def generate_ape(num_images=1, interpolate=False):
20
+ return ape_gen(num_images, interpolate)
21
+
22
+ def perform_style_transfer(content_image, style_image, is_super_resolution=False):
23
+ stylish_ape = style_transfer(content_image, style_image)
24
+ if is_super_resolution:
25
+ stylish_ape = super_resolution(stylish_ape)
26
+ return stylish_ape
27
+
28
+ # %%
29
+ with gr.Blocks() as demo:
30
+ button_generate_ape = gr.Button("Generate Ape")
31
+
32
+ generated_ape = gr.Image(example_generated_ape, label="Generated Ape", type="filepath")
33
+ style_image_input = gr.Image(example_style_starry_night, label="Stylish Image", type="filepath")
34
+ style_in_super_resolution = gr.Checkbox(True, label="Super resolution!")
35
+ stylish_ape = gr.Image(example_stylish_ape, label="Stylish Ape")
36
+
37
+ gr.Interface(
38
+ fn=perform_style_transfer,
39
+ inputs=[generated_ape, style_image_input, style_in_super_resolution],
40
+ outputs=stylish_ape,
41
+ examples=examples,
42
+ allow_flagging="never",
43
+ )
44
+ with gr.Row():
45
+ gr.Markdown("<a href='https://huggingface.co/spaces/ykilcher/apes' target='_blank'>Apes by ykilcher</a>, style transfer by <a href='https://huggingface.co/spaces/aravinds1811/neural-style-transfer' target='_blank'>Neural Style Transfer</a>, and super resolution by <a href='https://huggingface.co/spaces/akhaliq/SwinIR' target='_blank'>SwinIR</a>.")
46
+
47
+ button_generate_ape.click(generate_ape, inputs=[], outputs=generated_ape)
48
+
49
+ demo.launch(enable_queue=False)
50
+ # %%
Puck with Fairies Dancing (1786) by William Blake.jpg RENAMED
File without changes
examples/Self-Portrait Without a Beard (1889) by Vincent van Gogh.jpg ADDED
examples/The Scream (1893) by Edvard Munch.jpg ADDED
examples/another_generated_ape.png ADDED
examples/ape02.png ADDED
examples/ape03.png ADDED
examples/generated_ape.png ADDED
examples/generated_ape_super_resolution.jpg ADDED
examples/starry_night.jpeg ADDED
examples/stylish_ape.png ADDED
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ torch