Kvikontent commited on
Commit
a49be05
·
verified ·
1 Parent(s): 1a20742

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+
4
+ st.title("Cinematic Text-to-Image Generation")
5
+ st.write("Enter text and generate cinematic photo. Optional tag is POV")
6
+ prompt = st.input_text("Enter prompt")
7
+ hf_token = os.environ.get("API_TOKEN")
8
+ headers = {"Authorization": f"Bearer {hf_token}"}
9
+ API_URL = "https://api-inference.huggingface.co/models/TheLastBen/Filmic"
10
+
11
+ def query(payload):
12
+ response = requests.post(API_URL, headers=headers, json=payload)
13
+ return response.content
14
+
15
+ def generate_image(input_text):
16
+ image_bytes = query({
17
+ "inputs": input_text,
18
+ })
19
+ image = Image.open(io.BytesIO(image_bytes))
20
+ return image
21
+
22
+ if prompt:
23
+ output = generate_image(prompt)
24
+ st.image(output, caption="Generated image")
25
+ st.download_button("Download", output)