Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -29,8 +29,31 @@ if not hf_token:
|
|
29 |
# Use the token for authentication
|
30 |
HfFolder.save_token(hf_token)
|
31 |
|
|
|
|
|
32 |
pipe = StableVideoDiffusionPipeline.from_pretrained(
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
)
|
35 |
pipe.to("cuda")
|
36 |
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
|
|
29 |
# Use the token for authentication
|
30 |
HfFolder.save_token(hf_token)
|
31 |
|
32 |
+
# Load the original model to cache
|
33 |
+
original_model_id = "stabilityai/stable-video-diffusion-img2vid-xt"
|
34 |
pipe = StableVideoDiffusionPipeline.from_pretrained(
|
35 |
+
original_model_id,
|
36 |
+
torch_dtype=torch.float16,
|
37 |
+
variant="fp16",
|
38 |
+
use_auth_token=hf_token
|
39 |
+
)
|
40 |
+
|
41 |
+
# Get the cache directory of the original model
|
42 |
+
cache_dir = HfFolder.get_cache_dir()
|
43 |
+
model_cache_dir = os.path.join(cache_dir, "diffusers", original_model_id.replace("/", "--"))
|
44 |
+
|
45 |
+
# Path to the downloaded svd_xt_1_1.safetensors file
|
46 |
+
downloaded_safetensors_path = "svd_xt_1_1.safetensors"
|
47 |
+
|
48 |
+
# Replace the original safetensors file with the downloaded one
|
49 |
+
original_safetensors_path = os.path.join(model_cache_dir, "svd_xt.safetensors")
|
50 |
+
os.replace(downloaded_safetensors_path, original_safetensors_path)
|
51 |
+
|
52 |
+
# Load the model from the local directory with the replaced safetensors file
|
53 |
+
pipe = StableVideoDiffusionPipeline.from_pretrained(
|
54 |
+
model_cache_dir,
|
55 |
+
torch_dtype=torch.float16,
|
56 |
+
variant="fp16"
|
57 |
)
|
58 |
pipe.to("cuda")
|
59 |
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|