ariG23498 HF Staff commited on
Commit
80d0f16
·
verified ·
1 Parent(s): 035e10c

Upload AvitoTech_avision_0.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. AvitoTech_avision_0.py +71 -0
AvitoTech_avision_0.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "torch",
5
+ # "torchvision",
6
+ # "transformers",
7
+ # "diffusers",
8
+ # "sentence-transformers",
9
+ # "accelerate",
10
+ # "peft",
11
+ # "slack-sdk",
12
+ # ]
13
+ # ///
14
+
15
+ try:
16
+ # Use a pipeline as a high-level helper
17
+ from transformers import pipeline
18
+
19
+ pipe = pipeline("image-text-to-text", model="AvitoTech/avision")
20
+ messages = [
21
+ {
22
+ "role": "user",
23
+ "content": [
24
+ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
25
+ {"type": "text", "text": "What animal is on the candy?"}
26
+ ]
27
+ },
28
+ ]
29
+ pipe(text=messages)
30
+ with open('AvitoTech_avision_0.txt', 'w', encoding='utf-8') as f:
31
+ f.write('Everything was good in AvitoTech_avision_0.txt')
32
+ except Exception as e:
33
+ import os
34
+ from slack_sdk import WebClient
35
+ client = WebClient(token=os.environ['SLACK_TOKEN'])
36
+ client.chat_postMessage(
37
+ channel='#hub-model-metadata-snippets-sprint',
38
+ text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/AvitoTech_avision_0.txt|AvitoTech_avision_0.txt>',
39
+ )
40
+
41
+ with open('AvitoTech_avision_0.txt', 'a', encoding='utf-8') as f:
42
+ import traceback
43
+ f.write('''```CODE:
44
+ # Use a pipeline as a high-level helper
45
+ from transformers import pipeline
46
+
47
+ pipe = pipeline("image-text-to-text", model="AvitoTech/avision")
48
+ messages = [
49
+ {
50
+ "role": "user",
51
+ "content": [
52
+ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
53
+ {"type": "text", "text": "What animal is on the candy?"}
54
+ ]
55
+ },
56
+ ]
57
+ pipe(text=messages)
58
+ ```
59
+
60
+ ERROR:
61
+ ''')
62
+ traceback.print_exc(file=f)
63
+
64
+ finally:
65
+ from huggingface_hub import upload_file
66
+ upload_file(
67
+ path_or_fileobj='AvitoTech_avision_0.txt',
68
+ repo_id='model-metadata/code_execution_files',
69
+ path_in_repo='AvitoTech_avision_0.txt',
70
+ repo_type='dataset',
71
+ )