Spaces:
Sleeping
Sleeping
Add gr.Workflow app entrypoint
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def stylize(prompt: str) -> str:
|
| 5 |
+
"""Bound Python function exposed as a canvas node.
|
| 6 |
+
|
| 7 |
+
Appends a cinematic style suffix to the prompt before it is
|
| 8 |
+
sent to the Kandinsky Space. Delete the node on the canvas
|
| 9 |
+
(and its edges) if you want raw prompts instead.
|
| 10 |
+
"""
|
| 11 |
+
prompt = (prompt or "").strip()
|
| 12 |
+
if not prompt:
|
| 13 |
+
return prompt
|
| 14 |
+
return f"{prompt}, cinematic lighting, highly detailed, smooth camera motion"
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# gr.Workflow is a complete Gradio app and must be created at top level.
|
| 18 |
+
# graph= loads the saved topology from workflow.json (created on first
|
| 19 |
+
# authorized edit if missing); bind= exposes `stylize` as the fn node
|
| 20 |
+
# named "Stylize Prompt" in the graph.
|
| 21 |
+
app = gr.Workflow(
|
| 22 |
+
graph="workflow.json",
|
| 23 |
+
bind={"Stylize Prompt": stylize},
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
if __name__ == "__main__":
|
| 27 |
+
# Video generation on the Kandinsky Space takes ~4-5 minutes per run,
|
| 28 |
+
# so allow generous queueing.
|
| 29 |
+
app.queue(max_size=32, default_concurrency_limit=2).launch()
|