model-metadata/code_python_files
013k
1# /// script2# requires-python = ">=3.12"3# dependencies = [4# "numpy",5# "einops",6# "pandas",7# "protobuf",8# "torch",9# "torchvision",10# "transformers",11# "timm",12# "diffusers",13# "sentence-transformers",14# "accelerate",15# "peft",16# "slack-sdk",17# ]18# ///19 20try:21 # Use a pipeline as a high-level helper22 from transformers import pipeline23 24 pipe = pipeline("image-text-to-text", model="LiquidAI/LFM2-VL-3B")25 messages = [26 {27 "role": "user",28 "content": [29 {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},30 {"type": "text", "text": "What animal is on the candy?"}31 ]32 },33 ]34 pipe(text=messages)35 with open('LiquidAI_LFM2-VL-3B_0.txt', 'w', encoding='utf-8') as f:36 f.write('Everything was good in LiquidAI_LFM2-VL-3B_0.txt')37except Exception as e:38 import os39 from slack_sdk import WebClient40 client = WebClient(token=os.environ['SLACK_TOKEN'])41 client.chat_postMessage(42 channel='#hub-model-metadata-snippets-sprint',43 text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/LiquidAI_LFM2-VL-3B_0.txt|LiquidAI_LFM2-VL-3B_0.txt>',44 )45 46 with open('LiquidAI_LFM2-VL-3B_0.txt', 'a', encoding='utf-8') as f:47 import traceback48 f.write('''```CODE: 49# Use a pipeline as a high-level helper50from transformers import pipeline51 52pipe = pipeline("image-text-to-text", model="LiquidAI/LFM2-VL-3B")53messages = [54 {55 "role": "user",56 "content": [57 {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},58 {"type": "text", "text": "What animal is on the candy?"}59 ]60 },61]62pipe(text=messages)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='LiquidAI_LFM2-VL-3B_0.txt',73 repo_id='model-metadata/code_execution_files',74 path_in_repo='LiquidAI_LFM2-VL-3B_0.txt',75 repo_type='dataset',76 )77 