Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,30 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
model = "Blane187/memcho-s1-ponyxl-lora-nochekaiser"
|
4 |
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
demo = gr.load(
|
11 |
-
model,
|
12 |
-
title="Mem-Cho, PonyXL lora stable diffusion",
|
13 |
-
description="see triger word here https://huggingface.co/Blane187/memcho-s1-ponyxl-lora-nochekaiser",
|
14 |
-
src="models",
|
15 |
-
theme="Blane187/fuchsia",
|
16 |
-
examples=examples,
|
17 |
-
)
|
18 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import requests
|
3 |
+
from PIL import Image
|
4 |
+
import io
|
5 |
+
import os
|
6 |
|
|
|
7 |
|
8 |
+
API_URL = "https://api-inference.huggingface.co/models/Blane187/memcho-s1-ponyxl-lora-nochekaiser"
|
9 |
+
API_TOKEN = os.getenv("HF_READ_TOKEN")
|
10 |
|
11 |
+
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
12 |
+
|
13 |
+
def query(inputs):
|
14 |
+
response = requests.post(API_URL, headers=headers, json={"inputs": inputs})
|
15 |
+
image_bytes = response.content
|
16 |
+
image = Image.open(io.BytesIO(image_bytes))
|
17 |
+
return image
|
18 |
+
|
19 |
+
with gr.Blocks(theme="Hev832/niceandsimple") as demo:
|
20 |
+
gr.Markdown("# memcho-s1-ponyxl-lora-nochekaiser")
|
21 |
+
|
22 |
+
with gr.Row():
|
23 |
+
prompt_input = gr.Textbox(label="Enter a prompt", placeholder="Astronaut riding a horse")
|
24 |
+
generate_btn = gr.Button("Generate Image")
|
25 |
+
|
26 |
+
output_image = gr.Image(label="Generated Image")
|
27 |
+
|
28 |
+
generate_btn.click(fn=query, inputs=prompt_input, outputs=output_image)
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
demo.launch()
|