Kvikontent commited on
Commit
f44bc37
·
verified ·
1 Parent(s): 2fdfbe7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -0
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+
4
+ hf_token = os.environ("API_TOKEN")
5
+ API_URL_FACE = "https://api-inference.huggingface.co/models/prompthero/linkedin-diffusion"
6
+ API_URL_PIX = "https://api-inference.huggingface.co/models/nerijs/pixel-art-xl"
7
+ API_URL_3D = "https://api-inference.huggingface.co/models/goofyai/3d_render_style_xl"
8
+ API_URL_REAL = "https://api-inference.huggingface.co/models/stablediffusionapi/realistic-vision-v51"
9
+ API_URL_DALLE = "https://api-inference.huggingface.co/models/openskyml/dalle-3-xl"
10
+ API_URL_INKPUNK = "https://api-inference.huggingface.co/models/Envvi/Inkpunk-Diffusion"
11
+ API_URL_DREAM = "https://api-inference.huggingface.co/models/Lykon/dreamshaper-xl-v2-turbo"
12
+ API_URL_COVER = "https://api-inference.huggingface.co/models/Norod78/sxl-laisha-magazine-cover-lora"
13
+
14
+ st.title("✨ Open Text2Image Models Leaderboard")
15
+ st.write("Choose one model to generate image and enter prompt")
16
+ model = st.selectbox(
17
+ 'Model',
18
+ ('Dall-e 3', 'Pixel', '3D Render', 'Realistic', 'Inkpunk', 'Dremscape', 'Magazine-cover', 'Faces')
19
+ )
20
+ prompt = st.text_area('Enter prompt')
21
+ button = st.button('Generate')
22
+
23
+ if model == 'Dall-e 3':
24
+ API_URL = API_URL_DALLE
25
+ elif model == 'Pixel':
26
+ API_URL = API_URL_PIX
27
+ elif model == '3D Render':
28
+ API_URL = API_URL_3D
29
+ elif model == 'Realistic':
30
+ API_URL = API_URL_REAL
31
+ elif model == 'Inkpunk':
32
+ API_URL = API_URL_INKPUNk
33
+ elif model == 'Dremscape':
34
+ API_URL = API_URL_DREAM
35
+ elif model == 'Magazine-cover':
36
+ API_URL = API_URL_COVER
37
+ elif model == 'Faces':
38
+ API_URL = API_URL_FACE
39
+
40
+
41
+ def query(payload):
42
+ response = requests.post(API_URL, headers=headers, json=payload)
43
+ return response.content
44
+
45
+ def generate_image(input_text):
46
+ image_bytes = query({
47
+ "inputs": prompt,
48
+ })
49
+ image = Image.open(io.BytesIO(image_bytes))
50
+ return image
51
+
52
+ if button:
53
+ generated_image = generate_image(prompt)
54
+ st.image(generated_image, caption='Generated Image')