CoolFace
Datasetpublic

model-metadata/code_python_files

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes14kdownloads
LiquidAI_LFM2.5-VL-1.6B_0.py79 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    # Use a pipeline as a high-level helper24    from transformers import pipeline25    26    pipe = pipeline("image-text-to-text", model="LiquidAI/LFM2.5-VL-1.6B")27    messages = [28        {29            "role": "user",30            "content": [31                {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},32                {"type": "text", "text": "What animal is on the candy?"}33            ]34        },35    ]36    pipe(text=messages)37    with open('LiquidAI_LFM2.5-VL-1.6B_0.txt', 'w', encoding='utf-8') as f:38        f.write('Everything was good in LiquidAI_LFM2.5-VL-1.6B_0.txt')39except Exception as e:40    import os41    from slack_sdk import WebClient42    client = WebClient(token=os.environ['SLACK_TOKEN'])43    client.chat_postMessage(44        channel='#hub-model-metadata-snippets-sprint',45        text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/LiquidAI_LFM2.5-VL-1.6B_0.txt|LiquidAI_LFM2.5-VL-1.6B_0.txt>',46    )47 48    with open('LiquidAI_LFM2.5-VL-1.6B_0.txt', 'a', encoding='utf-8') as f:49        import traceback50        f.write('''```CODE: 51# Use a pipeline as a high-level helper52from transformers import pipeline53 54pipe = pipeline("image-text-to-text", model="LiquidAI/LFM2.5-VL-1.6B")55messages = [56    {57        "role": "user",58        "content": [59            {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},60            {"type": "text", "text": "What animal is on the candy?"}61        ]62    },63]64pipe(text=messages)65```66 67ERROR: 68''')69        traceback.print_exc(file=f)70    71finally:72    from huggingface_hub import upload_file73    upload_file(74        path_or_fileobj='LiquidAI_LFM2.5-VL-1.6B_0.txt',75        repo_id='model-metadata/code_execution_files',76        path_in_repo='LiquidAI_LFM2.5-VL-1.6B_0.txt',77        repo_type='dataset',78    )79