Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
from transformers import AutoModel, AutoTokenizer
|
2 |
|
3 |
-
tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
|
4 |
-
model = AutoModel.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True, low_cpu_mem_usage=True, device_map='cuda', use_safetensors=True, pad_token_id=tokenizer.eos_token_id)
|
5 |
-
model = model.eval().cuda()
|
6 |
|
7 |
|
8 |
# input your test image
|
9 |
-
image_file = 'car.jpg'
|
10 |
|
11 |
# plain texts OCR
|
12 |
-
res = model.chat(tokenizer, image_file, ocr_type='ocr')
|
13 |
|
14 |
# format texts OCR:
|
15 |
# res = model.chat(tokenizer, image_file, ocr_type='format')
|
@@ -27,16 +27,16 @@ res = model.chat(tokenizer, image_file, ocr_type='ocr')
|
|
27 |
# render the formatted OCR results:
|
28 |
# res = model.chat(tokenizer, image_file, ocr_type='format', render=True, save_render_file = './demo.html')
|
29 |
|
30 |
-
print(res)
|
31 |
|
32 |
-
|
33 |
-
|
34 |
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
1 |
+
# from transformers import AutoModel, AutoTokenizer
|
2 |
|
3 |
+
# tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
|
4 |
+
# model = AutoModel.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True, low_cpu_mem_usage=True, device_map='cuda', use_safetensors=True, pad_token_id=tokenizer.eos_token_id)
|
5 |
+
# model = model.eval().cuda()
|
6 |
|
7 |
|
8 |
# input your test image
|
9 |
+
# image_file = 'car.jpg'
|
10 |
|
11 |
# plain texts OCR
|
12 |
+
# res = model.chat(tokenizer, image_file, ocr_type='ocr')
|
13 |
|
14 |
# format texts OCR:
|
15 |
# res = model.chat(tokenizer, image_file, ocr_type='format')
|
|
|
27 |
# render the formatted OCR results:
|
28 |
# res = model.chat(tokenizer, image_file, ocr_type='format', render=True, save_render_file = './demo.html')
|
29 |
|
30 |
+
# print(res)
|
31 |
|
32 |
+
import google.generativeai as genai
|
33 |
+
import os
|
34 |
|
35 |
+
genai.configure(api_key=os.environ["AIzaSyB5WiEJf_yLMD1dMQf305EAbaPTzF_QD-I"])
|
36 |
|
37 |
+
model = genai.GenerativeModel('gemini-1.5-flash')
|
38 |
+
response = model.generate_content(
|
39 |
+
text_input="the color of the car is ?",
|
40 |
+
image_input="car.jpg"
|
41 |
+
)
|
42 |
+
print(response)
|