Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import requests
|
| 3 |
import io
|
| 4 |
from PIL import Image
|
|
@@ -6,24 +7,12 @@ from transformers import pipeline
|
|
| 6 |
from torchvision import transforms
|
| 7 |
|
| 8 |
title = "Fine Tuned SD Model - Authoral stylization"
|
| 9 |
-
description = "
|
| 10 |
article = "<p style='text-align: center'><a href='https://news.machinelearning.sg/posts/beautiful_profile_pics_remove_background_image_with_deeplabv3/'>Blog</a> | <a href='https://github.com/eugenesiow/practical-ml'>Github Repo</a></p>"
|
| 11 |
|
| 12 |
|
| 13 |
gr.Interface.load(
|
| 14 |
-
"spaces/
|
| 15 |
-
|
| 16 |
-
inputs=[gr.Image(label="Input Image", source="webcam")]
|
| 17 |
-
).launch()
|
| 18 |
-
|
| 19 |
-
def greet(name):
|
| 20 |
-
return "Hello " + name + "!!"
|
| 21 |
-
|
| 22 |
-
with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
| 23 |
-
name = gr.Textbox(label="Name")
|
| 24 |
-
output = gr.Textbox(label="Output Box")
|
| 25 |
-
greet_btn = gr.Button("Greet")
|
| 26 |
-
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
|
| 27 |
|
| 28 |
demo = gr.Interface(
|
| 29 |
fn=greet,
|
|
@@ -31,4 +20,23 @@ demo = gr.Interface(
|
|
| 31 |
outputs="text",
|
| 32 |
)
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import transforms
|
| 3 |
import requests
|
| 4 |
import io
|
| 5 |
from PIL import Image
|
|
|
|
| 7 |
from torchvision import transforms
|
| 8 |
|
| 9 |
title = "Fine Tuned SD Model - Authoral stylization"
|
| 10 |
+
description = "Generate images trained in an authoral illustration model."
|
| 11 |
article = "<p style='text-align: center'><a href='https://news.machinelearning.sg/posts/beautiful_profile_pics_remove_background_image_with_deeplabv3/'>Blog</a> | <a href='https://github.com/eugenesiow/practical-ml'>Github Repo</a></p>"
|
| 12 |
|
| 13 |
|
| 14 |
gr.Interface.load(
|
| 15 |
+
"spaces/Cacau/heart-of-painting",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
demo = gr.Interface(
|
| 18 |
fn=greet,
|
|
|
|
| 20 |
outputs="text",
|
| 21 |
)
|
| 22 |
|
| 23 |
+
|
| 24 |
+
with gr.Blocks(theme=gr.themes.Glass()) as demo:
|
| 25 |
+
inputs=[gr.Textbox(label="Prompt", source="input box")]
|
| 26 |
+
output=[gr.Ima]
|
| 27 |
+
).launch()
|
| 28 |
+
|
| 29 |
+
def query(payload):
|
| 30 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
| 31 |
+
return response.content
|
| 32 |
+
image_bytes = query({
|
| 33 |
+
"inputs":gr.Textbox(lines=2, placeholder="Your prompt here..."),
|
| 34 |
+
})
|
| 35 |
+
|
| 36 |
+
# You can access the image with PIL.Image for example
|
| 37 |
+
import io
|
| 38 |
+
from PIL import Image
|
| 39 |
+
image = Image.open(io.BytesIO(image_bytes))
|
| 40 |
+
|
| 41 |
+
return "This is your generated image:" + image "**Save it in your files!"
|
| 42 |
demo.launch()
|