model-metadata/custom_code_py_files
19.5k
1# /// script2# requires-python = ">=3.12"3# dependencies = [4# "transformers",5# "torch",6# ]7# ///8 9try:10 # Use a pipeline as a high-level helper11 from transformers import pipeline12 13 pipe = pipeline("image-text-to-text", model="OpenGVLab/InternVL3_5-38B", trust_remote_code=True)14 messages = [15 {16 "role": "user",17 "content": [18 {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},19 {"type": "text", "text": "What animal is on the candy?"}20 ]21 },22 ]23 pipe(text=messages)24 with open('OpenGVLab_InternVL3_5-38B_0.txt', 'w') as f:25 f.write('Everything was good in OpenGVLab_InternVL3_5-38B_0.txt')26except Exception as e:27 with open('OpenGVLab_InternVL3_5-38B_0.txt', 'w') as f:28 import traceback29 traceback.print_exc(file=f)30finally:31 from huggingface_hub import upload_file32 upload_file(33 path_or_fileobj='OpenGVLab_InternVL3_5-38B_0.txt',34 repo_id='model-metadata/custom_code_execution_files',35 path_in_repo='OpenGVLab_InternVL3_5-38B_0.txt',36 repo_type='dataset',37 )