adding tesseract OCR for floorplan detection
This commit is contained in:
parent
508aa02812
commit
d108bf11ee
8 changed files with 153 additions and 29 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import re
|
||||
from PIL import Image
|
||||
from transformers import Pix2StructProcessor, Pix2StructForConditionalGeneration
|
||||
import pytesseract
|
||||
|
||||
def inference(image_path):
|
||||
image = Image.open(image_path)
|
||||
|
|
@ -24,7 +25,14 @@ def extract_total_sqm(deplot_input_str):
|
|||
return max(sqms)
|
||||
|
||||
|
||||
def calculate(image_path):
|
||||
def calculate_model(image_path):
|
||||
output, predictions_tensor = inference(image_path)
|
||||
estimated_sqm = extract_total_sqm()
|
||||
estimated_sqm = extract_total_sqm(output)
|
||||
return estimated_sqm, output, predictions_tensor
|
||||
|
||||
|
||||
def calculate_ocr(image_path):
|
||||
img = Image.open(image_path)
|
||||
text = pytesseract.image_to_string(img)
|
||||
estimated_sqm = extract_total_sqm(text)
|
||||
return estimated_sqm, text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue