ariG23498 HF Staff commited on
Commit
0b304b5
·
verified ·
1 Parent(s): 4aeca8d

Upload Wan-AI_Wan2.2-I2V-A14B-Diffusers_0.py with huggingface_hub

Browse files
Wan-AI_Wan2.2-I2V-A14B-Diffusers_0.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "transformers",
5
+ # "torch",
6
+ # ]
7
+ # ///
8
+
9
+ try:
10
+ import torch
11
+ from diffusers import DiffusionPipeline
12
+ from diffusers.utils import load_image, export_to_video
13
+
14
+ pipe = DiffusionPipeline.from_pretrained("Wan-AI/Wan2.2-I2V-A14B-Diffusers", torch_dtype=torch.float16)
15
+ pipe.to("cuda")
16
+
17
+ prompt = "A man with short gray hair plays a red electric guitar."
18
+ image = load_image(
19
+ "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guitar-man.png"
20
+ )
21
+
22
+ output = pipe(image=image, prompt=prompt).frames[0]
23
+ export_to_video(output, "output.mp4")
24
+ with open('Wan-AI_Wan2.2-I2V-A14B-Diffusers_0.txt', 'w') as f:
25
+ f.write('Everything was good in Wan-AI_Wan2.2-I2V-A14B-Diffusers_0.txt')
26
+ except Exception as e:
27
+ with open('Wan-AI_Wan2.2-I2V-A14B-Diffusers_0.txt', 'w') as f:
28
+ import traceback
29
+ traceback.print_exc(file=f)
30
+ finally:
31
+ from huggingface_hub import upload_file
32
+ upload_file(
33
+ path_or_fileobj='Wan-AI_Wan2.2-I2V-A14B-Diffusers_0.txt',
34
+ repo_id='model-metadata/custom_code_execution_files',
35
+ path_in_repo='Wan-AI_Wan2.2-I2V-A14B-Diffusers_0.txt',
36
+ repo_type='dataset',
37
+ )