Spaces:
Running
Running
zR
commited on
Commit
•
0198f90
1
Parent(s):
ed6f29c
testing
Browse files- app.py +54 -39
- rife_model.py +6 -0
app.py
CHANGED
@@ -6,7 +6,7 @@ import time
|
|
6 |
|
7 |
import gradio as gr
|
8 |
import torch
|
9 |
-
from diffusers import CogVideoXPipeline, CogVideoXDDIMScheduler
|
10 |
from datetime import datetime, timedelta
|
11 |
|
12 |
from diffusers.image_processor import VaeImageProcessor
|
@@ -22,7 +22,7 @@ hf_hub_download(repo_id="ai-forever/Real-ESRGAN", filename="RealESRGAN_x4.pth",
|
|
22 |
snapshot_download(repo_id="AlexWortega/RIFE", local_dir="model_rife")
|
23 |
|
24 |
pipe = CogVideoXPipeline.from_pretrained("THUDM/CogVideoX-5b", torch_dtype=torch.bfloat16).to(device)
|
25 |
-
pipe.scheduler =
|
26 |
|
27 |
pipe.transformer.to(memory_format=torch.channels_last)
|
28 |
pipe.transformer = torch.compile(pipe.transformer, mode="max-autotune", fullgraph=True)
|
@@ -111,6 +111,7 @@ def infer(
|
|
111 |
num_videos_per_prompt=1,
|
112 |
num_inference_steps=num_inference_steps,
|
113 |
num_frames=49,
|
|
|
114 |
output_type="pt",
|
115 |
guidance_scale=guidance_scale,
|
116 |
generator=torch.Generator(device="cpu").manual_seed(seed),
|
@@ -198,44 +199,58 @@ with gr.Blocks() as demo:
|
|
198 |
seed_text = gr.Number(label="Seed Used for Video Generation", visible=False)
|
199 |
|
200 |
gr.Markdown("""
|
201 |
-
|
202 |
-
|
203 |
-
|
|
|
|
|
|
|
|
|
204 |
</div>
|
205 |
-
<div
|
206 |
-
|
207 |
-
|
208 |
-
|
|
|
209 |
</div>
|
210 |
-
<
|
211 |
-
<
|
212 |
-
<
|
213 |
-
</
|
214 |
-
<
|
215 |
-
|
216 |
-
|
217 |
-
<
|
218 |
-
<
|
219 |
-
</
|
220 |
-
<
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
""")
|
240 |
|
241 |
|
@@ -244,7 +259,7 @@ with gr.Blocks() as demo:
|
|
244 |
latents, seed = infer(
|
245 |
prompt,
|
246 |
num_inference_steps=50, # NOT Changed
|
247 |
-
guidance_scale=
|
248 |
seed=seed_value,
|
249 |
progress=progress,
|
250 |
)
|
|
|
6 |
|
7 |
import gradio as gr
|
8 |
import torch
|
9 |
+
from diffusers import CogVideoXPipeline, CogVideoXDDIMScheduler,CogVideoXDPMScheduler
|
10 |
from datetime import datetime, timedelta
|
11 |
|
12 |
from diffusers.image_processor import VaeImageProcessor
|
|
|
22 |
snapshot_download(repo_id="AlexWortega/RIFE", local_dir="model_rife")
|
23 |
|
24 |
pipe = CogVideoXPipeline.from_pretrained("THUDM/CogVideoX-5b", torch_dtype=torch.bfloat16).to(device)
|
25 |
+
pipe.scheduler = CogVideoXDPMScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
|
26 |
|
27 |
pipe.transformer.to(memory_format=torch.channels_last)
|
28 |
pipe.transformer = torch.compile(pipe.transformer, mode="max-autotune", fullgraph=True)
|
|
|
111 |
num_videos_per_prompt=1,
|
112 |
num_inference_steps=num_inference_steps,
|
113 |
num_frames=49,
|
114 |
+
use_dynamic_cfg=True,
|
115 |
output_type="pt",
|
116 |
guidance_scale=guidance_scale,
|
117 |
generator=torch.Generator(device="cpu").manual_seed(seed),
|
|
|
199 |
seed_text = gr.Number(label="Seed Used for Video Generation", visible=False)
|
200 |
|
201 |
gr.Markdown("""
|
202 |
+
<body>
|
203 |
+
<div class="video-container">
|
204 |
+
<div class="video-item">
|
205 |
+
<video width="100%" controls>
|
206 |
+
<source src="https://github.com/user-attachments/assets/cf5953ea-96d3-48fd-9907-c4708752c714" type="video/mp4">
|
207 |
+
</video>
|
208 |
+
<div class="caption">A garden comes to life as a kaleidoscope of butterflies flutters amidst the blossoms, their delicate wings casting shadows on the petals below. In the background, a grand fountain cascades water with a gentle splendor, its rhythmic sound providing a soothing backdrop. Beneath the cool shade of a mature tree, a solitary wooden chair invites solitude and reflection, its smooth surface worn by the touch of countless visitors seeking a moment of tranquility in nature's embrace.</div>
|
209 |
</div>
|
210 |
+
<div class="video-item">
|
211 |
+
<video width="100%" controls>
|
212 |
+
<source src="https://github.com/user-attachments/assets/fe0a78e6-b669-4800-8cf0-b5f9b5145b52" type="video/mp4">
|
213 |
+
</video>
|
214 |
+
<div class="caption">A small boy, head bowed and determination etched on his face, sprints through the torrential downpour as lightning crackles and thunder rumbles in the distance. The relentless rain pounds the ground, creating a chaotic dance of water droplets that mirror the dramatic sky's anger. In the far background, the silhouette of a cozy home beckons, a faint beacon of safety and warmth amidst the fierce weather. The scene is one of perseverance and the unyielding spirit of a child braving the elements.</div>
|
215 |
</div>
|
216 |
+
<div class="video-item">
|
217 |
+
<video width="100%" controls>
|
218 |
+
<source src="https://github.com/user-attachments/assets/c182f606-8f8c-421d-b414-8487070fcfcb" type="video/mp4">
|
219 |
+
</video>
|
220 |
+
<div class="caption">A suited astronaut, with the red dust of Mars clinging to their boots, reaches out to shake hands with an alien being, their skin a shimmering blue, under the pink-tinged sky of the fourth planet. In the background, a sleek silver rocket, a beacon of human ingenuity, stands tall, its engines powered down, as the two representatives of different worlds exchange a historic greeting amidst the desolate beauty of the Martian landscape.</div>
|
221 |
+
</div>
|
222 |
+
<div class="video-item">
|
223 |
+
<video width="100%" controls>
|
224 |
+
<source src="https://github.com/user-attachments/assets/7db2bbce-194d-434d-a605-350254b6c298" type="video/mp4">
|
225 |
+
</video>
|
226 |
+
<div class="caption">An elderly gentleman, with a serene expression, sits at the water's edge, a steaming cup of tea by his side. He is engrossed in his artwork, brush in hand, as he renders an oil painting on a canvas that's propped up against a small, weathered table. The sea breeze whispers through his silver hair, gently billowing his loose-fitting white shirt, while the salty air adds an intangible element to his masterpiece in progress. The scene is one of tranquility and inspiration, with the artist's canvas capturing the vibrant hues of the setting sun reflecting off the tranquil sea.</div>
|
227 |
+
</div>
|
228 |
+
<div class="video-item">
|
229 |
+
<video width="100%" controls>
|
230 |
+
<source src="https://github.com/user-attachments/assets/62b01046-8cab-44cc-bd45-4d965bb615ec" type="video/mp4">
|
231 |
+
</video>
|
232 |
+
<div class="caption">In a dimly lit bar, purplish light bathes the face of a mature man, his eyes blinking thoughtfully as he ponders in close-up, the background artfully blurred to focus on his introspective expression, the ambiance of the bar a mere suggestion of shadows and soft lighting.</div>
|
233 |
+
</div>
|
234 |
+
<div class="video-item">
|
235 |
+
<video width="100%" controls>
|
236 |
+
<source src="https://github.com/user-attachments/assets/d78e552a-4b3f-4b81-ac3f-3898079554f6" type="video/mp4">
|
237 |
+
</video>
|
238 |
+
<div class="caption">A golden retriever, sporting sleek black sunglasses, with its lengthy fur flowing in the breeze, sprints playfully across a rooftop terrace, recently refreshed by a light rain. The scene unfolds from a distance, the dog's energetic bounds growing larger as it approaches the camera, its tail wagging with unrestrained joy, while droplets of water glisten on the concrete behind it. The overcast sky provides a dramatic backdrop, emphasizing the vibrant golden coat of the canine as it dashes towards the viewer.</div>
|
239 |
+
</div>
|
240 |
+
<div class="video-item">
|
241 |
+
<video width="100%" controls>
|
242 |
+
<source src="https://github.com/user-attachments/assets/30894f12-c741-44a2-9e6e-ddcacc231e5b" type="video/mp4">
|
243 |
+
</video>
|
244 |
+
<div class="caption">On a brilliant sunny day, the lakeshore is lined with an array of willow trees, their slender branches swaying gently in the soft breeze. The tranquil surface of the lake reflects the clear blue sky, while several elegant swans glide gracefully through the still water, leaving behind delicate ripples that disturb the mirror-like quality of the lake. The scene is one of serene beauty, with the willows' greenery providing a picturesque frame for the peaceful avian visitors.</div>
|
245 |
+
</div>
|
246 |
+
<div class="video-item">
|
247 |
+
<video width="100%" controls>
|
248 |
+
<source src="https://github.com/user-attachments/assets/926575ca-7150-435b-a0ff-4900a963297b" type="video/mp4">
|
249 |
+
</video>
|
250 |
+
<div class="caption">A Chinese mother, draped in a soft, pastel-colored robe, gently rocks back and forth in a cozy rocking chair positioned in the tranquil setting of a nursery. The dimly lit bedroom is adorned with whimsical mobiles dangling from the ceiling, casting shadows that dance on the walls. Her baby, swaddled in a delicate, patterned blanket, rests against her chest, the child's earlier cries now replaced by contented coos as the mother's soothing voice lulls the little one to sleep. The scent of lavender fills the air, adding to the serene atmosphere, while a warm, orange glow from a nearby nightlight illuminates the scene with a gentle hue, capturing a moment of tender love and comfort.</div>
|
251 |
+
</div>
|
252 |
+
</div>
|
253 |
+
</body>
|
254 |
""")
|
255 |
|
256 |
|
|
|
259 |
latents, seed = infer(
|
260 |
prompt,
|
261 |
num_inference_steps=50, # NOT Changed
|
262 |
+
guidance_scale=7, # NOT Changed
|
263 |
seed=seed_value,
|
264 |
progress=progress,
|
265 |
)
|
rife_model.py
CHANGED
@@ -79,6 +79,12 @@ def ssim_interpolation_rife(model, samples, exp=1, upscale_amount=1, output_devi
|
|
79 |
|
80 |
|
81 |
def load_rife_model(model_path):
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
model = Model()
|
83 |
model.load_model(model_path, -1)
|
84 |
model.eval()
|
|
|
79 |
|
80 |
|
81 |
def load_rife_model(model_path):
|
82 |
+
torch.set_grad_enabled(False)
|
83 |
+
if torch.cuda.is_available():
|
84 |
+
torch.backends.cudnn.enabled = True
|
85 |
+
torch.backends.cudnn.benchmark = True
|
86 |
+
torch.set_default_tensor_type(torch.cuda.FloatTensor)
|
87 |
+
|
88 |
model = Model()
|
89 |
model.load_model(model_path, -1)
|
90 |
model.eval()
|