Kvikontent commited on
Commit
849a098
1 Parent(s): 16656a8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import io
4
+ from PIL import Image
5
+ import os
6
+
7
+ hf_token = os.environ.get("hf_token")
8
+ API_URL_KVI = "https://api-inference.huggingface.co/models/Kvikontent/kviimager2.0"
9
+ API_URL_MJ = "https://api-inference.huggingface.co/models/Kvikontent/midjourney-v6"
10
+ API_URL_DALLE = "https://api-inference.huggingface.co/models/ehristoforu/dalle-3-xl"
11
+
12
+ def query(payload):
13
+ response = requests.post(API_URL, headers=headers, json=payload)
14
+ return response.content
15
+
16
+ st.title("Text To Image models")
17
+ st.write("Choose model and enter a prompt")
18
+ model = st.selectbox(
19
+ "Choose model",
20
+ ("KVIImager2.0", "Midjourney V6", "Dalle 3")
21
+ )
22
+ prompt = st.text_input("Enter prompt")
23
+
24
+ if prompt:
25
+ if model == "KVIImager2.0":
26
+ API_URL = API_URL_KVI
27
+ elif model == "Midjourney V6":
28
+ API_URL = API_URL_MJ
29
+ elif model == "Dalle 3":
30
+ API_URL = API_URL_DALLE
31
+ image_bytes = query({
32
+ "inputs": prompt,
33
+ })
34
+ st.image(image_bytes, caption="Generated Image")
35
+ st.info("Image generated successfully!")