Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
import streamlit as st
|
| 4 |
+
import requests
|
| 5 |
+
import io
|
| 6 |
+
from PIL import Image
|
| 7 |
+
import os
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
# Create a text input
|
| 11 |
+
|
| 12 |
+
API_KEY = os.environ.get("API_KEY2")
|
| 13 |
+
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
|
| 14 |
+
headers = {"Authorization": f"Bearer {API_KEY}"}
|
| 15 |
+
|
| 16 |
+
user_input = st.text_input("Enter your text here:")
|
| 17 |
+
|
| 18 |
+
# Process the input (you can replace this with your own logic)
|
| 19 |
+
processed_output = user_input.upper()
|
| 20 |
+
|
| 21 |
+
# Display the processed output
|
| 22 |
+
# st.write(f"Processed output: {processed_output}")
|
| 23 |
+
def query(payload):
|
| 24 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
| 25 |
+
return response.content
|
| 26 |
+
image_bytes = query({
|
| 27 |
+
"inputs": user_input,
|
| 28 |
+
})
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
image = Image.open(io.BytesIO(image_bytes))
|
| 33 |
+
st.image(image, caption="image", width=None, use_column_width=None, clamp=False, channels="RGB", output_format="auto")
|
| 34 |
+
# st.image(image=image,caption="image")
|
| 35 |
+
# st.image(image)
|
| 36 |
+
# st.image(image : image,caption=image)
|