Kvikontent's picture
Create app.py
f44bc37 verified
raw
history blame
1.93 kB
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')