ariG23498 HF Staff commited on
Commit
349ae03
·
verified ·
1 Parent(s): cecf4e4

Upload Qwen_Qwen2.5-VL-7B-Instruct_0.py with huggingface_hub

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