File size: 1,099 Bytes
849a098
 
 
 
 
 
 
 
 
 
4eb7d6d
849a098
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st 
import requests
import io
from PIL import Image
import os 

hf_token = os.environ.get("hf_token")
API_URL_KVI = "https://api-inference.huggingface.co/models/Kvikontent/kviimager2.0"
API_URL_MJ = "https://api-inference.huggingface.co/models/Kvikontent/midjourney-v6"
API_URL_DALLE = "https://api-inference.huggingface.co/models/ehristoforu/dalle-3-xl"
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 models")
st.write("Choose model and enter a prompt")
model = st.selectbox(
    "Choose model",
    ("KVIImager2.0", "Midjourney V6", "Dalle 3")
)
prompt = st.text_input("Enter prompt")

if prompt:
    if model == "KVIImager2.0":
        API_URL = API_URL_KVI
    elif model == "Midjourney V6":
        API_URL = API_URL_MJ
    elif model == "Dalle 3":
        API_URL = API_URL_DALLE
    image_bytes = query({
    	"inputs": prompt,
    })
    st.image(image_bytes, caption="Generated Image")
    st.info("Image generated successfully!")