Ravi25 commited on
Commit
27b85fa
1 Parent(s): 6edcc42

first push

Browse files
Files changed (2) hide show
  1. app.py +26 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+ from PIL import Image
4
+ import requests
5
+ from io import BytesIO
6
+
7
+ url = "https://d2h50zujfkj84t.cloudfront.net/product_images/Screenshot_2024-09-03_135657.png"
8
+ response = requests.get(url)
9
+ image = Image.open(BytesIO(response.content))
10
+
11
+
12
+ model = AutoModelForCausalLM.from_pretrained(
13
+ "qresearch/llama-3.1-8B-vision-378",
14
+ trust_remote_code=True,
15
+ torch_dtype=torch.float16,
16
+ ).to("cpu")
17
+
18
+ tokenizer = AutoTokenizer.from_pretrained("qresearch/llama-3.1-8B-vision-378", use_fast=True,)
19
+
20
+ print(
21
+ model.answer_question(
22
+ image, "Briefly describe the image", tokenizer, max_new_tokens=128, do_sample=True, temperature=0.3
23
+ ),
24
+ )
25
+
26
+
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ transformers
3
+ pillow