from huggingface_hub import InferenceClient import gradio as gr def inference(api_key, prompt): client = InferenceClient( provider="hf-inference", api_key=api_key ) image = client.text_to_image( prompt, model="NeoPy/Panty-Anarchy" ) return image with gr.Blocks() as demo: gr.Markdown("# Text-to-Image Generator using HF Inference API") with gr.Row(): api_key = gr.Textbox(label="Hugging Face API Key") prompt = gr.Textbox(label="Enter Prompt") btn = gr.Button("Generate Image") output_image = gr.Image(label="Generated Image") btn.click(inference, inputs=[api_key, prompt], outputs=output_image) gr.Examples( examples=[ ["Your_HF_API_Key_Here", ", panty anarchy, blonde hair, blue eyes, ahoge, long hair,"] ], inputs=[api_key, prompt] ) demo.launch()