Spaces:
Runtime error
Runtime error
Update app.py
Browse files12367 unmodified lines717273747576777879def main():"""Face Detection App"""67 unmodified lineselse:st.warning("Please upload an image.")elif choice == 'About':st.subheader("About Face Detection App")st.markdown("Built with Streamlit by")if __name__ == '__main__':main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676867 unmodified lines136137138139140141142143144145146147148# Core Pkgsimport streamlit as stimport cv2from PIL import Image,ImageEnhanceimport numpy as npimport osface_cascade = cv2.CascadeClassifier('frecog/haarcascade_frontalface_default.xml')eye_cascade = cv2.CascadeClassifier('frecog/haarcascade_eye.xml')smile_cascade = cv2.CascadeClassifier('frecog/haarcascade_smile.xml')def detect_faces(our_image):new_img = np.array(our_image.convert('RGB'))img = cv2.cvtColor(new_img,1)gray = cv2.cvtColor(new_img, cv2.COLOR_BGR2GRAY)# Detect facesfaces = face_cascade.detectMultiScale(gray, 1.1, 4)# Draw rectangle around the facesfor (x, y, w, h) in faces:cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)return img,facesdef detect_eyes(our_image):new_img = np.array(our_image.convert('RGB'))img = cv2.cvtColor(new_img,1)gray = cv2.cvtColor(new_img, cv2.COLOR_BGR2GRAY)eyes = eye_cascade.detectMultiScale(gray, 1.3, 5)for (ex,ey,ew,eh) in eyes:cv2.rectangle(img,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)return imgdef detect_smiles(our_image):new_img = np.array(our_image.convert('RGB'))img = cv2.cvtColor(new_img,1)gray = cv2.cvtColor(new_img, cv2.COLOR_BGR2GRAY)# Detect Smilessmiles = smile_cascade.detectMultiScale(gray, 1.1, 4)# Draw rectangle around the Smilesfor (x, y, w, h) in smiles:cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)return imgdef cartonize_image(our_image):new_img = np.array(our_image.convert('RGB'))img = cv2.cvtColor(new_img,1)gray = cv2.cvtColor(new_img, cv2.COLOR_BGR2GRAY)# Edgesgray = cv2.medianBlur(gray, 5)edges = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 9, 9)#Colorcolor = cv2.bilateralFilter(img, 9, 300, 300)#Cartooncartoon = cv2.bitwise_and(color, color, mask=edges)return cartoondef cannize_image(our_image):new_img = np.array(our_image.convert('RGB'))img = cv2.cvtColor(new_img,1)img = cv2.GaussianBlur(img, (11, 11), 0)canny = cv2.Canny(img, 100, 150)return cannydef main():"""Face Detection App"""67 unmodified lineselse:st.warning("Please upload an image.")elif choice == 'About':st.subheader("About Face Detection App")st.markdown("Built with Streamlit by [JCharisTech](https://www.jcharistech.com/)")st.text("Jesse E.Agbe(JCharis)")st.success("Jesus Saves @JCharisTech")if __name__ == '__main__':main()
app.py+73-4