Upload ERNIE-4.5-VL-424B-A47B-Base-PT_0.py with huggingface_hub
Browse files
ERNIE-4.5-VL-424B-A47B-Base-PT_0.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# /// script
|
2 |
+
# requires-python = ">=3.12"
|
3 |
+
# dependencies = [
|
4 |
+
# "transformers",
|
5 |
+
# "torch",
|
6 |
+
# ]
|
7 |
+
# ///
|
8 |
+
|
9 |
+
try:
|
10 |
+
# Use a pipeline as a high-level helper
|
11 |
+
from transformers import pipeline
|
12 |
+
|
13 |
+
pipe = pipeline("image-text-to-text", model="baidu/ERNIE-4.5-VL-424B-A47B-Base-PT", 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 |
+
except Exception as e:
|
25 |
+
exception_file = 'baidu_ERNIE-4.5-VL-424B-A47B-Base-PT_0_exception.txt'
|
26 |
+
with open(exception_file, 'w') as f:
|
27 |
+
import traceback
|
28 |
+
traceback.print_exc(file=f)
|
29 |
+
# Upload exception log to HuggingFace
|
30 |
+
from huggingface_hub import upload_file
|
31 |
+
upload_file(
|
32 |
+
path_or_fileobj=exception_file,
|
33 |
+
repo_id='model-metadata/model-code-exception',
|
34 |
+
path_in_repo='09-07-25/baidu_ERNIE-4.5-VL-424B-A47B-Base-PT_0_exception.txt',
|
35 |
+
repo_type='dataset',
|
36 |
+
)
|