Upload google_gemma-3n-E4B-it_4.py with huggingface_hub
Browse files- google_gemma-3n-E4B-it_4.py +30 -0
google_gemma-3n-E4B-it_4.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# /// script
|
2 |
+
# requires-python = ">=3.12"
|
3 |
+
# dependencies = [
|
4 |
+
# "transformers",
|
5 |
+
# "torch",
|
6 |
+
# ]
|
7 |
+
# ///
|
8 |
+
|
9 |
+
try:
|
10 |
+
from transformers import AutoModelForImageTextToText, AutoProcessor
|
11 |
+
|
12 |
+
processor = AutoProcessor.from_pretrained(GEMMA_PATH)
|
13 |
+
model = AutoModelForImageTextToText.from_pretrained(GEMMA_PATH, torch_dtype="auto", device_map="auto")
|
14 |
+
|
15 |
+
print(f"Device: {model.device}")
|
16 |
+
print(f"DType: {model.dtype}")
|
17 |
+
with open('google_gemma-3n-E4B-it_4.txt', 'w') as f:
|
18 |
+
f.write('Everything was good in google_gemma-3n-E4B-it_4.txt')
|
19 |
+
except Exception as e:
|
20 |
+
with open('google_gemma-3n-E4B-it_4.txt', 'w') as f:
|
21 |
+
import traceback
|
22 |
+
traceback.print_exc(file=f)
|
23 |
+
finally:
|
24 |
+
from huggingface_hub import upload_file
|
25 |
+
upload_file(
|
26 |
+
path_or_fileobj='google_gemma-3n-E4B-it_4.txt',
|
27 |
+
repo_id='model-metadata/custom_code_execution_files',
|
28 |
+
path_in_repo='google_gemma-3n-E4B-it_4.txt',
|
29 |
+
repo_type='dataset',
|
30 |
+
)
|