File size: 620 Bytes
c2ce7bd
 
 
f983c19
 
c2ce7bd
e26069d
c2ce7bd
 
f983c19
 
 
 
 
c2ce7bd
f983c19
 
 
 
 
c2ce7bd
f983c19
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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)