ariG23498 HF Staff commited on
Commit
970a20c
·
verified ·
1 Parent(s): 9b1a674

Upload ByteDance_Dolphin-v2_0.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. ByteDance_Dolphin-v2_0.py +78 -0
ByteDance_Dolphin-v2_0.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # 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
+
22
+ try:
23
+ # Use a pipeline as a high-level helper
24
+ from transformers import pipeline
25
+
26
+ pipe = pipeline("image-text-to-text", model="ByteDance/Dolphin-v2")
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('ByteDance_Dolphin-v2_0.txt', 'w', encoding='utf-8') as f:
38
+ f.write('Everything was good in ByteDance_Dolphin-v2_0.txt')
39
+ except Exception as e:
40
+ import os
41
+ from slack_sdk import WebClient
42
+ 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/ByteDance_Dolphin-v2_0.txt|ByteDance_Dolphin-v2_0.txt>',
46
+ )
47
+
48
+ with open('ByteDance_Dolphin-v2_0.txt', 'a', encoding='utf-8') as f:
49
+ import traceback
50
+ f.write('''```CODE:
51
+ # Use a pipeline as a high-level helper
52
+ from transformers import pipeline
53
+
54
+ pipe = pipeline("image-text-to-text", model="ByteDance/Dolphin-v2")
55
+ messages = [
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
+ ]
64
+ pipe(text=messages)
65
+ ```
66
+
67
+ ERROR:
68
+ ''')
69
+ traceback.print_exc(file=f)
70
+
71
+ finally:
72
+ from huggingface_hub import upload_file
73
+ upload_file(
74
+ path_or_fileobj='ByteDance_Dolphin-v2_0.txt',
75
+ repo_id='model-metadata/code_execution_files',
76
+ path_in_repo='ByteDance_Dolphin-v2_0.txt',
77
+ repo_type='dataset',
78
+ )