File size: 957 Bytes
f659518
 
 
 
 
 
4878b34
 
f659518
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4878b34
f659518
 
 
5109866
 
 
 
f659518
 
 
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
import streamlit as st
from PIL import Image
import io
import requests
import os 
HF_TOKEN = os.environ["HF_TOKEN"]
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
def query(payload):
	response = requests.post(API_URL, headers=headers, json=payload)
	return response.content


def main():
    st.title(":male-astronaut: Image Generator App :male-astronaut:")

    # Text input box for the user
    text_input = st.text_input("Enter your Imagination :")

    # Button to trigger image generation
    if st.button("Generate Image"):
        # Call image_generator function
        

        
        image_bytes = query({
	"inputs": text_input,
})
        image = Image.open(io.BytesIO(image_bytes))
    
            # Display the generated image
        st.image(image, caption='Generated Image', use_column_width=True)

if __name__ == "__main__":
    main()