Repository navigation
Expand file tree
/
Copy pathapp.py
More file actions
148 lines (94 loc) · 2.98 KB
/
Copy pathapp.py
File metadata and controls
148 lines (94 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
from flask import Flask, render_template, Response, Request, jsonify
import cv2
from open_cv import camera_capture_prediction, label_function, training_dataset, train_dataset_cnn
import multiprocessing
import threading
from tensorflow.keras.models import load_model
import mediapipe as mp
import numpy as np
import os
from sklearn.model_selection import train_test_split
from tensorflow.keras.utils import to_categorical
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Dense
from tensorflow.keras.callbacks import TensorBoard
import time
mp_holistic = mp.solutions.holistic
mp_drawing = mp.solutions.drawing_utils
app = Flask(__name__)
change_cam_status = 3
change_label_status = 3
DATA_PATH = os.path.join('MP_Data')
no_sequences = 10
sequence_length = 10
start_folder = 10
# List of gestures
list_of_gest = ['hello', 'thanks', 'iloveyou', 'ok']
# Actions that we try to detect
actions = np.array(list_of_gest)
colors = [(245, 117, 16), (117, 245, 16), (16, 117, 245), (16, 217, 245)]
@app.route('/')
def hello_world(): # put application's code here
return render_template('index.html')
@app.route('/camera_cap')
def camera_cap():
isopened = 1
if change_cam_status == 2:
isopened = 2
print('hi camera capture',isopened)
return Response(camera_capture_prediction(isopened), mimetype='multipart/x-mixed-replace; boundary=frame')
# return 'hi camera capture return'
@app.route('/open_cam')
def open_cam():
global change_cam_status
change_cam_status = 2
camera_cap()
print('hi open cam')
return render_template('predict.html')
@app.route('/close_cam')
def close_cam():
print('hi close cam')
global change_cam_status
change_cam_status = 4
camera_cap()
return render_template('predict.html')
@app.route('/camera')
def camera():
return render_template('predict.html')
@app.route('/label')
def label():
return render_template('label.html')
@app.route('/label_fun')
def label_fun():
isOpen = 1
global change_label_status
if change_label_status == 2:
isOpen = 2
return Response(label_function(isOpen), mimetype='multipart/x-mixed-replace; boundary=frame')
@app.route('/open_label_cam')
def open_label_cam():
global change_label_status
change_label_status = 2
label_fun()
return render_template('label.html')
@app.route('/close_label_cam')
def close_label_cam():
global change_label_status
change_label_status = 1
label_fun()
return render_template('label.html')
@app.route('/train_dataset')
def train_dataset():
training_dataset()
message_value = ' COMPLETED '
return render_template('label.html', value=message_value)
@app.route('/train_cnn')
def train_cnn():
train_dataset_cnn()
message_value = ' COMPLETED '
return render_template('label.html', value=message_value)
@app.route('/about_us')
def about_us():
return render_template('about.html')
if __name__ == '__main__':
app.run(debug=True)