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()