Spaces:
Running
Running
import streamlit as st | |
import requests | |
import io | |
from PIL import Image | |
#authorization | |
API_URL = "https://api-inference.huggingface.co/models/xinsir/controlnet-union-sdxl-1.0" | |
headers = {"Authorization": "spaces_prototype"} | |
def query(payload): | |
response = requests.post(API_URL, headers=headers, json=payload) | |
return response.content | |
#function to generate image based on the prompt | |
def generate_image(prompt): | |
image_bytes = query({"inputs": prompt}) | |
image = Image.open(io.BytesIO(image_bytes)) | |
return image |