Spaces:
Sleeping
Sleeping
| import os | |
| import asyncio | |
| import prodiapy.aio # Import the async module | |
| import gradio as gr | |
| # Load API key from Hugging Face Secrets | |
| api_key = os.getenv("PRODIA_AI_API") | |
| prodia = prodiapy.aio.Prodia(api_key=api_key) # Initialize async client | |
| async def generate_image(prompt): | |
| job = await prodia.sd.generate(prompt=prompt) | |
| result = await prodia.wait(job) | |
| return result.image_url | |
| demo = gr.Interface( | |
| fn=generate_image, | |
| inputs="text", | |
| outputs="image", | |
| title="Async Prodia Image Generation", | |
| description="Generate images asynchronously using Prodia API.", | |
| ) | |
| demo.queue() | |
| demo.launch() |