import streamlit as st import requests import json from PIL import Image import time ngrok_url = st.text_input("Ngrok url") prompt_input = st.text_input("Prompt") if st.button('Generate Image'): payload = json.dumps({"text":prompt_input}) headers = { 'Content-Type': 'text/plain' } response = requests.request("POST", ngrok_url, headers=headers, data=payload) file_name = "static/"+prompt_input+time.strftime("%Y%m%d-%H%M%S")+".png" save_file = open(file_name, "wb") save_file.write(response.content) image = Image.open(file_name) st.image(image, caption=prompt_input)