Kvikontent commited on
Commit
b162d3f
1 Parent(s): 9ef86a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -4,22 +4,18 @@ from PIL import Image
4
  from io import BytesIO
5
  import os
6
  import requests
 
7
 
8
  st.sidebar.title("Stable Diffusion SDXL-Turbo", help="Made with API")
9
  st.sidebar.subheader("By KVI Kontent")
10
  st.sidebar.write("Choose model and enter prompt")
11
- api_key = os.environ['api_key']
12
- API_URL_DALLE = "https://api-inference.huggingface.co/models/openskyml/dalle-3-xl"
13
- headers = {"Authorization": f"Bearer {api_key}"}
14
 
15
  model = st.sidebar.selectbox("Choose Model", ("prodia", "pollinations", "Dall-e 3"))
16
 
17
  prompt = st.sidebar.text_input("Prompt", "")
18
 
19
- def Dalle_query(payload):
20
- response = requests.post(API_URL_DALLE, headers=headers, json=payload)
21
- return response.content
22
-
23
  if model == "prodia" or model == "pollinations":
24
  try:
25
  resp = Client.create_generation(model, prompt)
@@ -28,8 +24,6 @@ if model == "prodia" or model == "pollinations":
28
  except Exception as e:
29
  st.error(str(e))
30
  elif model == "Dall-e 3":
31
- image_bytes = Dalle_query({
32
- "inputs": prompt
33
- })
34
  image = Image.open(BytesIO(image_bytes))
35
  st.image(image, caption="Generated Image")
 
4
  from io import BytesIO
5
  import os
6
  import requests
7
+ from diffusers import DiffusionPipeline
8
 
9
  st.sidebar.title("Stable Diffusion SDXL-Turbo", help="Made with API")
10
  st.sidebar.subheader("By KVI Kontent")
11
  st.sidebar.write("Choose model and enter prompt")
12
+ pipeline = DiffusionPipeline.from_pretrained("stablediffusionapi/juggernaut-xl-v5")
13
+ pipeline.load_lora_weights("openskyml/dalle-3-xl")
 
14
 
15
  model = st.sidebar.selectbox("Choose Model", ("prodia", "pollinations", "Dall-e 3"))
16
 
17
  prompt = st.sidebar.text_input("Prompt", "")
18
 
 
 
 
 
19
  if model == "prodia" or model == "pollinations":
20
  try:
21
  resp = Client.create_generation(model, prompt)
 
24
  except Exception as e:
25
  st.error(str(e))
26
  elif model == "Dall-e 3":
27
+ image_bytes = pipeline(prompt)
 
 
28
  image = Image.open(BytesIO(image_bytes))
29
  st.image(image, caption="Generated Image")