BestWishYsh commited on
Commit
244e707
·
1 Parent(s): 441905a
Files changed (1) hide show
  1. app.py +66 -33
app.py CHANGED
@@ -6,29 +6,6 @@ import tempfile
6
  import zipfile
7
  import torch
8
 
9
- # ---------------------------------------------------------------------------
10
- # Install private diffusers fork
11
- # ---------------------------------------------------------------------------
12
- _APP_DIR = os.path.dirname(os.path.abspath(__file__))
13
- ZIP_PATH = os.path.join(_APP_DIR, "helios_diffusers.zip")
14
- EXTRACT_DIR = os.path.join(_APP_DIR, "_helios_diffusers")
15
- _PKG_ROOT = os.path.join(EXTRACT_DIR, "diffusers-new-model-addition-helios-helios")
16
-
17
- if not os.path.isdir(_PKG_ROOT):
18
- print(f"[setup] Extracting {ZIP_PATH}")
19
- with zipfile.ZipFile(ZIP_PATH, "r") as zf:
20
- zf.extractall(EXTRACT_DIR)
21
-
22
- print(f"[setup] Installing diffusers from {_PKG_ROOT}")
23
- try:
24
- subprocess.check_call([sys.executable, "-m", "pip", "install", _PKG_ROOT])
25
- except subprocess.CalledProcessError as e:
26
- print(f"[setup] pip install failed (exit {e.returncode}), falling back to sys.path")
27
-
28
- _SRC_DIR = os.path.join(_PKG_ROOT, "src")
29
- if os.path.isdir(_SRC_DIR):
30
- sys.path.insert(0, _SRC_DIR)
31
-
32
  import gradio as gr
33
  import spaces
34
  from diffusers import (
@@ -37,7 +14,6 @@ from diffusers import (
37
  HeliosDMDScheduler
38
  )
39
  from diffusers.utils import export_to_video, load_image, load_video
40
- from aoti import aoti_load_
41
 
42
  # ---------------------------------------------------------------------------
43
  # Pre-load model
@@ -54,12 +30,25 @@ pipe = HeliosPyramidPipeline.from_pretrained(
54
  is_distilled=True
55
  )
56
 
57
- # aoti_load_(pipe.transformer, "multimodalart/helios-distilled-transformer", "helios_distilled_transformer.pt2")
58
-
59
  pipe.to("cuda")
60
-
61
  pipe.transformer.set_attention_backend("_flash_3_hub")
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  # ---------------------------------------------------------------------------
64
  # Generation
65
  # ---------------------------------------------------------------------------
@@ -125,16 +114,42 @@ def update_conditional_visibility(mode):
125
  return gr.update(visible=False), gr.update(visible=False)
126
 
127
  CSS = """
128
- #header { text-align: center; margin-bottom: 0.5em; }
129
- #header h1 { font-size: 2.2em; margin-bottom: 0; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  .contain { max-width: 1350px; margin: 0 auto !important; }
131
  """
132
 
133
- with gr.Blocks(css=CSS, title="Helios Video Generation", theme=gr.themes.Soft()) as demo:
134
  gr.HTML(
135
  """
 
 
 
136
  <div id="header">
137
- <h1>🎬 Helios 14B distilled</h1>
 
 
 
 
 
 
 
 
 
138
  </div>
139
  """
140
  )
@@ -200,6 +215,8 @@ with gr.Blocks(css=CSS, title="Helios Video Generation", theme=gr.themes.Soft())
200
  "of hard and soft corals in shades of red, orange, and green. The photo captures "
201
  "the fish from a slightly elevated angle, emphasizing its lively movements and the "
202
  "vivid colors of its surroundings. A close-up shot with dynamic movement.",
 
 
203
  ],
204
  [
205
  "Text-to-Video",
@@ -211,6 +228,8 @@ with gr.Blocks(css=CSS, title="Helios Video Generation", theme=gr.themes.Soft())
211
  "smile as if he found the answer to the mystery of life, the lighting is very cinematic "
212
  "with the golden light and the Parisian streets and city in the background, depth of "
213
  "field, cinematic 35mm film.",
 
 
214
  ],
215
  [
216
  "Text-to-Video",
@@ -221,11 +240,25 @@ with gr.Blocks(css=CSS, title="Helios Video Generation", theme=gr.themes.Soft())
221
  "of the Amalfi Coast Italy, several distant people are seen walking and enjoying vistas "
222
  "on patios of the dramatic ocean views, the warm glow of the afternoon sun creates a "
223
  "magical and romantic feeling to the scene, the view is stunning captured with beautiful photography.",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  ],
225
  ],
226
- inputs=[mode, prompt],
227
  label="Example Prompts",
228
  )
229
 
230
  if __name__ == "__main__":
231
- demo.launch()
 
6
  import zipfile
7
  import torch
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  import gradio as gr
10
  import spaces
11
  from diffusers import (
 
14
  HeliosDMDScheduler
15
  )
16
  from diffusers.utils import export_to_video, load_image, load_video
 
17
 
18
  # ---------------------------------------------------------------------------
19
  # Pre-load model
 
30
  is_distilled=True
31
  )
32
 
 
 
33
  pipe.to("cuda")
34
+ # pipe.transformer.set_attention_backend("flash_hub")
35
  pipe.transformer.set_attention_backend("_flash_3_hub")
36
 
37
+ # @spaces.GPU(duration=1500)
38
+ # def compile_transformer():
39
+ # with spaces.aoti_capture(pipe.transformer) as call:
40
+ # pipe("arbitrary example prompt")
41
+
42
+ # exported = torch.export.export(
43
+ # pipe.transformer,
44
+ # args=call.args,
45
+ # kwargs=call.kwargs,
46
+ # )
47
+ # return spaces.aoti_compile(exported)
48
+
49
+ # compiled_transformer = compile_transformer()
50
+ # spaces.aoti_apply(compiled_transformer, pipe.transformer)
51
+
52
  # ---------------------------------------------------------------------------
53
  # Generation
54
  # ---------------------------------------------------------------------------
 
114
  return gr.update(visible=False), gr.update(visible=False)
115
 
116
  CSS = """
117
+ #header { text-align: center; margin-bottom: 1.5em; }
118
+ #header h1 { font-size: 2.2em; margin-bottom: 0.2em; }
119
+ .logo { max-height: 100px; margin: 0 auto 10px auto; display: block; }
120
+ .link-buttons { display: flex; justify-content: center; gap: 15px; margin-top: 10px; }
121
+ .link-buttons a {
122
+ background-color: #2b3137;
123
+ color: #ffffff !important;
124
+ padding: 8px 20px;
125
+ border-radius: 6px;
126
+ text-decoration: none;
127
+ font-weight: 600;
128
+ font-size: 1em;
129
+ transition: all 0.2s ease-in-out;
130
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
131
+ }
132
+ .link-buttons a:hover { background-color: #4a535c; transform: translateY(-1px); }
133
  .contain { max-width: 1350px; margin: 0 auto !important; }
134
  """
135
 
136
+ with gr.Blocks(title="Helios Video Generation") as demo:
137
  gr.HTML(
138
  """
139
+ <div style='display: flex; align-items: center; justify-content: center; width: 100%;'>
140
+ <img src="https://github.com/PKU-YuanGroup/Helios-Page/blob/main/figures/logo_white.png?raw=true" style='width: 400px; height: auto;' />
141
+ </div>
142
  <div id="header">
143
+ <h1>🎬 Helios 14B Distilled: Real Real-Time Long Video Generation Model</h1>
144
+ <p style="font-size: 1.1em; color: #666; margin-top: 0.5em; margin-bottom: 1em;">
145
+ If you like our project, please give us a star ⭐ on GitHub for the latest update.
146
+ </p>
147
+ <div class="link-buttons">
148
+ <a href="https://github.com/PKU-YuanGroup/Helios" target="_blank">💻 Code</a>
149
+ <a href="https://pku-yuangroup.github.io/Helios-Page" target="_blank">📄 Page</a>
150
+ <a href="https://www.youtube.com/watch?v=vd_AgHtOUFQ" target="_blank">🎥 Main Feature</a>
151
+ <a href="https://www.youtube.com/watch?v=1GeIU2Dn7UY" target="_blank">⚡ Inference Speed</a>
152
+ </div>
153
  </div>
154
  """
155
  )
 
215
  "of hard and soft corals in shades of red, orange, and green. The photo captures "
216
  "the fish from a slightly elevated angle, emphasizing its lively movements and the "
217
  "vivid colors of its surroundings. A close-up shot with dynamic movement.",
218
+ None,
219
+ None,
220
  ],
221
  [
222
  "Text-to-Video",
 
228
  "smile as if he found the answer to the mystery of life, the lighting is very cinematic "
229
  "with the golden light and the Parisian streets and city in the background, depth of "
230
  "field, cinematic 35mm film.",
231
+ None,
232
+ None,
233
  ],
234
  [
235
  "Text-to-Video",
 
240
  "of the Amalfi Coast Italy, several distant people are seen walking and enjoying vistas "
241
  "on patios of the dramatic ocean views, the warm glow of the afternoon sun creates a "
242
  "magical and romantic feeling to the scene, the view is stunning captured with beautiful photography.",
243
+ None,
244
+ None,
245
+ ],
246
+ [
247
+ "Image-to-Video",
248
+ "A towering emerald wave surges forward, its crest curling with raw power and energy. Sunlight glints off the translucent water, illuminating the intricate textures and deep green hues within the wave’s body. A thick spray erupts from the breaking crest, casting a misty veil that dances above the churning surface. As the perspective widens, the immense scale of the wave becomes apparent, revealing the restless expanse of the ocean stretching beyond. The scene captures the ocean’s untamed beauty and relentless force, with every droplet and ripple shimmering in the light. The dynamic motion and vivid colors evoke both awe and respect for nature’s might.",
249
+ "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/wave.jpg",
250
+ None,
251
+ ],
252
+ [
253
+ "Video-to-Video",
254
+ "A bright yellow Lamborghini Huracn Tecnica speeds along a curving mountain road, surrounded by lush green trees under a partly cloudy sky. The car's sleek design and vibrant color stand out against the natural backdrop, emphasizing its dynamic movement. The road curves gently, with a guardrail visible on one side, adding depth to the scene. The motion blur captures the sense of speed and energy, creating a thrilling and exhilarating atmosphere. A front-facing shot from a slightly elevated angle, highlighting the car's aggressive stance and the surrounding greenery.",
255
+ None,
256
+ "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/helios/car.mp4",
257
  ],
258
  ],
259
+ inputs=[mode, prompt, image_input, video_input],
260
  label="Example Prompts",
261
  )
262
 
263
  if __name__ == "__main__":
264
+ demo.launch(share=True, css=CSS, theme=gr.themes.Soft())