Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,28 +16,28 @@ class T2VReq(BaseModel):
|
|
| 16 |
text: str = Field(...)
|
| 17 |
negative: Optional[str] = None
|
| 18 |
seed: Optional[int] = None
|
| 19 |
-
steps: Optional[int] =
|
| 20 |
-
cfg: Optional[float] =
|
| 21 |
-
width: Optional[int] =
|
| 22 |
-
height: Optional[int] =
|
| 23 |
-
length: Optional[int] =
|
| 24 |
-
fps: Optional[int] =
|
| 25 |
filename_prefix: Optional[str] = "video/ComfyUI"
|
| 26 |
|
| 27 |
def _inject_params(prompt: Dict[str, Any], r: T2VReq) -> Dict[str, Any]:
|
| 28 |
p = json.loads(json.dumps(prompt))
|
| 29 |
-
p["
|
| 30 |
-
if r.seed is None:
|
| 31 |
-
|
| 32 |
-
p["3"]["inputs"]["seed"] = r.seed
|
| 33 |
-
if r.steps is not None: p["
|
| 34 |
-
if r.cfg is not None: p["
|
| 35 |
-
if r.width is not None: p["
|
| 36 |
-
if r.height is not None: p["
|
| 37 |
-
if r.length is not None: p["
|
| 38 |
-
if r.fps is not None: p["
|
| 39 |
if r.filename_prefix:
|
| 40 |
-
p["
|
| 41 |
return p
|
| 42 |
|
| 43 |
def _open_ws(client_id: str, token: str):
|
|
@@ -78,10 +78,10 @@ def _extract_video_from_history(history: Dict[str, Any]) -> Dict[str, str]:
|
|
| 78 |
raise RuntimeError("No video file found in history outputs")
|
| 79 |
|
| 80 |
sample_prompts = [
|
| 81 |
-
"A golden retriever running across a beach at sunset, cinematic
|
| 82 |
-
"
|
| 83 |
-
"
|
| 84 |
-
"
|
| 85 |
]
|
| 86 |
|
| 87 |
with gr.Blocks(
|
|
@@ -89,24 +89,22 @@ with gr.Blocks(
|
|
| 89 |
theme=gr.themes.Soft(primary_hue="blue", secondary_hue="blue", neutral_hue="slate"),
|
| 90 |
) as demo:
|
| 91 |
st_token = gr.State()
|
| 92 |
-
gr.Markdown("# Wan2.2
|
|
|
|
| 93 |
gr.Markdown("### Prompt")
|
| 94 |
text = gr.Textbox(label="Prompt", placeholder="Describe the video you want", lines=3)
|
| 95 |
|
| 96 |
gr.Examples(examples=sample_prompts, inputs=text)
|
| 97 |
-
gr.Markdown(
|
| 98 |
-
"[More Prompts](https://alidocs.dingtalk.com/i/nodes/EpGBa2Lm8aZxe5myC99MelA2WgN7R35y)"
|
| 99 |
-
)
|
| 100 |
|
| 101 |
with gr.Accordion("Advanced Settings", open=False):
|
| 102 |
with gr.Row():
|
| 103 |
-
width = gr.Number(label="Width", value=
|
| 104 |
-
height = gr.Number(label="Height", value=
|
| 105 |
with gr.Row():
|
| 106 |
-
length = gr.Number(label="Frames", value=
|
| 107 |
-
fps = gr.Number(label="FPS", value=
|
| 108 |
with gr.Row():
|
| 109 |
-
steps = gr.Number(label="Steps", value=
|
| 110 |
cfg = gr.Number(label="CFG", value=5.0)
|
| 111 |
seed = gr.Number(label="Seed (optional)", value=None)
|
| 112 |
filename_prefix = gr.Textbox(label="Filename prefix", value="video/ComfyUI")
|
|
|
|
| 16 |
text: str = Field(...)
|
| 17 |
negative: Optional[str] = None
|
| 18 |
seed: Optional[int] = None
|
| 19 |
+
steps: Optional[int] = 4
|
| 20 |
+
cfg: Optional[float] = 1
|
| 21 |
+
width: Optional[int] = 640
|
| 22 |
+
height: Optional[int] = 640
|
| 23 |
+
length: Optional[int] = 81
|
| 24 |
+
fps: Optional[int] = 16
|
| 25 |
filename_prefix: Optional[str] = "video/ComfyUI"
|
| 26 |
|
| 27 |
def _inject_params(prompt: Dict[str, Any], r: T2VReq) -> Dict[str, Any]:
|
| 28 |
p = json.loads(json.dumps(prompt))
|
| 29 |
+
p["89"]["inputs"]["text"] = r.text
|
| 30 |
+
# if r.seed is None:
|
| 31 |
+
# r.seed = int.from_bytes(os.urandom(8), "big") & ((1 << 63) - 1)
|
| 32 |
+
# p["3"]["inputs"]["seed"] = r.seed
|
| 33 |
+
# if r.steps is not None: p["78"]["inputs"]["steps"] = r.steps
|
| 34 |
+
# if r.cfg is not None: p["78"]["inputs"]["cfg"] = r.cfg
|
| 35 |
+
if r.width is not None: p["74"]["inputs"]["width"] = r.width
|
| 36 |
+
if r.height is not None: p["74"]["inputs"]["height"] = r.height
|
| 37 |
+
if r.length is not None: p["74"]["inputs"]["length"] = r.length
|
| 38 |
+
if r.fps is not None: p["88"]["inputs"]["fps"] = r.fps
|
| 39 |
if r.filename_prefix:
|
| 40 |
+
p["80"]["inputs"]["filename_prefix"] = r.filename_prefix
|
| 41 |
return p
|
| 42 |
|
| 43 |
def _open_ws(client_id: str, token: str):
|
|
|
|
| 78 |
raise RuntimeError("No video file found in history outputs")
|
| 79 |
|
| 80 |
sample_prompts = [
|
| 81 |
+
"A golden retriever running across a beach at sunset, cinematic",
|
| 82 |
+
"A cyberpunk city street at night with neon lights, light rain, slow pan",
|
| 83 |
+
"An astronaut walking on an alien planet covered in glowing crystals, purple sky with two moons, dust particles floating, slow panning shot, highly detailed, cinematic atmosphere.",
|
| 84 |
+
"A cat gracefully jumping between rooftops in slow motion, warm sunset lighting, camera tracking the cat midair, cinematic composition, natural movement."
|
| 85 |
]
|
| 86 |
|
| 87 |
with gr.Blocks(
|
|
|
|
| 89 |
theme=gr.themes.Soft(primary_hue="blue", secondary_hue="blue", neutral_hue="slate"),
|
| 90 |
) as demo:
|
| 91 |
st_token = gr.State()
|
| 92 |
+
gr.Markdown("# Experience Wan2.2 14B Text-to-Video on AMD MI300X — Free Trial")
|
| 93 |
+
gr.Markdown("Powered by [AMD Devcloud](https://oneclickamd.ai/) and [ComfyUI](https://github.com/comfyanonymous/ComfyUI)")
|
| 94 |
gr.Markdown("### Prompt")
|
| 95 |
text = gr.Textbox(label="Prompt", placeholder="Describe the video you want", lines=3)
|
| 96 |
|
| 97 |
gr.Examples(examples=sample_prompts, inputs=text)
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
with gr.Accordion("Advanced Settings", open=False):
|
| 100 |
with gr.Row():
|
| 101 |
+
width = gr.Number(label="Width", value=640, precision=0)
|
| 102 |
+
height = gr.Number(label="Height", value=640, precision=0)
|
| 103 |
with gr.Row():
|
| 104 |
+
length = gr.Number(label="Frames", value=81, precision=0)
|
| 105 |
+
fps = gr.Number(label="FPS", value=16, precision=0)
|
| 106 |
with gr.Row():
|
| 107 |
+
steps = gr.Number(label="Steps", value=4, precision=0)
|
| 108 |
cfg = gr.Number(label="CFG", value=5.0)
|
| 109 |
seed = gr.Number(label="Seed (optional)", value=None)
|
| 110 |
filename_prefix = gr.Textbox(label="Filename prefix", value="video/ComfyUI")
|