Spaces:
Runtime error
Runtime error
LucyintheSky
commited on
Commit
•
1c0019e
1
Parent(s):
16ca6f9
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import random
|
3 |
+
import requests
|
4 |
+
import io
|
5 |
+
from PIL import Image
|
6 |
+
import os
|
7 |
+
|
8 |
+
API_URL = "https://api-inference.huggingface.co/models/tonyassi/tony-assi-lora-1"
|
9 |
+
headers = {"Authorization": "Bearer " + os.environ.get('TOKEN')}
|
10 |
+
|
11 |
+
def query(payload):
|
12 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
13 |
+
return response.content
|
14 |
+
|
15 |
+
def generate(prompt):
|
16 |
+
image_bytes = query({
|
17 |
+
"inputs": "Tony Assi style " + prompt,
|
18 |
+
"parameters" : { "negative_prompt": "ugly, deformed, bad quality",
|
19 |
+
"seed": random.randint(0,9999999)}
|
20 |
+
})
|
21 |
+
image = Image.open(io.BytesIO(image_bytes))
|
22 |
+
return image
|
23 |
+
|
24 |
+
theme = gr.themes.Base(
|
25 |
+
primary_hue="gray",
|
26 |
+
secondary_hue="gray",
|
27 |
+
neutral_hue="gray",
|
28 |
+
font=['Helvetica', 'ui-sans-serif', 'system-ui', 'sans-serif'],
|
29 |
+
).set(
|
30 |
+
button_large_text_weight='400',
|
31 |
+
input_background_fill='#ffffff',
|
32 |
+
#input_border_width='*block_border_width',
|
33 |
+
#button_primary_background_fill='#ffffff',
|
34 |
+
#button_border_width='*block_border_width',
|
35 |
+
)
|
36 |
+
|
37 |
+
with gr.Blocks(theme=theme) as demo:
|
38 |
+
img = gr.Image(show_label=False, type='pil')
|
39 |
+
textbox = gr.Textbox(show_label=False, placeholder='type your prompt in here')
|
40 |
+
button = gr.Button("generate", variant="primary")
|
41 |
+
button.click(fn=generate, inputs=textbox, outputs=img)
|
42 |
+
textbox.submit(fn=generate, inputs=textbox, outputs=img)
|
43 |
+
|
44 |
+
demo.launch()
|