Upload LiquidAI_LFM2-VL-3B_0.py with huggingface_hub
Browse files- LiquidAI_LFM2-VL-3B_0.py +40 -0
 
    	
        LiquidAI_LFM2-VL-3B_0.py
    ADDED
    
    | 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
| 
         | 
|
| 1 | 
         
            +
            # /// script
         
     | 
| 2 | 
         
            +
            # requires-python = ">=3.12"
         
     | 
| 3 | 
         
            +
            # dependencies = [
         
     | 
| 4 | 
         
            +
            #     "torch",
         
     | 
| 5 | 
         
            +
            #     "torchvision",
         
     | 
| 6 | 
         
            +
            #     "transformers",
         
     | 
| 7 | 
         
            +
            #     "accelerate",
         
     | 
| 8 | 
         
            +
            #     "peft",
         
     | 
| 9 | 
         
            +
            # ]
         
     | 
| 10 | 
         
            +
            # ///
         
     | 
| 11 | 
         
            +
             
     | 
| 12 | 
         
            +
            try:
         
     | 
| 13 | 
         
            +
                # Use a pipeline as a high-level helper
         
     | 
| 14 | 
         
            +
                from transformers import pipeline
         
     | 
| 15 | 
         
            +
                
         
     | 
| 16 | 
         
            +
                pipe = pipeline("image-text-to-text", model="LiquidAI/LFM2-VL-3B")
         
     | 
| 17 | 
         
            +
                messages = [
         
     | 
| 18 | 
         
            +
                    {
         
     | 
| 19 | 
         
            +
                        "role": "user",
         
     | 
| 20 | 
         
            +
                        "content": [
         
     | 
| 21 | 
         
            +
                            {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
         
     | 
| 22 | 
         
            +
                            {"type": "text", "text": "What animal is on the candy?"}
         
     | 
| 23 | 
         
            +
                        ]
         
     | 
| 24 | 
         
            +
                    },
         
     | 
| 25 | 
         
            +
                ]
         
     | 
| 26 | 
         
            +
                pipe(text=messages)
         
     | 
| 27 | 
         
            +
                with open('LiquidAI_LFM2-VL-3B_0.txt', 'w', encoding='utf-8') as f:
         
     | 
| 28 | 
         
            +
                    f.write('Everything was good in LiquidAI_LFM2-VL-3B_0.txt')
         
     | 
| 29 | 
         
            +
            except Exception as e:
         
     | 
| 30 | 
         
            +
                with open('LiquidAI_LFM2-VL-3B_0.txt', 'w', encoding='utf-8') as f:
         
     | 
| 31 | 
         
            +
                    import traceback
         
     | 
| 32 | 
         
            +
                    traceback.print_exc(file=f)
         
     | 
| 33 | 
         
            +
            finally:
         
     | 
| 34 | 
         
            +
                from huggingface_hub import upload_file
         
     | 
| 35 | 
         
            +
                upload_file(
         
     | 
| 36 | 
         
            +
                    path_or_fileobj='LiquidAI_LFM2-VL-3B_0.txt',
         
     | 
| 37 | 
         
            +
                    repo_id='model-metadata/code_execution_files',
         
     | 
| 38 | 
         
            +
                    path_in_repo='LiquidAI_LFM2-VL-3B_0.txt',
         
     | 
| 39 | 
         
            +
                    repo_type='dataset',
         
     | 
| 40 | 
         
            +
                )
         
     |