Spaces:
Sleeping
Sleeping
File size: 1,245 Bytes
6afe459 771240c 6afe459 a3d8132 6afe459 771240c 01c0511 771240c 01c0511 771240c aed2387 0acd57a 6afe459 |
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import streamlit as st
import requests
import io
from PIL import Image
import os
import cv2
import numpy as np
# Create a text input
api_key = os.getenv("ImageGenerating")
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
headers = {"Authorization": "f'Bearer {api_key}"}
user_input = st.text_input("Enter your text here:")
# Process the input (you can replace this with your own logic)
processed_output = user_input.upper()
# Display the processed output
# st.write(f"Processed output: {processed_output}")
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
image_bytes = query({
"inputs": user_input,
})
def bytes_to_image_opencv(image_bytes):
np_arr = np.frombuffer(image_bytes, np.uint8)
image = cv2.imdecode(np_arr, cv2.IMREAD_COLOR)
return image
result_image_opencv = bytes_to_image_opencv(image_bytes)
st.image(result_image_opencv,caption="image")
# image = Image.open(io.BytesIO(image_bytes))
# st.image(image, caption=None, width=None, use_column_width=None, clamp=False, channels="RGB", output_format="PNG")
# st.image(image=image,caption="image")
# st.image(image)
# st.image(image : image,caption=image) |