Futuretop commited on
Commit
6ae5ff2
·
verified ·
1 Parent(s): 5ba87b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -33,10 +33,17 @@ def analyze_image(image_pil):
33
  out = model.generate(**inputs)
34
  caption = processor.decode(out[0], skip_special_tokens=True)
35
 
36
- # Face detection
37
  face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
38
- gray = cv2.cvtColor(image_np, cv2.COLOR_RGB2GRAY)
39
- faces = face_cascade.detectMultiScale(gray, 1.1, 4)
 
 
 
 
 
 
 
40
 
41
  face_infos = []
42
  for (x, y, w, h) in faces:
 
33
  out = model.generate(**inputs)
34
  caption = processor.decode(out[0], skip_special_tokens=True)
35
 
36
+ # Face detection (Improved parameters + correct color conversion)
37
  face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
38
+ gray = cv2.cvtColor(np.array(image_pil), cv2.COLOR_RGB2GRAY) # Ensures color format is correct
39
+
40
+ # 🔍 More sensitive detection parameters
41
+ faces = face_cascade.detectMultiScale(
42
+ gray,
43
+ scaleFactor=1.05, # increased sensitivity
44
+ minNeighbors=3, # lower neighbor count = more detections
45
+ minSize=(30, 30) # ensure even smaller faces are caught
46
+ )
47
 
48
  face_infos = []
49
  for (x, y, w, h) in faces: