Neurolingua commited on
Commit
9a1ecae
1 Parent(s): 2b88356

Update teacher_function.py

Browse files
Files changed (1) hide show
  1. teacher_function.py +6 -1
teacher_function.py CHANGED
@@ -4,8 +4,13 @@ from pdf2image import convert_from_path
4
  import cv2
5
  import numpy as np
6
  import pytesseract
 
 
7
  AI71_API_KEY = "api71-api-652e5c6c-8edf-41d0-9c34-28522b07bef9"
8
 
 
 
 
9
  def extract_text_from_pdf(pdf_file):
10
  text = ""
11
  reader = PdfReader(pdf_file)
@@ -33,7 +38,7 @@ def generate_questions_from_text(text, no_of_questions, marks_per_part, no_parts
33
  return "".join(questions)
34
 
35
  def extract_text_from_image(image_path):
36
- img = cv2.imread(image_path)
37
  text = pytesseract.image_to_string(img)
38
  return text
39
 
 
4
  import cv2
5
  import numpy as np
6
  import pytesseract
7
+ import subprocess
8
+ from PIL import Image
9
  AI71_API_KEY = "api71-api-652e5c6c-8edf-41d0-9c34-28522b07bef9"
10
 
11
+ subprocess.run(['apt-get','update'])
12
+ subprocess.run(['apt-get','install','-y','tesseract-ocr'])
13
+
14
  def extract_text_from_pdf(pdf_file):
15
  text = ""
16
  reader = PdfReader(pdf_file)
 
38
  return "".join(questions)
39
 
40
  def extract_text_from_image(image_path):
41
+ img = Image.open(image_path)
42
  text = pytesseract.image_to_string(img)
43
  return text
44