ariG23498 HF Staff commited on
Commit
d3cc2f2
·
verified ·
1 Parent(s): 7e2c0f2

Upload MCG-NJU_SteadyDancer-14B_0.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. MCG-NJU_SteadyDancer-14B_0.py +80 -0
MCG-NJU_SteadyDancer-14B_0.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "numpy",
5
+ # "einops",
6
+ # "pandas",
7
+ # "matplotlib",
8
+ # "protobuf",
9
+ # "torch",
10
+ # "sentencepiece",
11
+ # "torchvision",
12
+ # "transformers",
13
+ # "timm",
14
+ # "diffusers",
15
+ # "sentence-transformers",
16
+ # "accelerate",
17
+ # "peft",
18
+ # "slack-sdk",
19
+ # ]
20
+ # ///
21
+
22
+ try:
23
+ import torch
24
+ from diffusers import DiffusionPipeline
25
+ from diffusers.utils import load_image, export_to_video
26
+
27
+ # switch to "mps" for apple devices
28
+ pipe = DiffusionPipeline.from_pretrained("MCG-NJU/SteadyDancer-14B", dtype=torch.bfloat16, device_map="cuda")
29
+ pipe.to("cuda")
30
+
31
+ prompt = "A man with short gray hair plays a red electric guitar."
32
+ image = load_image(
33
+ "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guitar-man.png"
34
+ )
35
+
36
+ output = pipe(image=image, prompt=prompt).frames[0]
37
+ export_to_video(output, "output.mp4")
38
+ with open('MCG-NJU_SteadyDancer-14B_0.txt', 'w', encoding='utf-8') as f:
39
+ f.write('Everything was good in MCG-NJU_SteadyDancer-14B_0.txt')
40
+ except Exception as e:
41
+ import os
42
+ from slack_sdk import WebClient
43
+ client = WebClient(token=os.environ['SLACK_TOKEN'])
44
+ client.chat_postMessage(
45
+ channel='#hub-model-metadata-snippets-sprint',
46
+ text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/MCG-NJU_SteadyDancer-14B_0.txt|MCG-NJU_SteadyDancer-14B_0.txt>',
47
+ )
48
+
49
+ with open('MCG-NJU_SteadyDancer-14B_0.txt', 'a', encoding='utf-8') as f:
50
+ import traceback
51
+ f.write('''```CODE:
52
+ import torch
53
+ from diffusers import DiffusionPipeline
54
+ from diffusers.utils import load_image, export_to_video
55
+
56
+ # switch to "mps" for apple devices
57
+ pipe = DiffusionPipeline.from_pretrained("MCG-NJU/SteadyDancer-14B", dtype=torch.bfloat16, device_map="cuda")
58
+ pipe.to("cuda")
59
+
60
+ prompt = "A man with short gray hair plays a red electric guitar."
61
+ image = load_image(
62
+ "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guitar-man.png"
63
+ )
64
+
65
+ output = pipe(image=image, prompt=prompt).frames[0]
66
+ export_to_video(output, "output.mp4")
67
+ ```
68
+
69
+ ERROR:
70
+ ''')
71
+ traceback.print_exc(file=f)
72
+
73
+ finally:
74
+ from huggingface_hub import upload_file
75
+ upload_file(
76
+ path_or_fileobj='MCG-NJU_SteadyDancer-14B_0.txt',
77
+ repo_id='model-metadata/code_execution_files',
78
+ path_in_repo='MCG-NJU_SteadyDancer-14B_0.txt',
79
+ repo_type='dataset',
80
+ )