EAM-style / app.py
maialumiaho's picture
Update app.py
eac19d3 verified
raw
history blame
749 Bytes
import streamlit as st
import requests
import io
from PIL import Image
import os
hf_token = os.environ.get("hf_token")
API_URL = "https://api-inference.huggingface.co/models/xinsir/controlnet-union-sdxl-1.0"
headers = {"Authorization": f"Bearer hf_token"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
st.title("text to image model")
st.write("Enter a prompt")
model = st.selectbox(
"choose model",
("stable diffusion")
)
prompt = st.text_input("Enter prompt")
if prompt:
if model == "stable diffusion":
API_URL = API_URL_SD
image_bytes = query({
"inputs": prompt,
})
st.image(image_bytes, caption="Generated image")
st.info("Image generated successfully")