ariG23498 HF Staff commited on
Commit
0a2db76
·
verified ·
1 Parent(s): 5960c4c

Upload allenai_olmOCR-7B-0725_1.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. allenai_olmOCR-7B-0725_1.py +28 -0
allenai_olmOCR-7B-0725_1.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "transformers",
5
+ # "torch",
6
+ # ]
7
+ # ///
8
+
9
+ try:
10
+ # Load model directly
11
+ from transformers import AutoProcessor, AutoModelForVision2Seq
12
+
13
+ processor = AutoProcessor.from_pretrained("allenai/olmOCR-7B-0725")
14
+ model = AutoModelForVision2Seq.from_pretrained("allenai/olmOCR-7B-0725")
15
+ with open('allenai_olmOCR-7B-0725_1.txt', 'w') as f:
16
+ f.write('Everything was good in allenai_olmOCR-7B-0725_1.txt')
17
+ except Exception as e:
18
+ with open('allenai_olmOCR-7B-0725_1.txt', 'w') as f:
19
+ import traceback
20
+ traceback.print_exc(file=f)
21
+ finally:
22
+ from huggingface_hub import upload_file
23
+ upload_file(
24
+ path_or_fileobj='allenai_olmOCR-7B-0725_1.txt',
25
+ repo_id='model-metadata/custom_code_execution_files',
26
+ path_in_repo='allenai_olmOCR-7B-0725_1.txt',
27
+ repo_type='dataset',
28
+ )