Spaces:
Running
on
Zero
Running
on
Zero
ai-forever
commited on
Commit
•
0838eb3
1
Parent(s):
e039b6b
add video resolution
Browse files
app.py
CHANGED
@@ -43,6 +43,7 @@ max_64_bit_int = 2**63 - 1
|
|
43 |
def sample(
|
44 |
# image: Image,
|
45 |
prompt,
|
|
|
46 |
seed: Optional[int] = 42,
|
47 |
# randomize_seed: bool = True,
|
48 |
# motion_bucket_id: int = 127,
|
@@ -64,14 +65,23 @@ def sample(
|
|
64 |
os.makedirs(output_folder, exist_ok=True)
|
65 |
base_count = len(glob(os.path.join(output_folder, "*.mp4")))
|
66 |
video_path = os.path.join(output_folder, f"{base_count:06d}.mp4")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
# frames = pipe(image, decode_chunk_size=decoding_t, generator=generator, motion_bucket_id=motion_bucket_id, noise_aug_strength=0.1, num_frames=25).frames[0]
|
69 |
# prompt = "The camera follows behind a white vintage SUV with a black roof rack as it speeds up a steep dirt road surrounded by pine trees on a steep mountain slope, dust kicks up from it’s tires, the sunlight shines on the SUV as it speeds along the dirt road, casting a warm glow over the scene. The dirt road curves gently into the distance, with no other cars or vehicles in sight. The trees on either side of the road are redwoods, with patches of greenery scattered throughout. The car is seen from the rear following the curve with ease, making it seem as if it is on a rugged drive through the rugged terrain. The dirt road itself is surrounded by steep hills and mountains, with a clear blue sky above with wispy clouds."
|
70 |
frames = pipe(
|
71 |
seed=seed,
|
72 |
time_length=12,
|
73 |
-
width =
|
74 |
-
height =
|
75 |
save_path=video_path,
|
76 |
text=prompt,
|
77 |
)
|
@@ -124,6 +134,13 @@ with gr.Blocks() as demo:
|
|
124 |
placeholder="Enter your prompt",
|
125 |
container=False,
|
126 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
generate_btn = gr.Button("Generate")
|
128 |
|
129 |
# with gr.Accordion("Advanced options", open=False):
|
@@ -133,7 +150,8 @@ with gr.Blocks() as demo:
|
|
133 |
# fps_id = gr.Slider(label="Frames per second", info="The length of your video in seconds will be 25/fps", value=6, minimum=5, maximum=30)
|
134 |
|
135 |
# image.upload(fn=resize_image, inputs=image, outputs=image, queue=False)
|
136 |
-
|
|
|
137 |
# gr.Examples(
|
138 |
# examples=[
|
139 |
# "images/blink_meme.png",
|
|
|
43 |
def sample(
|
44 |
# image: Image,
|
45 |
prompt,
|
46 |
+
resolution,
|
47 |
seed: Optional[int] = 42,
|
48 |
# randomize_seed: bool = True,
|
49 |
# motion_bucket_id: int = 127,
|
|
|
65 |
os.makedirs(output_folder, exist_ok=True)
|
66 |
base_count = len(glob(os.path.join(output_folder, "*.mp4")))
|
67 |
video_path = os.path.join(output_folder, f"{base_count:06d}.mp4")
|
68 |
+
res_variants = {
|
69 |
+
'1:1': '512x512',
|
70 |
+
'9:16': '384x672',
|
71 |
+
'16:9': '672x384',
|
72 |
+
'1:2': '352x736',
|
73 |
+
'2:1': '736x352'
|
74 |
+
}
|
75 |
+
width = int(res_variants[resolution].split('x')[0])
|
76 |
+
height = int(res_variants[resolution].split('x')[1])
|
77 |
|
78 |
# frames = pipe(image, decode_chunk_size=decoding_t, generator=generator, motion_bucket_id=motion_bucket_id, noise_aug_strength=0.1, num_frames=25).frames[0]
|
79 |
# prompt = "The camera follows behind a white vintage SUV with a black roof rack as it speeds up a steep dirt road surrounded by pine trees on a steep mountain slope, dust kicks up from it’s tires, the sunlight shines on the SUV as it speeds along the dirt road, casting a warm glow over the scene. The dirt road curves gently into the distance, with no other cars or vehicles in sight. The trees on either side of the road are redwoods, with patches of greenery scattered throughout. The car is seen from the rear following the curve with ease, making it seem as if it is on a rugged drive through the rugged terrain. The dirt road itself is surrounded by steep hills and mountains, with a clear blue sky above with wispy clouds."
|
80 |
frames = pipe(
|
81 |
seed=seed,
|
82 |
time_length=12,
|
83 |
+
width = width,
|
84 |
+
height = height,
|
85 |
save_path=video_path,
|
86 |
text=prompt,
|
87 |
)
|
|
|
134 |
placeholder="Enter your prompt",
|
135 |
container=False,
|
136 |
)
|
137 |
+
#TODO ? можно так принять входное значение
|
138 |
+
resolution = gr.Dropdown(
|
139 |
+
label="Video resolution",
|
140 |
+
choices=["1:1", "9:16", "16:9", "1:2", "2:1"],
|
141 |
+
value="16:9"
|
142 |
+
)
|
143 |
+
|
144 |
generate_btn = gr.Button("Generate")
|
145 |
|
146 |
# with gr.Accordion("Advanced options", open=False):
|
|
|
150 |
# fps_id = gr.Slider(label="Frames per second", info="The length of your video in seconds will be 25/fps", value=6, minimum=5, maximum=30)
|
151 |
|
152 |
# image.upload(fn=resize_image, inputs=image, outputs=image, queue=False)
|
153 |
+
#TODO функция так принимает аргументы?
|
154 |
+
generate_btn.click(fn=sample, inputs=[prompt, resolution], outputs=[video], api_name="video")
|
155 |
# gr.Examples(
|
156 |
# examples=[
|
157 |
# "images/blink_meme.png",
|