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)