Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import InferenceClient
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
def inference(api_key, prompt):
|
5 |
+
client = InferenceClient(
|
6 |
+
provider="hf-inference",
|
7 |
+
api_key=api_key
|
8 |
+
)
|
9 |
+
image = client.text_to_image(
|
10 |
+
prompt,
|
11 |
+
model="NeoPy/Panty-Anarchy"
|
12 |
+
)
|
13 |
+
return image
|
14 |
+
|
15 |
+
with gr.Blocks() as demo:
|
16 |
+
gr.Markdown("# Text-to-Image Generator using HF Inference API")
|
17 |
+
|
18 |
+
with gr.Row():
|
19 |
+
api_key = gr.Textbox(label="Hugging Face API Key", type="password")
|
20 |
+
prompt = gr.Textbox(label="Enter Prompt")
|
21 |
+
|
22 |
+
btn = gr.Button("Generate Image")
|
23 |
+
output_image = gr.Image(label="Generated Image")
|
24 |
+
|
25 |
+
btn.click(inference, inputs=[api_key, prompt], outputs=output_image)
|
26 |
+
|
27 |
+
gr.Examples(
|
28 |
+
examples=[
|
29 |
+
["Your_HF_API_Key_Here", "<lora:panty-anarchy-anime-ponyxl-lora-nochekaiser:1>, panty anarchy, blonde hair, blue eyes, ahoge, long hair,"]
|
30 |
+
],
|
31 |
+
inputs=[api_key, prompt]
|
32 |
+
)
|
33 |
+
|
34 |
+
demo.launch()
|