Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
|
1 |
+
# This demo needs to be run from the repo folder.
|
2 |
+
# python demo/fake_gan/run.py
|
3 |
+
import os
|
4 |
+
import random
|
5 |
+
import time
|
6 |
+
|
7 |
import gradio as gr
|
8 |
|
|
|
|
|
9 |
|
10 |
+
def fake_gan(desc, wait):
|
11 |
+
if desc == "NSFW":
|
12 |
+
raise ValueError("NSFW - banned content.")
|
13 |
+
time.sleep(wait)
|
14 |
+
image = random.choice(
|
15 |
+
[
|
16 |
+
"https://images.unsplash.com/photo15070032111690a1dd7228f2dixlib=rb1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80",
|
17 |
+
"https://images.unsplash.com/photo-1554151228-14d9def656e4?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=386&q=80",
|
18 |
+
"https://images.unsplash.com/photo-1542909168-82c3e7fdca5c?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8aHVtYW4lMjBmYWNlfGVufDB8fDB8fA%3D%3D&w=1000&q=80",
|
19 |
+
"https://images.unsplash.com/photo-1546456073-92b9f0a8d413?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80",
|
20 |
+
"https://images.unsplash.com/photo-1601412436009-d964bd02edbc?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=464&q=80",
|
21 |
+
]
|
22 |
+
)
|
23 |
+
return image
|
24 |
+
|
25 |
+
|
26 |
+
demo = gr.Interface(
|
27 |
+
fn=fake_gan,
|
28 |
+
inputs=[gr.Textbox(), gr.Slider(0, 100)],
|
29 |
+
outputs=gr.Image(label="Generated Image"),
|
30 |
+
title="FD-GAN",
|
31 |
+
description="This is a fake demo of a GAN. In reality, the images are randomly chosen from Unsplash.",
|
32 |
+
)
|
33 |
+
demo.queue(max_size=3)
|
34 |
|
35 |
+
if __name__ == "__main__":
|
36 |
+
demo.launch(show_error=True)
|