Neurolingua commited on
Commit
29191e5
1 Parent(s): 93f2b25

Update other_function.py

Browse files
Files changed (1) hide show
  1. other_function.py +15 -0
other_function.py CHANGED
@@ -7,12 +7,27 @@ from io import BytesIO
7
  import pandas as pd
8
  from urllib.parse import urlparse
9
  import os
 
 
 
 
 
 
 
10
  from pypdf import PdfReader
11
  from ai71 import AI71
12
  import os
13
  import PyPDF2
14
  import pandas as pd
 
 
 
 
15
 
 
 
 
 
16
  from inference_sdk import InferenceHTTPClient
17
  import base64
18
  UPLOAD_FOLDER = '/code/uploads'
 
7
  import pandas as pd
8
  from urllib.parse import urlparse
9
  import os
10
+ import py
11
+ from pdf2image import convert_from_path
12
+ import cv2
13
+ import numpy as np
14
+ import pytesseract
15
+ import subprocess
16
+ from PIL import Image
17
  from pypdf import PdfReader
18
  from ai71 import AI71
19
  import os
20
  import PyPDF2
21
  import pandas as pd
22
+ def extract_text_from_image(image_path):
23
+ img = cv2.imread(image_path)
24
+ if img is None:
25
+ raise ValueError("Image not found or unable to load")
26
 
27
+ img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
28
+ text = pytesseract.image_to_string(img_rgb)
29
+
30
+ return text
31
  from inference_sdk import InferenceHTTPClient
32
  import base64
33
  UPLOAD_FOLDER = '/code/uploads'