Genmoji / app.py
SpyC0der77's picture
Update app.py
401f757 verified
raw
history blame
1.05 kB
import gradio as gr
from huggingface_hub import InferenceClient
import os
client = InferenceClient("EvanZhouDev/open-genmoji", token=os.getenv("HUGGINGFACE_API_TOKEN"))
# 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)
# Define the event listener for the Enter key press
prompt_input.submit(fn=process, inputs=prompt_input, outputs=image_output)
# Launch the interface
if __name__ == "__main__":
demo.launch(show_error=True)