ariG23498 HF Staff commited on
Commit
fd22a97
·
verified ·
1 Parent(s): 4f732dd

Upload zai-org_GLM-4.1V-9B-Thinking_0.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. zai-org_GLM-4.1V-9B-Thinking_0.py +33 -0
zai-org_GLM-4.1V-9B-Thinking_0.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "transformers",
5
+ # "torch",
6
+ # ]
7
+ # ///
8
+
9
+ try:
10
+ from transformers import AutoProcessor, Glm4vForConditionalGeneration
11
+ import torch
12
+
13
+ MODEL_PATH = "THUDM/GLM-4.1V-9B-Thinking"
14
+ processor = AutoProcessor.from_pretrained(MODEL_PATH, use_fast=True)
15
+ model = Glm4vForConditionalGeneration.from_pretrained(
16
+ pretrained_model_name_or_path=MODEL_PATH,
17
+ torch_dtype=torch.bfloat16,
18
+ device_map="auto",
19
+ )
20
+ with open('zai-org_GLM-4.1V-9B-Thinking_0.txt', 'w') as f:
21
+ f.write('Everything was good in zai-org_GLM-4.1V-9B-Thinking_0.txt')
22
+ except Exception as e:
23
+ with open('zai-org_GLM-4.1V-9B-Thinking_0.txt', 'w') as f:
24
+ import traceback
25
+ traceback.print_exc(file=f)
26
+ finally:
27
+ from huggingface_hub import upload_file
28
+ upload_file(
29
+ path_or_fileobj='zai-org_GLM-4.1V-9B-Thinking_0.txt',
30
+ repo_id='model-metadata/custom_code_execution_files',
31
+ path_in_repo='zai-org_GLM-4.1V-9B-Thinking_0.txt',
32
+ repo_type='dataset',
33
+ )