Rakesh443 commited on
Commit
6afe459
·
verified ·
1 Parent(s): 47c7fe3

Create app.py

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