ariG23498 HF Staff commited on
Commit
ed84e9e
·
verified ·
1 Parent(s): 1eddd82

Upload google_gemma-3n-E4B-it_5.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. google_gemma-3n-E4B-it_5.py +33 -0
google_gemma-3n-E4B-it_5.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
+ prompt = {
11
+ "role": "user",
12
+ "content": [
13
+ {"type": "image", "image": f"{RESOURCE_URL_PREFIX}kitchen_painting.jpg"},
14
+ {"type": "text", "text": "describe the image in detail"},
15
+ ]
16
+ }
17
+
18
+ chat = ChatState(model, processor)
19
+ chat.send_message(prompt, max_tokens=512)
20
+ with open('google_gemma-3n-E4B-it_5.txt', 'w') as f:
21
+ f.write('Everything was good in google_gemma-3n-E4B-it_5.txt')
22
+ except Exception as e:
23
+ with open('google_gemma-3n-E4B-it_5.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='google_gemma-3n-E4B-it_5.txt',
30
+ repo_id='model-metadata/custom_code_execution_files',
31
+ path_in_repo='google_gemma-3n-E4B-it_5.txt',
32
+ repo_type='dataset',
33
+ )