File size: 928 Bytes
66a500b
da28892
a180f58
da28892
7685695
da28892
80621e1
da28892
 
 
 
f5b81b8
da28892
 
 
 
 
 
 
 
 
 
 
80621e1
da28892
66a500b
da28892
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 gradio as gr
from huggingface_hub import InferenceClient
import os
client = InferenceClient("EvanZhouDev/open-genmoji", token=os.getenv("HUGGINGFACE_API_TOKEN"))

# output is a PIL.Image object

# Define the process function that takes a text prompt and returns an image
def process(prompt):
    image = client.text_to_image(prompt)
    return image

# Create a Gradio Blocks app
with gr.Blocks() as demo:
    # Create a Textbox for the input prompt
    prompt_input = gr.Textbox(label="Enter a prompt")
    # Create an Image component for the output image
    image_output = gr.Image(label="Generated Image")
    # Create a Button to trigger the image generation
    generate_button = gr.Button("Generate Image")
    
    # Define the event listener for the button click
    generate_button.click(fn=process, inputs=prompt_input, outputs=image_output)

# Launch the interface
if __name__ == "__main__":
    demo.launch()