syedfaisalabrar commited on
Commit
fa25b8d
·
verified ·
1 Parent(s): 543a951

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -5,11 +5,11 @@ import numpy as np
5
  from PIL import Image, ImageEnhance
6
  from ultralytics import YOLO
7
 
8
- # Load YOLOv11 Model
9
  model_path = "best.pt"
10
  model = YOLO(model_path)
11
 
12
- # ---------------- Preprocessing Function ---------------- #
13
  def preprocessing(image):
14
  """Apply three enhancement filters, including brightness reduction, and resize."""
15
  image = Image.fromarray(np.array(image))
@@ -27,12 +27,12 @@ def preprocessing(image):
27
 
28
  return image
29
 
30
- # ---------------- Dummy Image Rotation Function ---------------- #
31
  def imageRotation(image):
32
  """Dummy function for image rotation."""
33
  return image
34
 
35
- # ---------------- Document Detection Function ---------------- #
36
  def detect_document(image):
37
  """Detects front and back of the document using YOLO."""
38
  image = np.array(image)
@@ -107,7 +107,7 @@ def predict(image):
107
  "back": back_result
108
  }
109
 
110
- return detected_image, labels, api_results, cropped_images # Return cropped images as output
111
 
112
  # ---------------- Gradio Interface ---------------- #
113
  iface = gr.Interface(
 
5
  from PIL import Image, ImageEnhance
6
  from ultralytics import YOLO
7
 
8
+
9
  model_path = "best.pt"
10
  model = YOLO(model_path)
11
 
12
+
13
  def preprocessing(image):
14
  """Apply three enhancement filters, including brightness reduction, and resize."""
15
  image = Image.fromarray(np.array(image))
 
27
 
28
  return image
29
 
30
+
31
  def imageRotation(image):
32
  """Dummy function for image rotation."""
33
  return image
34
 
35
+
36
  def detect_document(image):
37
  """Detects front and back of the document using YOLO."""
38
  image = np.array(image)
 
107
  "back": back_result
108
  }
109
 
110
+ return cropped_images, labels, api_results
111
 
112
  # ---------------- Gradio Interface ---------------- #
113
  iface = gr.Interface(