Update app.py
Browse files
app.py
CHANGED
@@ -297,14 +297,14 @@ def extract(image):
|
|
297 |
# im=im.convert("L")
|
298 |
# im.save("demo.jpeg")
|
299 |
# print("#### Image Saved #######")
|
300 |
-
|
301 |
|
302 |
|
303 |
|
304 |
-
|
305 |
|
306 |
#print("Started Processing")
|
307 |
-
image = line_image
|
308 |
pixel_values = processor(images=image, return_tensors="pt").pixel_values
|
309 |
|
310 |
generated_ids = model.generate(pixel_values)
|
@@ -452,11 +452,11 @@ def extract_eval(image1,image2,image3,image4):
|
|
452 |
print(a)
|
453 |
text_sim_score=b
|
454 |
model = ResNet50(include_top=False, weights='imagenet', pooling='avg')
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
|
461 |
|
462 |
|
|
|
297 |
# im=im.convert("L")
|
298 |
# im.save("demo.jpeg")
|
299 |
# print("#### Image Saved #######")
|
300 |
+
imageio.imwrite('demo.jpeg',line_image)
|
301 |
|
302 |
|
303 |
|
304 |
+
image = Image.open("demo.jpeg").convert("RGB")
|
305 |
|
306 |
#print("Started Processing")
|
307 |
+
#image = line_image
|
308 |
pixel_values = processor(images=image, return_tensors="pt").pixel_values
|
309 |
|
310 |
generated_ids = model.generate(pixel_values)
|
|
|
452 |
print(a)
|
453 |
text_sim_score=b
|
454 |
model = ResNet50(include_top=False, weights='imagenet', pooling='avg')
|
455 |
+
diagram_1_embed=return_image_embedding(model,image2)
|
456 |
+
diagram_2_embed=return_image_embedding(model,image4)
|
457 |
+
diagram_embed_sim_score=util.pytorch_cos_sim(embedding_1, embedding_2)
|
458 |
+
print("Diagram Embedding Similarity Score \n")
|
459 |
+
print(diagram_embed_sim_score)
|
460 |
|
461 |
|
462 |
|