Neurolingua commited on
Commit
a621863
1 Parent(s): 8b31415

Update teacher_function.py

Browse files
Files changed (1) hide show
  1. teacher_function.py +13 -2
teacher_function.py CHANGED
@@ -38,8 +38,19 @@ def generate_questions_from_text(text, no_of_questions, marks_per_part, no_parts
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
 
45
 
 
38
  return "".join(questions)
39
 
40
  def extract_text_from_image(image_path):
41
+ # Load the image
42
+ img = cv2.imread(image_path)
43
+
44
+ # Ensure the image was loaded correctly
45
+ if img is None:
46
+ raise ValueError("Image not found or unable to load")
47
+
48
+ # Convert the image to RGB format
49
+ img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
50
+
51
+ # Extract text from the image
52
+ text = pytesseract.image_to_string(img_rgb)
53
+
54
  return text
55
 
56