C commited on
Commit
dd42ab6
·
1 Parent(s): 05cb992
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import io
4
+ from PIL import Image
5
+ import os
6
+
7
+
8
+ API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-xl-base-1.0"
9
+
10
+ def query(payload):
11
+ auth_hf_api_token = os.environ.get("AUTH_HF_API_TOKEN")
12
+ authorization = "Bearer " + auth_hf_api_token
13
+ headers = {"Authorization": authorization}
14
+ response = requests.post(API_URL, headers=headers, json=payload)
15
+ return response.content
16
+
17
+ def genImage(character_name, description_of_the_character):
18
+ input = "Create a movie poster for " + character_name + description_of_the_character + "Disney Pixar movie style"
19
+ image_bytes = query({
20
+ "inputs": input,
21
+ })
22
+ image = Image.open(io.BytesIO(image_bytes))
23
+ return image
24
+
25
+ demo = gr.Interface(genImage, inputs=["text", "text"], outputs=["image"])
26
+ demo.launch()