File size: 749 Bytes
f86b2f2
 
 
 
 
 
5b6119d
eac19d3
5b6119d
f86b2f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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")