pushpinder06 commited on
Commit
b3f30d9
·
verified ·
1 Parent(s): 6e2e266

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -7,24 +7,24 @@ from PIL import Image
7
  face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
8
 
9
  # Face Detection Function
10
- def detect_faces(image_np):
11
  img=np.array(gray_image)
12
  # Convert image to grayscale
13
  gray_image = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
14
 
15
  # Detect faces
16
- faces = face_cascade.detectMultiScale(gray_image, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30))
17
 
18
  # Draw rectangles around faces
19
  for (x, y, w, h) in faces:
20
  cv2.rectangle(image_np, (x, y), (x + w, y + h), (0, 255, 0), 2)
21
 
22
  return img
23
-
24
  # Create Gradio Interface
25
  iface = gr.Interface(
26
  fn=detect_faces,
27
- inputs="image",
28
  outputs="image",
29
  title="Face Detection",
30
  description="Upload an image, and the model will detect faces and draw bounding boxes around them."
 
7
  face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
8
 
9
  # Face Detection Function
10
+ def detect_faces(image_np,slider):
11
  img=np.array(gray_image)
12
  # Convert image to grayscale
13
  gray_image = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
14
 
15
  # Detect faces
16
+ faces = face_cascade.detectMultiScale(gray_image, scaleFactor=]slider, minNeighbors=5, minSize=(30, 30))
17
 
18
  # Draw rectangles around faces
19
  for (x, y, w, h) in faces:
20
  cv2.rectangle(image_np, (x, y), (x + w, y + h), (0, 255, 0), 2)
21
 
22
  return img
23
+ slider=gr.Slider(minimum=1,maximum=2,step=.1,label="Adjust the scale factor.")
24
  # Create Gradio Interface
25
  iface = gr.Interface(
26
  fn=detect_faces,
27
+ inputs=["image","slider"]
28
  outputs="image",
29
  title="Face Detection",
30
  description="Upload an image, and the model will detect faces and draw bounding boxes around them."