File size: 942 Bytes
5a040db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9155d09
5a040db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
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", "<lora:panty-anarchy-anime-ponyxl-lora-nochekaiser:1>, panty anarchy, blonde hair, blue eyes, ahoge, long hair,"]
        ],
        inputs=[api_key, prompt]
    )

demo.launch()