Upload ByteDance_Video-As-Prompt-Wan2.1-14B_2.py with huggingface_hub
Browse files
ByteDance_Video-As-Prompt-Wan2.1-14B_2.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# /// script
|
| 2 |
+
# requires-python = ">=3.12"
|
| 3 |
+
# dependencies = [
|
| 4 |
+
# "torch",
|
| 5 |
+
# "torchvision",
|
| 6 |
+
# "transformers",
|
| 7 |
+
# "accelerate",
|
| 8 |
+
# "peft",
|
| 9 |
+
# "slack-sdk",
|
| 10 |
+
# ]
|
| 11 |
+
# ///
|
| 12 |
+
|
| 13 |
+
try:
|
| 14 |
+
import torch
|
| 15 |
+
from diffusers import DiffusionPipeline
|
| 16 |
+
from diffusers.utils import load_image, export_to_video
|
| 17 |
+
|
| 18 |
+
pipe = DiffusionPipeline.from_pretrained("ByteDance/Video-As-Prompt-Wan2.1-14B", torch_dtype=torch.float16)
|
| 19 |
+
pipe.to("cuda")
|
| 20 |
+
|
| 21 |
+
prompt = "A man with short gray hair plays a red electric guitar."
|
| 22 |
+
image = load_image(
|
| 23 |
+
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guitar-man.png"
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
output = pipe(image=image, prompt=prompt).frames[0]
|
| 27 |
+
export_to_video(output, "output.mp4")
|
| 28 |
+
with open('ByteDance_Video-As-Prompt-Wan2.1-14B_2.txt', 'w', encoding='utf-8') as f:
|
| 29 |
+
f.write('Everything was good in ByteDance_Video-As-Prompt-Wan2.1-14B_2.txt')
|
| 30 |
+
except Exception as e:
|
| 31 |
+
import os
|
| 32 |
+
from slack_sdk import WebClient
|
| 33 |
+
client = WebClient(token=os.environ['SLACK_TOKEN'])
|
| 34 |
+
client.chat_postMessage(
|
| 35 |
+
channel='#exp-slack-alerts',
|
| 36 |
+
text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/ByteDance_Video-As-Prompt-Wan2.1-14B_2.txt|ByteDance_Video-As-Prompt-Wan2.1-14B_2.txt>',
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
with open('ByteDance_Video-As-Prompt-Wan2.1-14B_2.txt', 'a', encoding='utf-8') as f:
|
| 40 |
+
import traceback
|
| 41 |
+
f.write('''```CODE:
|
| 42 |
+
import torch
|
| 43 |
+
from diffusers import DiffusionPipeline
|
| 44 |
+
from diffusers.utils import load_image, export_to_video
|
| 45 |
+
|
| 46 |
+
pipe = DiffusionPipeline.from_pretrained("ByteDance/Video-As-Prompt-Wan2.1-14B", torch_dtype=torch.float16)
|
| 47 |
+
pipe.to("cuda")
|
| 48 |
+
|
| 49 |
+
prompt = "A man with short gray hair plays a red electric guitar."
|
| 50 |
+
image = load_image(
|
| 51 |
+
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guitar-man.png"
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
output = pipe(image=image, prompt=prompt).frames[0]
|
| 55 |
+
export_to_video(output, "output.mp4")
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
ERROR:
|
| 59 |
+
''')
|
| 60 |
+
traceback.print_exc(file=f)
|
| 61 |
+
|
| 62 |
+
finally:
|
| 63 |
+
from huggingface_hub import upload_file
|
| 64 |
+
upload_file(
|
| 65 |
+
path_or_fileobj='ByteDance_Video-As-Prompt-Wan2.1-14B_2.txt',
|
| 66 |
+
repo_id='model-metadata/code_execution_files',
|
| 67 |
+
path_in_repo='ByteDance_Video-As-Prompt-Wan2.1-14B_2.txt',
|
| 68 |
+
repo_type='dataset',
|
| 69 |
+
)
|