akhaliq's picture
akhaliq HF Staff
Deploy Gradio app with multiple files
3f6c6eb verified
raw
history blame
2.2 kB
import gradio as gr
from models import generate_image, MODEL_ID
def create_ui():
with gr.Blocks(title=f"Tencent HunyuanImage-3.0 Demo") as demo:
gr.HTML(
f"<div style='text-align: center; max-width: 700px; margin: 0 auto;'>"
f"<h1>Tencent {MODEL_ID.split('/')[-1]}</h1>"
f"<p>Generate images using Tencent's state-of-the-art model hosted by FAL AI.</p>"
f"Built with <a href='https://huggingface.co/spaces/akhaliq/anycoder' target='_blank'>anycoder</a>"
f"</div>"
)
with gr.Row():
with gr.Column(scale=1):
prompt_input = gr.Textbox(
label="Prompt",
placeholder="e.g., Astronaut riding a horse, 4K, realistic photo, cinematic lighting",
lines=4
)
generate_btn = gr.Button("🎨 Generate Image", variant="primary")
with gr.Column(scale=1):
output_image = gr.Image(
label="Generated Image",
height=512,
width=512,
interactive=False,
show_download_button=True
)
# Set up the event listener
generate_btn.click(
fn=generate_image,
inputs=[prompt_input],
outputs=[output_image],
# Use queue and concurrency for robustness when dealing with external APIs
queue=True
)
# Example usage guidance
gr.Examples(
examples=[
"A dramatic black and white photo of a futuristic motorcycle gang leader in a rainy city street.",
"High quality photorealistic close-up portrait of an elderly wizard, highly detailed, dramatic lighting.",
"A detailed watercolor painting of a small red fox sleeping on a pile of autumn leaves."
],
inputs=prompt_input,
outputs=output_image,
fn=generate_image,
cache_examples=False,
)
return demo
if __name__ == "__main__":
app = create_ui()
app.queue()
app.launch()