Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,42 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
-
import transforms
|
3 |
import requests
|
4 |
import io
|
5 |
from PIL import Image
|
6 |
from transformers import pipeline
|
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.
|
15 |
-
|
16 |
|
17 |
-
|
18 |
-
fn=greet,
|
19 |
-
inputs=gr.Textbox(lines=2, placeholder="Name Here..."),
|
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()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import requests
|
3 |
import io
|
4 |
from PIL import Image
|
5 |
from transformers import pipeline
|
|
|
6 |
|
7 |
title = "Fine Tuned SD Model - Authoral stylization"
|
8 |
description = "Generate images trained in an authoral illustration model."
|
9 |
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>"
|
10 |
|
11 |
+
def generate_image(prompt):
|
12 |
+
model = pipeline("image-to-image", model="Cacau/heart-of-painting")
|
13 |
+
return model(prompt)[0]
|
14 |
|
15 |
+
inputs = gr.inputs.Textbox(label="Prompt", placeholder="Your prompt here...")
|
16 |
+
output = gr.outputs.Image(label="Generated Image")
|
17 |
|
18 |
+
gr.Interface(generate_image, inputs, output, title=title, description=description, article=article).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|