kshipra-jadav commited on
Commit
0d9713a
·
1 Parent(s): c130034

initial commit

Browse files
.dockerignore ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Git
2
+ .git
3
+ .gitignore
4
+
5
+ # CI
6
+ .codeclimate.yml
7
+ .travis.yml
8
+ .taskcluster.yml
9
+
10
+ # Docker
11
+ docker-compose.yml
12
+ .docker
13
+
14
+ # Byte-compiled / optimized / DLL files
15
+ __pycache__/
16
+ */__pycache__/
17
+ */*/__pycache__/
18
+ */*/*/__pycache__/
19
+ *.py[cod]
20
+ */*.py[cod]
21
+ */*/*.py[cod]
22
+ */*/*/*.py[cod]
23
+
24
+ # C extensions
25
+ *.so
26
+
27
+ # Distribution / packaging
28
+ .Python
29
+ env/
30
+ build/
31
+ develop-eggs/
32
+ dist/
33
+ downloads/
34
+ eggs/
35
+ lib/
36
+ lib64/
37
+ parts/
38
+ sdist/
39
+ var/
40
+ *.egg-info/
41
+ .installed.cfg
42
+ *.egg
43
+
44
+ # PyInstaller
45
+ # Usually these files are written by a python script from a template
46
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
47
+ *.manifest
48
+ *.spec
49
+
50
+ # Installer logs
51
+ pip-log.txt
52
+ pip-delete-this-directory.txt
53
+
54
+ # Unit test / coverage reports
55
+ htmlcov/
56
+ .tox/
57
+ .coverage
58
+ .cache
59
+ nosetests.xml
60
+ coverage.xml
61
+
62
+ # Translations
63
+ *.mo
64
+ *.pot
65
+
66
+ # Django stuff:
67
+ *.log
68
+
69
+ # Sphinx documentation
70
+ docs/_build/
71
+
72
+ # PyBuilder
73
+ target/
74
+
75
+ # Virtual environment
76
+ .env/
77
+ .venv/
78
+ venv/
79
+
80
+ # PyCharm
81
+ .idea
82
+
83
+ # Python mode for VIM
84
+ .ropeproject
85
+ */.ropeproject
86
+ */*/.ropeproject
87
+ */*/*/.ropeproject
88
+
89
+ # Vim swap files
90
+ *.swp
91
+ */*.swp
92
+ */*/*.swp
93
+ */*/*/*.swp
Dockerfile ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim-buster
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt requirements.txt
6
+
7
+ RUN pip3 install --upgrade pip
8
+
9
+ RUN pip3 install -r requirements.txt
10
+
11
+ RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
12
+
13
+ COPY . .
14
+
15
+ CMD ["python", "-m", "flask", "run", "--host=0.0.0.0", "--port=7860"]
app.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request, jsonify
2
+ import cv2
3
+ from mtcnn import MTCNN
4
+ import time
5
+ import concurrent.futures
6
+ import base64
7
+ import numpy as np
8
+
9
+ app = Flask(__name__)
10
+
11
+ def load_and_detect_haar(gray_img):
12
+ print("inside haar")
13
+ ff = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
14
+ ff_alt = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_alt.xml')
15
+ ff_alt2 = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_alt2.xml')
16
+ pf = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_profileface.xml')
17
+
18
+ ff_faces = ff.detectMultiScale(gray_img, scaleFactor=1.2, minNeighbors=10, minSize=(25, 25))
19
+ ff_alt2_faces = ff_alt2.detectMultiScale(gray_img, scaleFactor=1.05, minNeighbors=10, minSize=(20, 20))
20
+ pf_faces = pf.detectMultiScale(gray_img, scaleFactor=1.05, minNeighbors=5, minSize=(20, 20))
21
+
22
+ return ff_faces, ff_alt2_faces, pf_faces
23
+
24
+ def load_and_detect_mtcnn(image):
25
+ print("inside mtcnn")
26
+ mtcnn = MTCNN()
27
+ faces = mtcnn.detect_faces(image)
28
+ mt_faces = [face['box'] for face in faces]
29
+ return mt_faces
30
+
31
+ def get_unique_face_locations(all_face_locations):
32
+ unique_detected_faces = []
33
+ for (x1, y1, w1, h1) in all_face_locations:
34
+ unique = True
35
+ for (x2, y2, w2, h2) in unique_detected_faces:
36
+ if abs(x1 - x2) < 50 and abs(y1 - y2) < 50:
37
+ unique = False
38
+ break
39
+ if unique:
40
+ unique_detected_faces.append((x1, y1, w1, h1))
41
+
42
+ return unique_detected_faces
43
+
44
+ @app.route('/')
45
+ def index():
46
+ return render_template('pg1.html')
47
+
48
+ @app.route('/camera')
49
+ def camera():
50
+ return render_template("pg2.html")
51
+
52
+ @app.route('/report')
53
+ def report():
54
+ return render_template("pg4.html")
55
+
56
+ @app.route('/detect_faces', methods=['POST'])
57
+ def detect_faces():
58
+ filestr = request.files["img_upload"].read()
59
+ file_bytes = np.fromstring(filestr, np.uint8)
60
+ img = cv2.imdecode(file_bytes, cv2.IMREAD_UNCHANGED)
61
+ gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
62
+
63
+ with concurrent.futures.ThreadPoolExecutor() as executor:
64
+ haar_detections = executor.submit(load_and_detect_haar, gray)
65
+ mtcnn_detections = executor.submit(load_and_detect_mtcnn, img)
66
+
67
+ ff_faces, ff_alt2_faces, pf_faces = haar_detections.result()
68
+ mt_faces = mtcnn_detections.result()
69
+
70
+ all_faces = [*ff_faces, *ff_alt2_faces, *pf_faces, *mt_faces]
71
+ unique_detected_faces = get_unique_face_locations(all_faces)
72
+
73
+ for (x, y, w, h) in unique_detected_faces:
74
+ cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 3)
75
+
76
+ img = cv2.putText(img, f"{len(unique_detected_faces)} Faces", (100, 300), cv2.FONT_HERSHEY_SIMPLEX, 6, (0, 0, 0), 10)
77
+
78
+ _, buffer = cv2.imencode(".jpg", cv2.resize(img, (0, 0), fx=0.5, fy=0.5))
79
+ b64 = base64.b64encode(buffer)
80
+
81
+ return render_template("pg1.html", img_data = b64.decode('utf-8'))
82
+
83
+ if __name__ == '__main__':
84
+ app.run(debug=False)
app1.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # from flask import Flask, render_template, Response
2
+ # import cv2
3
+ # from mtcnn import MTCNN
4
+ # import base64
5
+ # import numpy as np
6
+ # import concurrent.futures
7
+
8
+ # app = Flask(__name__)
9
+
10
+ # class FaceDetector:
11
+ # def __init__(self):
12
+ # self.detector = MTCNN()
13
+ # self.face_count = 0
14
+
15
+ # def detect_faces(self, frame):
16
+ # faces = self.detector.detect_faces(frame)
17
+ # self.face_count = len(faces)
18
+ # return faces
19
+
20
+ # face_detector = FaceDetector()
21
+
22
+ # def generate_frames():
23
+ # camera = cv2.VideoCapture(0) # 0 indicates the default camera (you can change it to the camera index you want to use)
24
+
25
+ # while True:
26
+ # success, frame = camera.read()
27
+ # if not success:
28
+ # break
29
+
30
+ # gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
31
+
32
+ # # Perform face detection
33
+ # faces = face_detector.detect_faces(frame)
34
+
35
+ # for face in faces:
36
+ # x, y, w, h = face['box']
37
+ # cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 3)
38
+
39
+ # # Display face count on each frame
40
+ # font = cv2.FONT_HERSHEY_SIMPLEX
41
+ # cv2.putText(frame, f'Faces: {face_detector.face_count}', (10, 30), font, 1, (255, 255, 255), 2, cv2.LINE_AA)
42
+
43
+ # _, buffer = cv2.imencode(".jpg", cv2.resize(frame, (0, 0), fx=0.5, fy=0.5))
44
+ # img_data = buffer.tobytes()
45
+
46
+ # yield (b'--frame\r\n'
47
+ # b'Content-Type: image/jpeg\r\n\r\n' + img_data + b'\r\n\r\n')
48
+
49
+ # camera.release()
50
+
51
+ # @app.route('/')
52
+ # def index():
53
+ # return render_template('index.html')
54
+
55
+ # @app.route('/detect_faces')
56
+ # def detect_faces():
57
+ # return Response(generate_frames(), mimetype='multipart/x-mixed-replace; boundary=frame')
58
+
59
+ # if __name__ == '__main__':
60
+ # app.run(debug=True)
61
+
62
+
63
+ from flask import Flask, render_template, Response, request
64
+ import cv2
65
+ from mtcnn import MTCNN
66
+ import numpy as np
67
+ import concurrent.futures
68
+
69
+ app = Flask(__name__)
70
+
71
+ class FaceDetector:
72
+ def __init__(self):
73
+ self.detector = MTCNN()
74
+ self.face_count = 0
75
+
76
+ def detect_faces(self, frame):
77
+ faces = self.detector.detect_faces(frame)
78
+ self.face_count = len(faces)
79
+ return faces
80
+
81
+ face_detector = FaceDetector()
82
+
83
+ def generate_frames(camera_index):
84
+ camera = cv2.VideoCapture(camera_index)
85
+
86
+ while True:
87
+ success, frame = camera.read()
88
+ if not success:
89
+ break
90
+
91
+ # Perform face detection
92
+ faces = face_detector.detect_faces(frame)
93
+
94
+ for face in faces:
95
+ x, y, w, h = face['box']
96
+ cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 3)
97
+
98
+ # Display face count on each frame
99
+ font = cv2.FONT_HERSHEY_SIMPLEX
100
+ cv2.putText(frame, f'Faces: {face_detector.face_count}', (10, 30), font, 1, (255, 255, 255), 2, cv2.LINE_AA)
101
+
102
+ _, buffer = cv2.imencode(".jpg", cv2.resize(frame, (0, 0), fx=0.5, fy=0.5))
103
+ img_data = buffer.tobytes()
104
+
105
+ yield (b'--frame\r\n'
106
+ b'Content-Type: image/jpeg\r\n\r\n' + img_data + b'\r\n\r\n')
107
+
108
+ camera.release()
109
+
110
+ @app.route('/')
111
+ def index():
112
+ return render_template('pg2.html')
113
+
114
+ @app.route('/detect_faces')
115
+ def detect_faces():
116
+ camera_index = int(request.args.get('camera_index', 1))
117
+ return Response(generate_frames(camera_index), mimetype='multipart/x-mixed-replace; boundary=frame')
118
+
119
+ if __name__ == '__main__':
120
+ app.run(debug=True)
docker-compose.yml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ version: '3'
2
+ services:
3
+ flask-app:
4
+ build: '.'
5
+ ports:
6
+ - '7860:7860'
requirements.txt ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==2.1.0
2
+ astunparse==1.6.3
3
+ blinker==1.7.0
4
+ cachetools==5.3.2
5
+ certifi==2023.11.17
6
+ charset-normalizer==3.3.2
7
+ click==8.1.7
8
+ dm-tree==0.1.8
9
+ Flask==3.0.1
10
+ flatbuffers==23.5.26
11
+ gast==0.5.4
12
+ google-auth==2.26.2
13
+ google-auth-oauthlib==1.2.0
14
+ google-pasta==0.2.0
15
+ grpcio==1.60.0
16
+ h5py==3.10.0
17
+ idna==3.6
18
+ itsdangerous==2.1.2
19
+ Jinja2==3.1.3
20
+ keras==2.15.0
21
+ libclang==16.0.6
22
+ Markdown==3.5.2
23
+ markdown-it-py==3.0.0
24
+ MarkupSafe==2.1.3
25
+ mdurl==0.1.2
26
+ ml-dtypes==0.2.0
27
+ mtcnn==0.1.1
28
+ namex==0.0.7
29
+ numpy==1.26.3
30
+ oauthlib==3.2.2
31
+ opencv-python==4.9.0.80
32
+ opt-einsum==3.3.0
33
+ packaging==23.2
34
+ pillow==10.2.0
35
+ protobuf==4.23.4
36
+ pyasn1==0.5.1
37
+ pyasn1-modules==0.3.0
38
+ Pygments==2.17.2
39
+ requests==2.31.0
40
+ requests-oauthlib==1.3.1
41
+ rich==13.7.0
42
+ rsa==4.9
43
+ six==1.16.0
44
+ tensorboard==2.15.1
45
+ tensorboard-data-server==0.7.2
46
+ tensorflow==2.15.0.post1
47
+ tensorflow-estimator==2.15.0
48
+ tensorflow-io-gcs-filesystem==0.35.0
49
+ termcolor==2.4.0
50
+ typing_extensions==4.9.0
51
+ urllib3==2.1.0
52
+ Werkzeug==3.0.1
53
+ wrapt==1.14.1
templates/camera.css ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* camera.css */
2
+
3
+ .camera-section {
4
+ background-color: #f5f5f5e8;
5
+ text-align: center;
6
+ padding: 20px;
7
+ border-radius: 10px;
8
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
9
+
10
+ }
11
+
12
+ #cameraFeed {
13
+ max-width: 100%;
14
+ border-radius: 10px;
15
+ }
templates/camera.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ // Get access to the user's camera
2
+ navigator.mediaDevices.getUserMedia({ video: true })
3
+ .then(function (stream) {
4
+ var videoElement = document.getElementById('cameraFeed');
5
+ videoElement.srcObject = stream;
6
+ })
7
+ .catch(function (error) {
8
+ console.error('Error accessing camera: ' + error);
9
+ });
templates/common.css ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* common.css */
2
+
3
+ body {
4
+ font-family: Arial, sans-serif;
5
+ margin: 0;
6
+ padding: 0;
7
+ background-image: url('https://www.gsfcuni.edu.in/upload/slider/php949D_NcK1628833893.jpeg'); /* Replace 'your-image.jpg' with the path to your background image */
8
+ background-size: cover;
9
+ background-repeat: no-repeat;
10
+ background-attachment: fixed;
11
+ }
12
+
13
+
14
+ nav {
15
+ background-color: #212529;
16
+ color: #fff;
17
+ display: flex;
18
+ justify-content: space-between;
19
+ align-items: center;
20
+ padding: 20px;
21
+ box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.2);
22
+ }
23
+
24
+ nav img {
25
+ max-width: 150px;
26
+ }
27
+
28
+ nav ul {
29
+ list-style-type: none;
30
+ display: flex;
31
+ }
32
+
33
+ nav ul li {
34
+ margin-right: 20px;
35
+ }
36
+
37
+ nav ul li a {
38
+ text-decoration: none;
39
+ color: #fff;
40
+ font-weight: bold;
41
+ transition: color 0.3s ease;
42
+ }
43
+
44
+ nav ul li a:hover {
45
+ color: #ff5733;
46
+ }
47
+
48
+ section {
49
+ padding: 20px;
50
+ background-color: #fff;
51
+ border-radius: 10px;
52
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
53
+ margin: 20px;
54
+ }
55
+
56
+ h1 {
57
+ color: #1b2850;
58
+ margin-bottom: 20px;
59
+ }
60
+
61
+ footer {
62
+ background-color: rgba(27, 40, 80, 1);
63
+ color: #fff;
64
+ text-align: center;
65
+ padding: 10px;
66
+ position: fixed;
67
+ bottom: 0;
68
+ width: 100%;
69
+ }
70
+
71
+
72
+
73
+ .carousel-caption {
74
+ position: absolute;
75
+ right: 15%;
76
+ bottom: 20%;
77
+ left: 15%;
78
+ z-index: 10;
79
+ padding-top: 20px;
80
+ padding-bottom: 20px;
81
+ text-align: center;
82
+ background-color: rgba(0, 0, 0, 0.084);
83
+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
84
+ border: 0px solid rgba(0, 0, 0, 0.2);
85
+ border-radius: 4px;
86
+ }
87
+
88
+ /* Add this CSS to your website's CSS file */
89
+
90
+ .carousel-caption h3 {
91
+ font-size: 100px;
92
+ font-weight: 700;
93
+ color: #fff;
94
+ text-transform: uppercase;
95
+ letter-spacing: 2px;
96
+ margin-top: 0;
97
+ margin-bottom: 0;
98
+ }
99
+
100
+ span {
101
+ font-size: 70px;
102
+ color: #26386e; /* Desired text color */
103
+ font-weight: bold;
104
+ }
templates/pg1.html ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <style>
8
+ /* common.css */
9
+ body {
10
+ font-family: Arial, sans-serif;
11
+ margin: 0;
12
+ padding: 0;
13
+ background-image: url('https://www.gsfcuni.edu.in/upload/slider/php949D_NcK1628833893.jpeg');
14
+ background-size: cover;
15
+ background-repeat: no-repeat;
16
+ background-attachment: fixed;
17
+ }
18
+
19
+ nav {
20
+ background-color: #212529;
21
+ color: #fff;
22
+ display: flex;
23
+ justify-content: space-between;
24
+ align-items: center;
25
+ padding: 20px;
26
+ box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.2);
27
+ }
28
+
29
+ nav img {
30
+ max-width: 100%;
31
+ height: auto;
32
+ }
33
+
34
+ nav ul {
35
+ list-style-type: none;
36
+ display: flex;
37
+ flex-wrap: wrap;
38
+ /* Added for mobile responsiveness */
39
+ }
40
+
41
+ nav ul li {
42
+ margin-right: 20px;
43
+ margin-bottom: 10px;
44
+ /* Added for mobile responsiveness */
45
+ }
46
+
47
+ nav ul li a {
48
+ text-decoration: none;
49
+ color: #fff;
50
+ font-weight: bold;
51
+ transition: color 0.3s ease;
52
+ }
53
+
54
+ nav ul li a:hover {
55
+ color: #ff5733;
56
+ }
57
+
58
+ section {
59
+ padding: 20px;
60
+ background-color: #fff;
61
+ border-radius: 10px;
62
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
63
+ margin: 20px;
64
+ }
65
+
66
+ h1 {
67
+ color: #1b2850;
68
+ margin-bottom: 20px;
69
+ }
70
+
71
+ footer {
72
+ background-color: rgba(27, 40, 80, 1);
73
+ color: #fff;
74
+ text-align: center;
75
+ padding: 10px;
76
+ position: fixed;
77
+ bottom: 0;
78
+ width: 100%;
79
+ }
80
+
81
+ .carousel-caption {
82
+ position: absolute;
83
+ right: 15%;
84
+ bottom: 20%;
85
+ left: 15%;
86
+ z-index: 10;
87
+ padding-top: 20px;
88
+ padding-bottom: 20px;
89
+ text-align: center;
90
+ background-color: rgba(0, 0, 0, 0.084);
91
+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
92
+ border: 0px solid rgba(0, 0, 0, 0.2);
93
+ border-radius: 4px;
94
+ }
95
+
96
+ .carousel-caption h3 {
97
+ font-size: 100px;
98
+ font-weight: 700;
99
+ color: #fff;
100
+ text-transform: uppercase;
101
+ letter-spacing: 2px;
102
+ margin-top: 0;
103
+ margin-bottom: 0;
104
+ }
105
+
106
+ span {
107
+ font-size: 70px;
108
+ color: #26386e;
109
+ font-weight: bold;
110
+ }
111
+
112
+ /* upload.css */
113
+ .upload-section {
114
+ background-color: #f5f5f5;
115
+ text-align: center;
116
+ padding: 20px;
117
+ border-radius: 10px;
118
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
119
+ opacity: 1;
120
+ }
121
+
122
+ #imageUpload {
123
+ display: block;
124
+ margin: 0 auto;
125
+ padding: 10px;
126
+ border: 2px dashed #ccc;
127
+ border-radius: 10px;
128
+ background-color: #fff;
129
+ cursor: pointer;
130
+ }
131
+
132
+ #imageUpload:hover {
133
+ border-color: #1b2850;
134
+ }
135
+
136
+ #imageUploadLabel {
137
+ display: block;
138
+ font-weight: bold;
139
+ margin-top: 10px;
140
+ }
141
+
142
+ #imagePreview {
143
+ max-width: 100%;
144
+ margin-top: 20px;
145
+ border-radius: 10px;
146
+ }
147
+
148
+ /* custom.css */
149
+ #imagePreviewContainer {
150
+ display: flex;
151
+ flex-direction: column;
152
+ align-items: center;
153
+ text-align: center;
154
+ background-color: rgba(255, 255, 255, 0.9);
155
+ border-radius: 10px;
156
+ padding: 20px;
157
+ margin-top: 20px;
158
+ box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
159
+ }
160
+
161
+ #imagePreviewContainer h2 {
162
+ color: #1b2850;
163
+ font-size: 24px;
164
+ font-weight: bold;
165
+ }
166
+
167
+ #imagePreview {
168
+ max-width: 100%;
169
+ height: auto;
170
+ margin-top: 10px;
171
+ border: 2px solid #1b2850;
172
+ border-radius: 5px;
173
+ }
174
+
175
+ #previewButton {
176
+ background-color: #1b2850;
177
+ color: #fff;
178
+ border: none;
179
+ padding: 10px 20px;
180
+ margin-top: 10px;
181
+ font-size: 16px;
182
+ font-weight: bold;
183
+ border-radius: 5px;
184
+ cursor: pointer;
185
+ transition: background-color 0.3s ease;
186
+ }
187
+
188
+ #previewButton:hover {
189
+ background-color: #ff5733;
190
+ }
191
+
192
+ @media only screen and (max-width: 768px) {
193
+ .carousel-caption {
194
+ font-size: 24px;
195
+ }
196
+
197
+ .carousel-caption h3 {
198
+ font-size: 50px;
199
+ }
200
+
201
+ span {
202
+ font-size: 40px;
203
+ }
204
+
205
+ #previewButton {
206
+ font-size: 14px;
207
+ }
208
+ }
209
+ </style>
210
+ <title>Page 1</title>
211
+ </head>
212
+
213
+ <body>
214
+ <nav>
215
+ <img src="https://www.gsfcuni.edu.in/public/logo/White1.png" alt="Logo">
216
+ <ul>
217
+ <li><a href="/">Image</a></li>
218
+ <li><a href="/camera">Camera</a></li>
219
+ </ul>
220
+ </nav>
221
+ <section class="upload-section">
222
+ <h1>UPLOAD</h1>
223
+ <label for="imageUpload" id="imageUploadLabel">Choose an image</label>
224
+ <form method="post" action="http://localhost:5000/detect_faces" enctype="multipart/form-data">
225
+ <input type="file" id="imageUpload" name="img_upload" accept="image/*">
226
+ <input type="submit" value="Submit Form" id="previewButton">
227
+ </form>
228
+ <div id="imagePreviewContainer">
229
+ {% if img_data: %}
230
+ <h2>Image Preview</h2>
231
+ <div>
232
+ <img id="imagePreview" src="data:image/jpeg;base64,{{ img_data }}" width="800" height="600">
233
+ </div>
234
+ {% endif %}
235
+ </div>
236
+ </section>
237
+ <footer>
238
+ Developed by Kshipra and Viraj
239
+ </footer>
240
+ </body>
241
+
242
+ </html>
templates/pg2.html ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <style>
8
+ /* Common styles for all screen sizes */
9
+ body {
10
+ font-family: Arial, sans-serif;
11
+ margin: 0;
12
+ padding: 0;
13
+ background-image: url('https://www.gsfcuni.edu.in/upload/slider/php949D_NcK1628833893.jpeg');
14
+ background-size: cover;
15
+ background-repeat: no-repeat;
16
+ background-attachment: fixed;
17
+ }
18
+
19
+ nav {
20
+ background-color: #212529;
21
+ color: #fff;
22
+ display: flex;
23
+ justify-content: space-between;
24
+ align-items: center;
25
+ padding: 20px;
26
+ box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.2);
27
+ }
28
+
29
+ nav img {
30
+ max-width: 100%;
31
+ height: auto;
32
+ }
33
+
34
+ nav ul {
35
+ list-style-type: none;
36
+ display: flex;
37
+ flex-wrap: wrap;
38
+ /* Added for mobile responsiveness */
39
+ }
40
+
41
+ nav ul li {
42
+ margin-right: 20px;
43
+ margin-bottom: 10px;
44
+ /* Added for mobile responsiveness */
45
+ }
46
+
47
+ nav ul li a {
48
+ text-decoration: none;
49
+ color: #fff;
50
+ font-weight: bold;
51
+ transition: color 0.3s ease;
52
+ }
53
+
54
+ nav ul li a:hover {
55
+ color: #ff5733;
56
+ }
57
+
58
+ section {
59
+ padding: 20px;
60
+ background-color: #fff;
61
+ border-radius: 10px;
62
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
63
+ margin: 20px;
64
+ }
65
+
66
+ h1 {
67
+ color: #1b2850;
68
+ margin-bottom: 20px;
69
+ }
70
+
71
+ footer {
72
+ background-color: rgba(27, 40, 80, 1);
73
+ color: #fff;
74
+ text-align: center;
75
+ padding: 10px;
76
+ position: fixed;
77
+ bottom: 0;
78
+ width: 100%;
79
+ }
80
+
81
+ /* Responsive styles */
82
+ @media only screen and (max-width: 768px) {
83
+
84
+ /* Common styles for small screens */
85
+ nav ul li {
86
+ margin-right: 10px;
87
+ }
88
+
89
+ h1 {
90
+ font-size: 24px;
91
+ }
92
+
93
+ /* Styles for small screens */
94
+ .camera-section img {
95
+ width: 100%;
96
+ /* Use 100% width */
97
+ max-width: none;
98
+ /* Remove max-width */
99
+ }
100
+ }
101
+
102
+ /* Styles for medium to large screens */
103
+ @media only screen and (min-width: 769px) {
104
+ nav ul li {
105
+ margin-right: 20px;
106
+ margin-bottom: 0;
107
+ }
108
+
109
+ h1 {
110
+ font-size: 36px;
111
+ }
112
+
113
+ /* Styles for laptop and tablet views */
114
+ .camera-section {
115
+ text-align: center;
116
+ /* Center-align the container */
117
+ }
118
+
119
+ .camera-section img {
120
+ width: 70%;
121
+ /* Adjust width as needed */
122
+ max-width: 800px;
123
+ /* Set a maximum width */
124
+ margin: 0 auto;
125
+ /* Center the image */
126
+ }
127
+ }
128
+
129
+ /* Styles for the camera section */
130
+ .camera-section {
131
+ background-color: #f5f5f5e8;
132
+ padding: 20px;
133
+ border-radius: 10px;
134
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
135
+ margin-top: 20px;
136
+ }
137
+
138
+ #cameraFeed {
139
+ width: 100%;
140
+ /* Use 100% width of the container */
141
+ max-width: 800px;
142
+ /* Set a maximum width for larger screens */
143
+ border-radius: 10px;
144
+ align-items: center;
145
+ }
146
+ </style>
147
+ <title>Page 1</title>
148
+ </head>
149
+
150
+ <body>
151
+ <nav>
152
+ <img src="https://www.gsfcuni.edu.in/public/logo/White1.png" alt="Logo">
153
+ <ul>
154
+ <li><a href="/">Image</a></li>
155
+ <li><a href="/camera">Camera</a></li>
156
+ <li><a href="/report">Report</a></li>
157
+ </ul>
158
+ </nav>
159
+
160
+ <section class="camera-section">
161
+ <h1>Access Camera Section</h1>
162
+ <!-- Add code to turn on and display the camera feed using JavaScript -->
163
+ <img src="{{ url_for('detect_faces', camera_index=0) }}" alt="Face Detection">
164
+ <video id="cameraFeed" autoplay></video>
165
+ </section>
166
+
167
+ <footer>
168
+ Developed by Kshipra and Viraj
169
+ </footer>
170
+ <script src="camera.js"></script>
171
+ </body>
172
+
173
+ </html>
templates/pg4.html ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <link rel="stylesheet" href="report.css">
8
+ <link rel="stylesheet" href="common.css">
9
+
10
+ <title>Attendance System Report</title>
11
+ </head>
12
+
13
+ <body>
14
+ <nav>
15
+ <img src="https://www.gsfcuni.edu.in/public/logo/White1.png" alt="Logo">
16
+ <ul>
17
+ <li><a href="/">Image</a></li>
18
+ <li><a href="/camera">Camera</a></li>
19
+ <li><a href="/table">Table</a></li>
20
+ <li><a href="/report">Report</a></li>
21
+ </ul>
22
+ </nav>
23
+ <main class="main">
24
+ <section class="container">
25
+ <h1>Attendance System Project</h1>
26
+
27
+ <h2>Introduction</h2>
28
+ <p>
29
+ The Attendance System Project is an innovative solution developed as part of the Computer Vision
30
+ subject. It leverages the power of YOLO (You Only Look Once), a state-of-the-art object detection
31
+ framework, to automate attendance tracking in various contexts, such as classrooms, meetings, or events.
32
+ </p>
33
+
34
+ <h2>Features</h2>
35
+ <ul>
36
+ <li>Real-time Object Detection</li>
37
+ <li>Face Recognition</li>
38
+ <li>Automatic Attendance Recording</li>
39
+ <li>User-friendly Web Interface</li>
40
+ </ul>
41
+
42
+ <h2>Implementation</h2>
43
+ <p>
44
+ The project was implemented using Python and the YOLO framework. It involves training the YOLO model to
45
+ recognize faces and track them in real-time using a camera feed. When a recognized face is detected, the
46
+ system records the attendance of the corresponding individual.
47
+ </p>
48
+
49
+ <h2>Challenges</h2>
50
+ <p>
51
+ While implementing the project, several challenges were encountered, including real-time processing,
52
+ optimizing the YOLO model for speed, and ensuring accurate face recognition under various lighting
53
+ conditions.
54
+ </p>
55
+
56
+ <h2>Conclusion</h2>
57
+ <p>
58
+ The Attendance System Project demonstrates the potential of computer vision and deep learning in
59
+ automating attendance tracking processes. It offers a robust and efficient solution for educational
60
+ institutions and organizations seeking to streamline attendance management.
61
+ </p>
62
+ </section>
63
+ </main>
64
+ <footer>
65
+ Developed by Kshipra and Viraj
66
+ </footer>
67
+ </body>
68
+
69
+ </html>
templates/report.css ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* report.css */
2
+
3
+
4
+
5
+ header {
6
+ background-color: #fff;
7
+ box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
8
+ padding: 20px 0;
9
+ }
10
+
11
+ header nav {
12
+ display: flex;
13
+ justify-content: space-around;
14
+ align-items: center;
15
+ }
16
+
17
+ header a {
18
+ text-decoration: none;
19
+ color: #1b2850;
20
+ font-weight: bold;
21
+ transition: color 0.3s ease;
22
+ }
23
+
24
+ header a:hover {
25
+ color: #ff5733;
26
+ }
27
+
28
+ .main {
29
+ padding: 20px;
30
+ background-color: #fff;
31
+ border-radius: 10px;
32
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
33
+ margin: 20px;
34
+ }
35
+
36
+ .container {
37
+ max-width: 800px;
38
+ margin: 0 auto;
39
+ }
40
+
41
+ h1 {
42
+ color: #1b2850;
43
+ margin-bottom: 20px;
44
+ font-size: 32px;
45
+ font-weight: bold;
46
+ }
47
+
48
+ h2 {
49
+ color: #1b2850;
50
+ font-size: 24px;
51
+ font-weight: bold;
52
+ margin-top: 20px;
53
+ margin-bottom: 10px;
54
+ }
55
+
56
+ p {
57
+ color: #333;
58
+ font-size: 18px;
59
+ line-height: 1.6;
60
+ margin-bottom: 20px;
61
+ }
62
+
63
+ ul {
64
+ list-style-type: disc;
65
+ margin-left: 20px;
66
+ }
67
+
68
+ footer {
69
+ background-color: #1b2850;
70
+ color: #fff;
71
+ text-align: center;
72
+ padding: 20px 0;
73
+ }
74
+
75
+ .footer-content {
76
+ display: flex;
77
+ justify-content: space-around;
78
+ align-items: center;
79
+ }
80
+
81
+ .developer-info {
82
+ text-align: left;
83
+ }
84
+
85
+ .developer-info h3 {
86
+ font-size: 20px;
87
+ font-weight: bold;
88
+ margin-bottom: 10px;
89
+ }
90
+
91
+ .developer-info p {
92
+ margin: 0;
93
+ }
94
+
95
+ .additional-info {
96
+ text-align: right;
97
+ }
98
+
99
+ .additional-info p {
100
+ margin: 0;
101
+ }
templates/upload.css ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* upload.css */
2
+
3
+ .upload-section {
4
+ background-color: #f5f5f5;
5
+ text-align: center;
6
+ padding: 20px;
7
+ border-radius: 10px;
8
+ box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.1);
9
+ opacity: 0.9; /* Adjust the opacity value as needed */
10
+
11
+ }
12
+
13
+ #imageUpload {
14
+ display: block;
15
+ margin: 0 auto;
16
+ padding: 10px;
17
+ border: 2px dashed #ccc;
18
+ border-radius: 10px;
19
+ background-color: #fff;
20
+ cursor: pointer;
21
+ }
22
+
23
+ #imageUpload:hover {
24
+ border-color: #1b2850;
25
+ }
26
+
27
+ #imageUploadLabel {
28
+ display: block;
29
+ font-weight: bold;
30
+ margin-top: 10px;
31
+ }
32
+
33
+ #imagePreview {
34
+ max-width: 100%;
35
+ margin-top: 20px;
36
+ border-radius: 10px;
37
+ }
38
+
39
+ /* custom.css */
40
+
41
+ /* Style for the image preview container */
42
+ #imagePreviewContainer {
43
+ display: none;
44
+ text-align: center;
45
+ background-color: rgba(255, 255, 255, 0.9); /* Semi-transparent white background */
46
+ border-radius: 10px;
47
+ padding: 20px;
48
+ margin-top: 20px;
49
+ box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
50
+ }
51
+
52
+ /* Style for the h2 element within the image preview container */
53
+ #imagePreviewContainer h2 {
54
+ color: #1b2850; /* Text color similar to the GSFC University style */
55
+ font-size: 24px;
56
+ font-weight: bold;
57
+ }
58
+
59
+ /* Style for the image within the image preview container */
60
+ #imagePreview {
61
+ max-width: 100%;
62
+ height: auto;
63
+ margin-top: 10px;
64
+ border: 2px solid #1b2850; /* Border color similar to the GSFC University style */
65
+ border-radius: 5px;
66
+ }
67
+
68
+ /* custom.css */
69
+
70
+ /* Style for the "Preview" button */
71
+ #previewButton {
72
+ background-color: #1b2850; /* Background color similar to the GSFC University style */
73
+ color: #fff; /* Text color */
74
+ border: none;
75
+ padding: 10px 20px;
76
+ font-size: 16px;
77
+ font-weight: bold;
78
+ border-radius: 5px;
79
+ cursor: pointer;
80
+ transition: background-color 0.3s ease;
81
+ }
82
+
83
+ #previewButton:hover {
84
+ background-color: #ff5733; /* Change background color on hover */
85
+ }