yasserrmd commited on
Commit
7341603
1 Parent(s): a4b6a3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -16
app.py CHANGED
@@ -10,8 +10,6 @@ from diffusers.utils import export_to_video
10
  import spaces
11
  import uuid
12
 
13
- is_canonical = True if os.environ.get("SPACE_ID") == "Pyramid-Flow/pyramid-flow" else False
14
-
15
  # Constants
16
  MODEL_PATH = "pyramid-flow-model"
17
  MODEL_REPO = "rain1011/pyramid-flow-sd3"
@@ -62,7 +60,7 @@ model = load_model()
62
 
63
  # Text-to-video generation function
64
  @spaces.GPU(duration=120)
65
- def generate_video(prompt, image=None, duration=10, guidance_scale=9, video_guidance_scale=5, progress=gr.Progress(track_tqdm=True)):
66
  multiplier = 3
67
  temp = int(duration * multiplier) + 1 # Convert seconds to temp value (assuming 24 FPS)
68
  torch_dtype = torch.bfloat16 if MODEL_DTYPE == "bf16" else torch.float32
@@ -109,26 +107,16 @@ with gr.Blocks() as demo:
109
  i2v_image = gr.Image(type="pil", label="Input Image")
110
  t2v_prompt = gr.Textbox(label="Prompt")
111
  with gr.Accordion("Advanced settings", open=False):
112
- t2v_duration = gr.Slider(minimum=1, maximum=5, value=5, step=1, label="Duration (seconds)", visible=not is_canonical)
113
  t2v_guidance_scale = gr.Slider(minimum=1, maximum=15, value=7, step=0.1, label="Guidance Scale")
114
  t2v_video_guidance_scale = gr.Slider(minimum=1, maximum=15, value=5, step=0.1, label="Video Guidance Scale")
115
  t2v_generate_btn = gr.Button("Generate Video")
116
  with gr.Column():
117
  t2v_output = gr.Video(label="Generated Video")
118
- gr.HTML("""
119
- <div style="display: flex; flex-direction: column;justify-content: center; align-items: center; text-align: center;">
120
- <p style="display: flex;gap: 6px;">
121
- <a href="https://huggingface.co/spaces/Pyramid-Flow/pyramid-flow?duplicate=true">
122
- <img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-lg.svg" alt="Duplicate this Space">
123
- </a>
124
- </p>
125
- <p>to use privately and generate videos up to 10s</p>
126
- </div>
127
- """)
128
  gr.Examples(
129
  examples=[
130
- "A movie trailer featuring the adventures of the 30 year old space man wearing a red wool knitted motorcycle helmet, blue sky, salt desert, cinematic style, shot on 35mm film, vivid colors",
131
- "Beautiful, snowy Tokyo city is bustling. The camera moves through the bustling city street, following several people enjoying the beautiful snowy weather and shopping at nearby stalls. Gorgeous sakura petals are flying through the wind along with snowflakes"
132
  ],
133
  fn=generate_video,
134
  inputs=t2v_prompt,
 
10
  import spaces
11
  import uuid
12
 
 
 
13
  # Constants
14
  MODEL_PATH = "pyramid-flow-model"
15
  MODEL_REPO = "rain1011/pyramid-flow-sd3"
 
60
 
61
  # Text-to-video generation function
62
  @spaces.GPU(duration=120)
63
+ def generate_video(prompt, image=None, duration=5, guidance_scale=9, video_guidance_scale=5, progress=gr.Progress(track_tqdm=True)):
64
  multiplier = 3
65
  temp = int(duration * multiplier) + 1 # Convert seconds to temp value (assuming 24 FPS)
66
  torch_dtype = torch.bfloat16 if MODEL_DTYPE == "bf16" else torch.float32
 
107
  i2v_image = gr.Image(type="pil", label="Input Image")
108
  t2v_prompt = gr.Textbox(label="Prompt")
109
  with gr.Accordion("Advanced settings", open=False):
110
+ t2v_duration = gr.Slider(minimum=1, maximum=10, value=5, step=1, label="Duration (seconds)")
111
  t2v_guidance_scale = gr.Slider(minimum=1, maximum=15, value=7, step=0.1, label="Guidance Scale")
112
  t2v_video_guidance_scale = gr.Slider(minimum=1, maximum=15, value=5, step=0.1, label="Video Guidance Scale")
113
  t2v_generate_btn = gr.Button("Generate Video")
114
  with gr.Column():
115
  t2v_output = gr.Video(label="Generated Video")
 
 
 
 
 
 
 
 
 
 
116
  gr.Examples(
117
  examples=[
118
+ "A futuristic explorer, 30 years old, travels across distant galaxies in a sleek silver space suit, gliding through a glowing nebula. The scene is illuminated by vibrant starbursts and cosmic dust, captured with a futuristic drone in ultra-high-definition, showcasing vibrant purples and blues",
119
+ "In a serene winter landscape, a futuristic metropolis hums with life. The camera glides along an icy street as citizens, wrapped in advanced thermal suits, enjoy the wintry scene. Holographic advertisements flicker above snow-covered buildings, while sleek flying vehicles zip overhead. In the background, delicate crystalline structures refract light through the snowflakes."
120
  ],
121
  fn=generate_video,
122
  inputs=t2v_prompt,