README: AI-Powered Harassment and Safety Monitoring System with Email Alert and Face Recognition
Inspiration
Throughout our lives, we've been exposed to countless reports and stories in newspapers and online platforms, underscoring the distressing prevalence of sexual harassment incidents. The reluctance victims often experience when reporting such incidents due to fears of retaliation or social stigma drove the creation of this project. The aim is to leverage innovative technologies to create a safer, more inclusive work environment.
Problem Statement
The goal is to build a technological solution for real-time harassment detection while addressing the gaps left by traditional methods. This includes creating a safer work environment, overcoming reporting hesitancy, supporting HR and legal management, reducing stress, and ensuring early detection and prevention of harassment.
Introduction
The project aims to develop a CNN-based model to detect workplace harassment and a **Safety Monitoring System with Email Alert and Face Recognition** module. This hybrid approach ensures accurate detection of harassment behavior while enhancing workplace safety through real-time face recognition and alert notifications.
Modules Overview
1. Harassment Detection System
This module leverages a CNN-based model to differentiate harassment behaviors from normal workplace activities in videos.
2. Safety Monitoring System with Email Alerts and Face Recognition
A real-time monitoring solution using facial recognition technology integrated with safety protocols.
- Features:
- Face recognition to identify individuals in the workplace.
- Real-time monitoring to detect anomalies.
- Instant email alerts sent to security and management in case of unauthorized access or suspicious behavior.
Approach
Harassment Detection System
- Model: CNN with transfer learning (VGG16, Xception).
- Dataset: Custom dataset with 1,000 harassment and 1,000 non-harassment images.
- Data Split: 80% training, 20% testing.
Safety Monitoring System
- Face Recognition: Utilizes OpenCV and dlib for detecting faces and matching against a pre-registered database.
- Email Alerts: Python's SMTP library sends notifications upon detecting unauthorized individuals or safety concerns.
- Data Sources: Pre-trained models and a custom facial dataset collected for workplace safety monitoring.
Procedure
1. Pre-Installation
Install the following libraries:
- OpenCV
- Keras
- TensorFlow
- dlib
- Pandas
- NumPy
- OS
- SMTP (for email alerts)
2. Dataset Preparation
-
Harassment Detection:
- 2 folders:
yes
(harassment images) and no
(healthy environment images).
- Images resized to 224x224x3.
- Converted into NumPy arrays and split into training/testing sets.
-
Face Recognition:
- A database of employee faces is pre-registered.
- Images are preprocessed for facial encoding using dlib’s facial recognition model.
3. Model Training
4. Deployment
- Application:
- Flutter-based app integrates both modules.
- Alerts are displayed on the app with real-time notifications.
- Admin access to employee records and system logs.
Results
Harassment Detection
Achieved 98% training accuracy and 97% validation accuracy.
Safety Monitoring
- Recognized faces with 95% accuracy in real-time.
- Instant email alerts successfully sent for all test cases.
Learnings
-
Machine Learning:
- Developed expertise in training CNN models for video analysis.
- Implemented transfer learning to improve detection accuracy.
-
Face Recognition:
- Used dlib and OpenCV for robust facial recognition.
- Integrated real-time recognition with anomaly detection.
-
Deployment:
- Built a cross-platform Flutter app for user interaction and notifications.
-
Optimization:
- Leveraged Intel OneAPI to optimize model performance on heterogeneous systems.
Future Enhancements
- Expand the facial recognition database for scalability.
- Integrate emotion recognition to identify stress or discomfort.
- Enable voice alerts in addition to email notifications.
- Explore IoT integration for enhanced real-time monitoring.
Conclusion
By combining Harassment Detection with a Safety Monitoring System, this project addresses workplace safety comprehensively. It fosters a secure environment, supports HR processes, and promotes early intervention for safety and harassment concerns.
README: Sexual Harassment Detection and Safety Monitoring System
Inspiration
Throughout our lives, we've been exposed to countless reports and stories in newspapers and online platforms, underscoring the distressing prevalence of sexual harassment incidents. The reluctance victims often experience when reporting such incidents due to fears of retaliation or social stigma drove the creation of this project. The aim is to leverage innovative technologies to create a safer, more inclusive work environment.
Problem Statement
The goal is to build a technological solution for real-time harassment detection while addressing the gaps left by traditional methods. This includes creating a safer work environment, overcoming reporting hesitancy, supporting HR and legal management, reducing stress, and ensuring early detection and prevention of harassment.
Introduction
The project aims to develop a CNN-based model to detect workplace harassment and a **Safety Monitoring System with Email Alert and Face Recognition** module. This hybrid approach ensures accurate detection of harassment behavior while enhancing workplace safety through real-time face recognition and alert notifications.
Modules Overview
1. Harassment Detection System
This module leverages a CNN-based model to differentiate harassment behaviors from normal workplace activities in videos.
2. Safety Monitoring System with Email Alerts and Face Recognition
A real-time monitoring solution using facial recognition technology integrated with safety protocols.
- Features:
- Face recognition to identify individuals in the workplace.
- Real-time monitoring to detect anomalies.
- Instant email alerts sent to security and management in case of unauthorized access or suspicious behavior.
Approach
Harassment Detection System
- Model: CNN with transfer learning (VGG16, Xception).
- Dataset: Custom dataset with 1,000 harassment and 1,000 non-harassment images.
- Data Split: 80% training, 20% testing.
Safety Monitoring System
- Face Recognition: Utilizes OpenCV and dlib for detecting faces and matching against a pre-registered database.
- Email Alerts: Python's SMTP library sends notifications upon detecting unauthorized individuals or safety concerns.
- Data Sources: Pre-trained models and a custom facial dataset collected for workplace safety monitoring.
Procedure
1. Pre-Installation
Install the following libraries:
- OpenCV
- Keras
- TensorFlow
- dlib
- Pandas
- NumPy
- OS
- SMTP (for email alerts)
2. Dataset Preparation
-
Harassment Detection:
- 2 folders:
yes
(harassment images) and no
(healthy environment images).
- Images resized to 224x224x3.
- Converted into NumPy arrays and split into training/testing sets.
-
Face Recognition:
- A database of employee faces is pre-registered.
- Images are preprocessed for facial encoding using dlib’s facial recognition model.
3. Model Training
4. Deployment
- Application:
- Flutter-based app integrates both modules.
- Alerts are displayed on the app with real-time notifications.
- Admin access to employee records and system logs.
Results
Harassment Detection
Achieved 98% training accuracy and 97% validation accuracy.
Safety Monitoring
- Recognized faces with 95% accuracy in real-time.
- Instant email alerts successfully sent for all test cases.
Learnings
-
Machine Learning:
- Developed expertise in training CNN models for video analysis.
- Implemented transfer learning to improve detection accuracy.
-
Face Recognition:
- Used dlib and OpenCV for robust facial recognition.
- Integrated real-time recognition with anomaly detection.
-
Deployment:
- Built a cross-platform Flutter app for user interaction and notifications.
-
Optimization:
- Leveraged Intel OneAPI to optimize model performance on heterogeneous systems.
Future Enhancements
- Expand the facial recognition database for scalability.
- Integrate emotion recognition to identify stress or discomfort.
- Enable voice alerts in addition to email notifications.
- Explore IoT integration for enhanced real-time monitoring.
Conclusion
By combining Harassment Detection with a Safety Monitoring System, this project addresses workplace safety comprehensively. It fosters a secure environment, supports HR processes, and promotes early intervention for safety and harassment concerns.
𝐄𝐦𝐚𝐢𝐥 𝐀𝐥𝐞𝐫𝐭 𝐅𝐮𝐧𝐜𝐭𝐢𝐨𝐧
𝐓𝐡𝐢𝐬 𝐟𝐮𝐧𝐜𝐭𝐢𝐨𝐧 𝐬𝐞𝐧𝐝𝐬 𝐚𝐧 𝐞𝐦𝐚𝐢𝐥 𝐚𝐥𝐞𝐫𝐭 𝐰𝐢𝐭𝐡 𝐚𝐧 𝐢𝐦𝐚𝐠𝐞 𝐚𝐭𝐭𝐚𝐜𝐡𝐦𝐞𝐧𝐭 𝐰𝐡𝐞𝐧 𝐡𝐚𝐫𝐚𝐬𝐬𝐦𝐞𝐧𝐭 𝐢𝐬 𝐝𝐞𝐭𝐞𝐜𝐭𝐞𝐝.
def send_alert(frame, incident_details):
sender_email = "your_email@example.com" # Replace with your email
receiver_email = "receiver_email@example.com" # Replace with the recipient's email
password = "your_email_password" # Use app-specific password for security
# Save the frame as an image
incident_image = "incident.jpg"
cv2.imwrite(incident_image, frame)
# Set up email
msg = MIMEMultipart()
msg['From'] = sender_email
msg['To'] = receiver_email
msg['Subject'] = "Harassment Alert"
body = incident_details
msg.attach(MIMEBase('application', 'octet-stream'))
# Attach the image
with open(incident_image, 'rb') as file:
part = MIMEBase('application', 'octet-stream')
part.set_payload(file.read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', f"attachment; filename={incident_image}")
msg.attach(part)
# Send the email
try:
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, msg.as_string())
server.quit()
print("Alert sent successfully!")
except Exception as e:
print(f"Failed to send email: {e}")