ariG23498 HF Staff commited on
Commit
b012054
·
verified ·
1 Parent(s): 114e093

Upload custom_code/bharatgenai_patram-7b-instruct.py with huggingface_hub

Browse files
custom_code/bharatgenai_patram-7b-instruct.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "transformers",
5
+ # "torch",
6
+ # ]
7
+ # ///
8
+
9
+ # Use a pipeline as a high-level helper
10
+ from transformers import pipeline
11
+
12
+ pipe = pipeline("image-text-to-text", model="bharatgenai/patram-7b-instruct", trust_remote_code=True)
13
+ messages = [
14
+ {
15
+ "role": "user",
16
+ "content": [
17
+ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
18
+ {"type": "text", "text": "What animal is on the candy?"}
19
+ ]
20
+ },
21
+ ]
22
+ pipe(text=messages)
23
+ # Load model directly
24
+ from transformers import AutoModelForCausalLM
25
+ model = AutoModelForCausalLM.from_pretrained("bharatgenai/patram-7b-instruct", trust_remote_code=True)