ariG23498 HF Staff commited on
Commit
475f520
·
verified ·
1 Parent(s): cf80021

Upload allenai_olmOCR-2-7B-1025-FP8_1.py with huggingface_hub

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