Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,11 @@ import gradio as gr
|
|
7 |
from PIL import Image
|
8 |
import base64
|
9 |
from utils import HocrParser
|
|
|
10 |
|
|
|
|
|
|
|
11 |
predictor = ocr_predictor(det_arch='db_mobilenet_v3_large', reco_arch='crnn_vgg16_bn',pretrained=True)
|
12 |
predictor.reco_predictor.model.cfg['vocab']='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!”#$%&’()*+,-./:;<=>?@[]^_`{|}~°£€¥¢฿áàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệóòỏõọôốồổộỗơớờởợỡúùủũụưứừửữựiíìỉĩịýỳỷỹỵÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆÓÒỎÕỌÔỐỒỔỘỖƠỚỜỞỢỠÚÙỦŨỤƯỨỪỬỮỰIÍÌỈĨỊÝỲỶỸỴ'
|
13 |
title="DocTR OCR (PDL Demo)"
|
@@ -29,7 +33,11 @@ def greet(img):
|
|
29 |
res=res + " " + obj3.value
|
30 |
res=res + "\n"
|
31 |
res=res + "\n"
|
32 |
-
|
|
|
|
|
|
|
|
|
33 |
_output_name = "RESULT_OCR.txt"
|
34 |
_output_name_pdf="RESULT_OCR.pdf"
|
35 |
|
|
|
7 |
from PIL import Image
|
8 |
import base64
|
9 |
from utils import HocrParser
|
10 |
+
import google.generativeai as genai
|
11 |
|
12 |
+
api_key = 'AIzaSyB7-RzBwTAfVA-7ZGk2mEOQwOxshpwzhpM' # put your API key here
|
13 |
+
genai.configure(api_key=api_key)
|
14 |
+
geminiModel = genai.GenerativeModel(model_name='gemini-pro')
|
15 |
predictor = ocr_predictor(det_arch='db_mobilenet_v3_large', reco_arch='crnn_vgg16_bn',pretrained=True)
|
16 |
predictor.reco_predictor.model.cfg['vocab']='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!”#$%&’()*+,-./:;<=>?@[]^_`{|}~°£€¥¢฿áàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệóòỏõọôốồổộỗơớờởợỡúùủũụưứừửữựiíìỉĩịýỳỷỹỵÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆÓÒỎÕỌÔỐỒỔỘỖƠỚỜỞỢỠÚÙỦŨỤƯỨỪỬỮỰIÍÌỈĨỊÝỲỶỸỴ'
|
17 |
title="DocTR OCR (PDL Demo)"
|
|
|
33 |
res=res + " " + obj3.value
|
34 |
res=res + "\n"
|
35 |
res=res + "\n"
|
36 |
+
# generate text
|
37 |
+
prompt = "take this peace of information and give all the information in point wise better format also give some recomendation related to them: " + res
|
38 |
+
# print(prompt)
|
39 |
+
response = geminiModel.generate_content(prompt)
|
40 |
+
res = response.text
|
41 |
_output_name = "RESULT_OCR.txt"
|
42 |
_output_name_pdf="RESULT_OCR.pdf"
|
43 |
|