File size: 1,931 Bytes
f44bc37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import os

hf_token = os.environ("API_TOKEN")
API_URL_FACE = "https://api-inference.huggingface.co/models/prompthero/linkedin-diffusion"
API_URL_PIX = "https://api-inference.huggingface.co/models/nerijs/pixel-art-xl"
API_URL_3D = "https://api-inference.huggingface.co/models/goofyai/3d_render_style_xl"
API_URL_REAL = "https://api-inference.huggingface.co/models/stablediffusionapi/realistic-vision-v51"
API_URL_DALLE = "https://api-inference.huggingface.co/models/openskyml/dalle-3-xl"
API_URL_INKPUNK = "https://api-inference.huggingface.co/models/Envvi/Inkpunk-Diffusion"
API_URL_DREAM = "https://api-inference.huggingface.co/models/Lykon/dreamshaper-xl-v2-turbo"
API_URL_COVER = "https://api-inference.huggingface.co/models/Norod78/sxl-laisha-magazine-cover-lora"

st.title("✨ Open Text2Image Models Leaderboard")
st.write("Choose one model to generate image and enter prompt")
model = st.selectbox(
    'Model',
    ('Dall-e 3', 'Pixel', '3D Render', 'Realistic', 'Inkpunk', 'Dremscape', 'Magazine-cover', 'Faces')
)
prompt = st.text_area('Enter prompt')
button = st.button('Generate')

if model == 'Dall-e 3':
    API_URL = API_URL_DALLE
elif model == 'Pixel':
    API_URL = API_URL_PIX
elif model == '3D Render':
    API_URL = API_URL_3D
elif model == 'Realistic':
    API_URL = API_URL_REAL
elif model == 'Inkpunk':
    API_URL = API_URL_INKPUNk
elif model == 'Dremscape':
    API_URL = API_URL_DREAM
elif model == 'Magazine-cover':
    API_URL = API_URL_COVER
elif model == 'Faces':
    API_URL = API_URL_FACE


def query(payload):
	response = requests.post(API_URL, headers=headers, json=payload)
	return response.content
    
def generate_image(input_text):
    image_bytes = query({
        "inputs": prompt,
    })
    image = Image.open(io.BytesIO(image_bytes))
    return image

if button:
    generated_image = generate_image(prompt)
    st.image(generated_image, caption='Generated Image')