File size: 778 Bytes
a49be05
692811e
a49be05
692811e
 
a49be05
 
 
78b0594
155afaf
a49be05
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0192ba4
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
import streamlit as st
import os
import requests
import io
from PIL import Image

st.title("Cinematic Text-to-Image Generation")
st.write("Enter text and generate cinematic photo. Optional tag is POV")
prompt = st.text_input("Enter prompt")
hf_token = os.environ.get("api_token")
headers = {"Authorization": f"Bearer {hf_token}"}
API_URL = "https://api-inference.huggingface.co/models/TheLastBen/Filmic"

def query(payload):
  response = requests.post(API_URL, headers=headers, json=payload)
  return response.content
    
def generate_image(input_text):
    image_bytes = query({
        "inputs": input_text,
    })
    image = Image.open(io.BytesIO(image_bytes))
    return image

if prompt:
    output = generate_image(prompt)
    st.image(output, caption="Generated image")