Update app.py
Browse files
app.py
CHANGED
@@ -425,10 +425,10 @@ def draw_boxes(image, bounds, color='yellow', width=2):
|
|
425 |
def inference(img, lang):
|
426 |
reader = easyocr.Reader(lang)
|
427 |
bounds = reader.readtext(img.name)
|
428 |
-
im = PIL.Image.open(img.name)
|
429 |
-
draw_boxes(im, bounds)
|
430 |
-
im.save('result.jpg')
|
431 |
-
return [
|
432 |
|
433 |
def compute_tfidf_embeddings(documents1, documents2):
|
434 |
# Combine both lists of words into a single list
|
@@ -449,22 +449,27 @@ def compute_tfidf_embeddings(documents1, documents2):
|
|
449 |
import requests
|
450 |
import base64
|
451 |
def extract_eval(image1,image2,image3,image4):
|
452 |
-
print(image1)
|
453 |
-
ideal_text=extract(image1)
|
454 |
-
print("Extracting Ideal Text \n")
|
455 |
-
print(ideal_text)
|
456 |
-
submitted_text=extract(image3)
|
457 |
-
print("Extracting Submitted Text \n")
|
458 |
-
print(submitted_text)
|
459 |
-
a,b=sim(ideal_text,submitted_text)
|
460 |
-
print(a)
|
461 |
-
text_sim_score=b
|
462 |
model = ResNet50(include_top=False, weights='imagenet', pooling='avg')
|
463 |
diagram_1_embed=return_image_embedding(model,image2)
|
464 |
diagram_2_embed=return_image_embedding(model,image4)
|
465 |
-
diagram_embed_sim_score=util.pytorch_cos_sim(
|
466 |
print("Diagram Embedding Similarity Score \n")
|
467 |
print(diagram_embed_sim_score)
|
|
|
|
|
|
|
|
|
|
|
468 |
|
469 |
|
470 |
|
|
|
425 |
def inference(img, lang):
|
426 |
reader = easyocr.Reader(lang)
|
427 |
bounds = reader.readtext(img.name)
|
428 |
+
#im = PIL.Image.open(img.name)
|
429 |
+
#draw_boxes(im, bounds)
|
430 |
+
#im.save('result.jpg')
|
431 |
+
return [pd.DataFrame(bounds).iloc[: , 1:]]
|
432 |
|
433 |
def compute_tfidf_embeddings(documents1, documents2):
|
434 |
# Combine both lists of words into a single list
|
|
|
449 |
import requests
|
450 |
import base64
|
451 |
def extract_eval(image1,image2,image3,image4):
|
452 |
+
# print(image1)
|
453 |
+
# ideal_text=extract(image1)
|
454 |
+
# print("Extracting Ideal Text \n")
|
455 |
+
# print(ideal_text)
|
456 |
+
# submitted_text=extract(image3)
|
457 |
+
# print("Extracting Submitted Text \n")
|
458 |
+
# print(submitted_text)
|
459 |
+
# a,b=sim(ideal_text,submitted_text)
|
460 |
+
# print(a)
|
461 |
+
# text_sim_score=b
|
462 |
model = ResNet50(include_top=False, weights='imagenet', pooling='avg')
|
463 |
diagram_1_embed=return_image_embedding(model,image2)
|
464 |
diagram_2_embed=return_image_embedding(model,image4)
|
465 |
+
diagram_embed_sim_score=util.pytorch_cos_sim(diagram_1_embed, diagram_2_embed)
|
466 |
print("Diagram Embedding Similarity Score \n")
|
467 |
print(diagram_embed_sim_score)
|
468 |
+
diagram_1_text=inference(image2,'en')
|
469 |
+
diagram_2_text=inference(image4,'en')
|
470 |
+
print(diagram_1_text)
|
471 |
+
print(diagram_2_text)
|
472 |
+
|
473 |
|
474 |
|
475 |
|