Update app.py
Browse files
app.py
CHANGED
@@ -427,11 +427,11 @@ def draw_boxes(image, bounds, color='yellow', width=2):
|
|
427 |
|
428 |
def inference(img, lang):
|
429 |
reader = easyocr.Reader(lang)
|
430 |
-
bounds = reader.readtext(img)
|
431 |
#im = PIL.Image.open(img.name)
|
432 |
#draw_boxes(im, bounds)
|
433 |
#im.save('result.jpg')
|
434 |
-
return
|
435 |
|
436 |
def compute_tfidf_embeddings(documents1, documents2):
|
437 |
# Combine both lists of words into a single list
|
@@ -470,8 +470,12 @@ def extract_eval(Ideal_Answer_Text,Ideal_Answer_Diagram,Submitted_Answer_Text,Su
|
|
470 |
print(str(int(float(str(diagram_embed_sim_score).split("[")[2].split("]")[0])*10.0)))
|
471 |
diagram_1_text=inference(Ideal_Answer_Diagram,['en'])
|
472 |
diagram_2_text=inference(Submitted_Answer_Diagram,['en'])
|
473 |
-
print(pd.DataFrame(diagram_1_text
|
474 |
-
print(pd.DataFrame(
|
|
|
|
|
|
|
|
|
475 |
|
476 |
|
477 |
|
|
|
427 |
|
428 |
def inference(img, lang):
|
429 |
reader = easyocr.Reader(lang)
|
430 |
+
bounds = reader.readtext(img,detail=0)
|
431 |
#im = PIL.Image.open(img.name)
|
432 |
#draw_boxes(im, bounds)
|
433 |
#im.save('result.jpg')
|
434 |
+
return bounds
|
435 |
|
436 |
def compute_tfidf_embeddings(documents1, documents2):
|
437 |
# Combine both lists of words into a single list
|
|
|
470 |
print(str(int(float(str(diagram_embed_sim_score).split("[")[2].split("]")[0])*10.0)))
|
471 |
diagram_1_text=inference(Ideal_Answer_Diagram,['en'])
|
472 |
diagram_2_text=inference(Submitted_Answer_Diagram,['en'])
|
473 |
+
print(pd.DataFrame(diagram_1_text)
|
474 |
+
print(pd.DataFrame(diagram_2_text)
|
475 |
+
diagram_1_text_embed,diagram_2_text_embed=compute_tfidf_embeddings(diagram_1_text,diagram_2_text)
|
476 |
+
diagram_text_similarity=util.pytorch_cos_sim(diagram_1_text_embed,diagram_2_text_embed)
|
477 |
+
print("Diagram Text Embedding Similarity Score \n")
|
478 |
+
print(str(int(float(str(diagram_text_similarity).split("[")[2].split("]")[0])*10.0)))
|
479 |
|
480 |
|
481 |
|