Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -33,16 +33,16 @@ if img_file_buffer is not None:
|
|
33 |
test_image = Image.open(img_file_buffer)
|
34 |
st.image(test_image, use_column_width=True)
|
35 |
st.write(type(test_image))
|
36 |
-
|
37 |
-
gray = cv2.cvtColor(
|
38 |
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
|
39 |
-
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
|
40 |
|
41 |
i = 0
|
42 |
|
43 |
for (x,y,w,h) in faces:
|
44 |
i = i+1
|
45 |
-
cv2.rectangle(
|
46 |
|
47 |
img_gray=gray[y:y+h,x:x+w]
|
48 |
|
@@ -66,7 +66,7 @@ if img_file_buffer is not None:
|
|
66 |
|
67 |
col = (0,255,0)
|
68 |
|
69 |
-
cv2.putText(
|
70 |
-
st.image(cv2.cvtColor(
|
71 |
if bytes_data is None:
|
72 |
st.stop()
|
|
|
33 |
test_image = Image.open(img_file_buffer)
|
34 |
st.image(test_image, use_column_width=True)
|
35 |
st.write(type(test_image))
|
36 |
+
image = np.asarray(test_image)
|
37 |
+
gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
|
38 |
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
|
39 |
+
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.3, minNeighbors=5)
|
40 |
|
41 |
i = 0
|
42 |
|
43 |
for (x,y,w,h) in faces:
|
44 |
i = i+1
|
45 |
+
cv2.rectangle(image,(x,y),(x+w,y+h),(203,12,255),2)
|
46 |
|
47 |
img_gray=gray[y:y+h,x:x+w]
|
48 |
|
|
|
66 |
|
67 |
col = (0,255,0)
|
68 |
|
69 |
+
cv2.putText(image, str(i),(x,y),cv2.FONT_HERSHEY_SIMPLEX,1,col,2)
|
70 |
+
st.image(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
|
71 |
if bytes_data is None:
|
72 |
st.stop()
|