Divyansh12 commited on
Commit
06672c1
·
verified ·
1 Parent(s): 6b236d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -6
app.py CHANGED
@@ -19,20 +19,17 @@ def load_model(model_name):
19
 
20
  # Function to run the GOT model for multilingual OCR
21
  @st.cache_data
22
- def run_GOT(_image, tokenizer, model):
23
  unique_id = str(uuid.uuid4())
24
  image_path = f"{unique_id}.png"
25
 
26
  _image.save(image_path) # Save the image using the underscore variable
27
- st.write(f"Saved image to {image_path}")
28
 
29
  try:
30
  # Use the model to extract text
31
- res = model.chat(tokenizer, image_path, ocr_type='ocr') # Extract plain text
32
- st.write(f"Raw result: {res}") # Debug output
33
  return res
34
  except Exception as e:
35
- st.error(f"Error: {str(e)}") # Display any errors
36
  return f"Error: {str(e)}"
37
  finally:
38
  # Clean up the saved image
@@ -85,4 +82,3 @@ if uploaded_image:
85
  st.markdown(highlighted_text, unsafe_allow_html=True)
86
  else:
87
  st.error(result_text)
88
-
 
19
 
20
  # Function to run the GOT model for multilingual OCR
21
  @st.cache_data
22
+ def run_GOT(_image, _tokenizer, _model):
23
  unique_id = str(uuid.uuid4())
24
  image_path = f"{unique_id}.png"
25
 
26
  _image.save(image_path) # Save the image using the underscore variable
 
27
 
28
  try:
29
  # Use the model to extract text
30
+ res = _model.chat(_tokenizer, image_path, ocr_type='ocr') # Extract plain text
 
31
  return res
32
  except Exception as e:
 
33
  return f"Error: {str(e)}"
34
  finally:
35
  # Clean up the saved image
 
82
  st.markdown(highlighted_text, unsafe_allow_html=True)
83
  else:
84
  st.error(result_text)