Spaces:
Sleeping
Sleeping
liudongqing
commited on
Commit
·
76209e3
1
Parent(s):
d398fa0
reduce the tokens
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ model_id = "unsloth/Llama-3.2-11B-Vision"
|
|
16 |
model = AutoModelForImageTextToText.from_pretrained(
|
17 |
model_id,
|
18 |
torch_dtype=torch.bfloat16,
|
19 |
-
|
20 |
)
|
21 |
processor = AutoProcessor.from_pretrained(model_id)
|
22 |
|
@@ -32,7 +32,7 @@ def score_it(input_img):
|
|
32 |
prompt = "<|image|><|begin_of_text|>extract the text in this picture"
|
33 |
inputs = processor(image, prompt, return_tensors="pt").to(model.device)
|
34 |
|
35 |
-
output = model.generate(**inputs, max_new_tokens=
|
36 |
return processor.decode(output[0])
|
37 |
|
38 |
|
|
|
16 |
model = AutoModelForImageTextToText.from_pretrained(
|
17 |
model_id,
|
18 |
torch_dtype=torch.bfloat16,
|
19 |
+
device_map="auto",
|
20 |
)
|
21 |
processor = AutoProcessor.from_pretrained(model_id)
|
22 |
|
|
|
32 |
prompt = "<|image|><|begin_of_text|>extract the text in this picture"
|
33 |
inputs = processor(image, prompt, return_tensors="pt").to(model.device)
|
34 |
|
35 |
+
output = model.generate(**inputs, max_new_tokens=200)
|
36 |
return processor.decode(output[0])
|
37 |
|
38 |
|