CoolFace
Datasetpublic

model-metadata/code_python_files

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes14kdownloads
lightx2v_Wan2.2-Distill-Loras_0.py77 linesDownload Raw Back to root
1# /// script2# 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 22try:23    import torch24    from diffusers import DiffusionPipeline25    from diffusers.utils import load_image, export_to_video26    27    # switch to "mps" for apple devices28    pipe = DiffusionPipeline.from_pretrained("Wan-AI/Wan2.2-I2V-A14B", dtype=torch.bfloat16, device_map="cuda")29    pipe.load_lora_weights("lightx2v/Wan2.2-Distill-Loras")30    31    prompt = "A man with short gray hair plays a red electric guitar."32    input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guitar-man.png")33    34    image = pipe(image=input_image, prompt=prompt).frames[0]35    export_to_video(output, "output.mp4")36    with open('lightx2v_Wan2.2-Distill-Loras_0.txt', 'w', encoding='utf-8') as f:37        f.write('Everything was good in lightx2v_Wan2.2-Distill-Loras_0.txt')38except Exception as e:39    import os40    from slack_sdk import WebClient41    client = WebClient(token=os.environ['SLACK_TOKEN'])42    client.chat_postMessage(43        channel='#hub-model-metadata-snippets-sprint',44        text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/lightx2v_Wan2.2-Distill-Loras_0.txt|lightx2v_Wan2.2-Distill-Loras_0.txt>',45    )46 47    with open('lightx2v_Wan2.2-Distill-Loras_0.txt', 'a', encoding='utf-8') as f:48        import traceback49        f.write('''```CODE: 50import torch51from diffusers import DiffusionPipeline52from diffusers.utils import load_image, export_to_video53 54# switch to "mps" for apple devices55pipe = DiffusionPipeline.from_pretrained("Wan-AI/Wan2.2-I2V-A14B", dtype=torch.bfloat16, device_map="cuda")56pipe.load_lora_weights("lightx2v/Wan2.2-Distill-Loras")57 58prompt = "A man with short gray hair plays a red electric guitar."59input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guitar-man.png")60 61image = pipe(image=input_image, prompt=prompt).frames[0]62export_to_video(output, "output.mp4")63```64 65ERROR: 66''')67        traceback.print_exc(file=f)68    69finally:70    from huggingface_hub import upload_file71    upload_file(72        path_or_fileobj='lightx2v_Wan2.2-Distill-Loras_0.txt',73        repo_id='model-metadata/code_execution_files',74        path_in_repo='lightx2v_Wan2.2-Distill-Loras_0.txt',75        repo_type='dataset',76    )77