SupulKalara commited on
Commit
7c6755e
·
1 Parent(s): 9d6cf42

api-call-working

Browse files
Files changed (1) hide show
  1. main.py +2 -0
main.py CHANGED
@@ -38,6 +38,7 @@ async def ProcessDocument(file: UploadFile):
38
 
39
  @app.post("/submit-doc-base64")
40
  async def ProcessDocument(file: str = Form(...)):
 
41
  str_as_bytes = str.encode(file)
42
  content = b64decode(str_as_bytes)
43
  tokenClassificationOutput, ocr_df, img_size = LabelTokens(content)
@@ -46,6 +47,7 @@ async def ProcessDocument(file: str = Form(...)):
46
 
47
  def LabelTokens(content):
48
  image = Image.open(io.BytesIO(content))
 
49
  ocr_df = config['vision_client'].ocr(content, image)
50
  input_ids, attention_mask, token_type_ids, bbox, token_actual_boxes, offset_mapping = config['processor'].process(ocr_df, image = image)
51
  token_labels = token_classification.classifyTokens(config['ser_model'], input_ids, attention_mask, bbox, offset_mapping)
 
38
 
39
  @app.post("/submit-doc-base64")
40
  async def ProcessDocument(file: str = Form(...)):
41
+ head, file = file.split(',')
42
  str_as_bytes = str.encode(file)
43
  content = b64decode(str_as_bytes)
44
  tokenClassificationOutput, ocr_df, img_size = LabelTokens(content)
 
47
 
48
  def LabelTokens(content):
49
  image = Image.open(io.BytesIO(content))
50
+ image.show()
51
  ocr_df = config['vision_client'].ocr(content, image)
52
  input_ids, attention_mask, token_type_ids, bbox, token_actual_boxes, offset_mapping = config['processor'].process(ocr_df, image = image)
53
  token_labels = token_classification.classifyTokens(config['ser_model'], input_ids, attention_mask, bbox, offset_mapping)