vivienfanghua commited on
Commit
916a8c1
·
verified ·
1 Parent(s): 8a1e93f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -30
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
20
- cfg: Optional[float] = 5.0
21
- width: Optional[int] = 1280
22
- height: Optional[int] = 704
23
- length: Optional[int] = 121
24
- fps: Optional[int] = 24
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["6"]["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["3"]["inputs"]["steps"] = r.steps
34
- if r.cfg is not None: p["3"]["inputs"]["cfg"] = r.cfg
35
- if r.width is not None: p["55"]["inputs"]["width"] = r.width
36
- if r.height is not None: p["55"]["inputs"]["height"] = r.height
37
- if r.length is not None: p["55"]["inputs"]["length"] = r.length
38
- if r.fps is not None: p["57"]["inputs"]["fps"] = r.fps
39
  if r.filename_prefix:
40
- p["58"]["inputs"]["filename_prefix"] = r.filename_prefix
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, 24fps",
82
- "Aerial shot, warm colors, extreme wide shot, sunny lighting, hard lighting, daylight, establishing shot.In a desolate desert, a black SUV speeds along a highway. In a high-angle shot, the vehicle is seen driving on the left side of the road, with a roof rack and a red taillight on top. The camera slowly pushes in. In front of the vehicle are vast yellow sand dunes, and a few mountain peaks can be seen in the distance. The sky is a pale blue, and sunlight filters through the clouds, bringing a touch of warmth to the desolate land. The sides of the road are lined with dry grass dotted with some low shrubs.",
83
- "Pixel art style. In a colorful universe, a player-controlled pixel character travels between planets of various shapes and unique color tones, each with strange terrain and alien creatures. A close-up shot shows the player character in the center of the frame, in dialogue with a friendly alien creature. The alien has a rounded body and large eyes, appearing very cute. Above, pixelated cosmic storms and energy vortex effects rotate slowly, adding a sense of dynamism. The overall style is retro yet futuristic, with a vibrant and lively color palette.",
84
- "In an oil painting style, a vast sea of sunflowers unfolds, their golden heads blooming brilliantly in the faint light of dawn or dusk. The impasto technique is prominently used, with bold, thick brushstrokes lending a powerful texture and vitality to the sky and petals. The deep blue of the sky creates a striking contrast with the bright sunflowers, cultivating an atmosphere that is both serene and hopeful. Swarms of bees dance and hover ceaselessly among the flowers, busily collecting nectar. These dynamic bees inject boundless energy and a sense of motion into the otherwise static painting, filling the entire scene with the vibrant life of summer and the joy of harvest."
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 T2V running on AMD MI300x")
 
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=1280, precision=0)
104
- height = gr.Number(label="Height", value=704, precision=0)
105
  with gr.Row():
106
- length = gr.Number(label="Frames", value=121, precision=0)
107
- fps = gr.Number(label="FPS", value=24, precision=0)
108
  with gr.Row():
109
- steps = gr.Number(label="Steps", value=20, precision=0)
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")