Spaces:
Sleeping
Sleeping
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, | |
}) | |
st.text(image_bytes) | |
# if(image_bytes): | |
# image = Image.open(io.BytesIO(image_bytes)) | |
# st.image(image, caption="Image generated by the model", use_column_width=True) |