File size: 724 Bytes
233dcde
e54a0d5
40041d3
 
 
 
 
 
e6b153f
40041d3
8da1e7a
e6b153f
 
 
36b5bad
8da1e7a
40041d3
233dcde
40041d3
233dcde
36b5bad
40041d3
 
637bad0
 
 
 
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
# Python
import streamlit as st
import requests
import io
from PIL import Image
import os
from dotenv import load_dotenv
load_dotenv()

API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-cascade-prior"
HEADERS = {"Authorization": f"Bearer ${os.getenv('bearer_token')}"}

st.title("Image Generator with Diffusers")

def query(payload):
	response = requests.post(API_URL, headers=HEADERS, json=payload)
	return response.content

prompt = st.text_input("Enter a prompt:", "batman hitting the griddy in gotham")

image_bytes = query({
	"inputs": prompt,
})

if(image_bytes):
    image = Image.open(io.BytesIO(image_bytes))
    st.image(image, caption="Image generated by the model", use_column_width=True)