Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import prodiapy.aio
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import asyncio
|
| 4 |
+
|
| 5 |
+
async def generate(prompt):
|
| 6 |
+
prodia = prodiapy.aio.Prodia(api_key="your_api_key")
|
| 7 |
+
job = await prodia.sd.generate(prompt=prompt)
|
| 8 |
+
result = await prodia.wait(job)
|
| 9 |
+
return result.image_url
|
| 10 |
+
|
| 11 |
+
def wrapper(prompt):
|
| 12 |
+
return asyncio.run(generate(prompt))
|
| 13 |
+
|
| 14 |
+
demo = gr.Interface(fn=wrapper, inputs="text", outputs="image", title="Async Stable Diffusion", description="Generate images using a prompt asynchronously.")
|
| 15 |
+
demo.launch()
|