File size: 1,725 Bytes
c4bca75
d7024bf
 
 
 
e5812b4
d7024bf
 
 
 
 
 
 
 
36771cf
c73d51d
 
 
 
 
 
 
c4bca75
de1a3cf
0aecf3d
 
 
de1a3cf
 
21da889
3280e63
1ecb9d5
59827fa
 
de1a3cf
 
 
046dc7e
884d04c
046dc7e
7a671d0
046dc7e
63e9f9a
8293635
 
 
 
 
 
 
 
046dc7e
de1a3cf
046dc7e
ffd1052
c4bca75
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import gradio as gr
import random
import requests
import io
from PIL import Image
import os

API_URL = "https://api-inference.huggingface.co/models/tonyassi/tony-assi-lora-1"
headers = {"Authorization": "Bearer " + os.environ.get('TOKEN')}

def query(payload):
	response = requests.post(API_URL, headers=headers, json=payload)
	return response.content

def generate(prompt):
    image_bytes = query({
    	"inputs": "Tony Assi style " + prompt,
        "parameters" : { "negative_prompt": "ugly, deformed, bad quality",
                        "seed": random.randint(0,9999999)}
    })
    image = Image.open(io.BytesIO(image_bytes))
    return image

theme = gr.themes.Base(
    primary_hue="gray",
    secondary_hue="gray",
    neutral_hue="gray",
    font=['Helvetica', 'ui-sans-serif', 'system-ui', 'sans-serif'],
).set(
    button_large_text_weight='400',
    input_background_fill='#ffffff',
    #input_border_width='*block_border_width',
    #button_primary_background_fill='#ffffff',
    #button_border_width='*block_border_width',
)

with gr.Blocks(theme=theme) as demo:
    
    img = gr.Image(show_label=False, type='pil')
    
    textbox = gr.Textbox(show_label=False, placeholder='type your prompt in here')
    
    button = gr.Button("generate",  variant="primary")

    gr.Examples(
        [["Kendall Jenner wearing a black mesh outfit with puffy black sleeves"], ["Hunter Schafer wearing a mint green mesh outfit with puffy sleeves"], ["Eva Mendes wearing clear vinyl outfit"]],
        textbox,
        img,
        generate,
        cache_examples=True,
    )
    
    button.click(fn=generate, inputs=textbox, outputs=img)
    
    textbox.submit(fn=generate, inputs=textbox, outputs=img)

demo.launch()