Commit 91760e33 authored by YONG-LIN SU's avatar YONG-LIN SU

version 1 api server

parents
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import inception_resnet_v1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"from skimage.transform import resize\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"img=cv2.imread('nas/Face/test/test2.jpg')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"face_cascade = cv2.CascadeClassifier(\"Face-Clock/model/cv2/haarcascade_frontalface_alt2.xml\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"faces = face_cascade.detectMultiScale(img,scaleFactor=1.1,minNeighbors=3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# 人臉偵測處理回傳結果矩陣\n",
"image_size=160\n",
"def face_cropped(img,faces, margin): \n",
" aligned_images = []\n",
" for f in faces:\n",
" (x, y, w, h) = f\n",
" cropped = img[y-margin//2:y+h+margin//2,x-margin//2:x+w+margin//2, :]\n",
" aligned = resize(cropped, (image_size, image_size), mode='reflect')\n",
" aligned_images.append(aligned)\n",
" \n",
" return np.array(aligned_images)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"inception_resnet_v1.calc_embs(face_cropped(img,faces,10))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
FLASK_APP=run.py FLASK_DEBUG=1 flask run -h 0.0.0.0 -p 8000
\ No newline at end of file
Face-Clock @ 2fbb3cf9
Subproject commit 2fbb3cf9dffbeaa2f9b3c7d3ee7f4c9eaecd0b1e
import pypyodbc as odbc # MS SQL Server
import os as __os, logger as __log
__drive = "DRIVER={FreeTDS};"
__server = "SERVER=" + __os.environ['MSSQL_HOST'] + "," + __os.environ['MSSQL_PORT'] + ";"
__database = "DATABASE=" + __os.environ['MSSQL_DB'] + ';'
__uid = "UID=" + __os.environ['MSSQL_USR'] + ";"
__pwd = "PWD=" + __os.environ['MSSQL_PWD'] + ";"
__version = "TDS_Version=" + __os.environ['MSSQL_TDS'] + ";"
def select(table, columns="*"): # (資料表, 資料欄位)
if isinstance(columns, list): # 查詢特定多個欄位
for column in columns:
fields = (fields + ", " if 'fields' in vars() else "") + column
else: # 查詢特定或所有欄位
fields = columns
# 從資料表中選出指定欄位的內容
return "SELECT " + fields + " FROM " + table
def insert(table, data): # (資料表, 新增資料)
for key in data.keys():
fields = (fields + ", " if 'fields' in vars() else "") + key
value = str(data[key])
values = (values + ", " if 'values' in vars() else "") + "'" + value + "'"
# 新增資料列到資料表中
return "INSERT INTO " + table + " (" + fields + ") VALUES (" + values + ")"
def update(table, data):
for key in data.keys():
pair = key + " = '" + str(data[key]) + "'"
pairs = (pairs + ", " if 'pairs' in vars() else "") + pair
# 更新特定欄位的內容 `" + table + "` SET " + data_set
return "UPDATE " + table + " SET " + pairs
def delete(table):
return "DELETE FROM " + table
def where(query, column, logic, value):
condition = column + ' ' + logic + " '" + str(value) + "'"
# 設定查詢或更新符合條件的資料列
return query + " WHERE " + condition
def where_in(query, column, values):
if isinstance(values, list):
for value in values:
_in = (_in + ", " if '_in' in vars() else "") + "'" + value + "'"
else:
_in = "'" + values + "'"
# 設定查詢或更新符合條件的資料列
return query + " WHERE " + column + " IN (" + _in + ")"
def where_between(query, column, start, end):
_between = "'" + str(start) + "' AND '" + str(end) + "'"
return query + " WHERE " + column + " BETWEEN " + _between
def where_like(query, column, like):
return query + " WHERE " + column + " LIKE '" + like + "'"
def where_or(query, column, logic, value):
condition = column + " " + logic + " '" + str(value) + "'"
# 設定查詢或更新符合條件的資料列
return query + " OR " + condition
def where_and(query, column, logic, value):
condition = column + ' ' + logic + " '" + str(value) + "'"
# 設定查詢或更新符合條件的資料列
return query + " AND " + condition
def orderby(query, column, desc=False):
return query + " ORDER BY " + column + " " + ("DESC" if desc else "ASC")
def fetchall(ip, table, query):
connect = odbc.connect(__drive + __server + __database + __uid + __pwd + __version)
cursor = connect.cursor()
try:
cursor.execute(query)
rows = cursor.fetchall()
connect.commit()
except:
connect.rollback()
__log.write(ip, "ERROR", query)
return False
tag = len(rows) if isinstance(row, tuple) else 0
tag = "SELECT " + str(tag) + " data." if "SELECT" in query else tag
tag = "INSERT " + str(tag) + " data." if "INSERT" in query else tag
tag = "UPDATE " + str(tag) + " data." if "UPDATE" in query else tag
tag = "DELETE " + str(tag) + " data." if "DELETE" in query else tag
__log.write(ip, tag, table, query)
cursor.close()
connect.close()
return rows if isinstance(rows, tuple) else True
def fetchone(query):
connect = odbc.connect(__drive + __server + __database + __uid + __pwd + __version)
cursor = connect.cursor()
try:
cursor.execute(query)
row = cursor.fetchone() if "SELECT" in query else True
connect.commit()
except:
connect.rollback()
__log.write(ip, "ERROR", query)
return False
tag = len(row) if isinstance(row, tuple) else 0
tag = "SELECT " + str(tag) + " data." if "SELECT" in query else tag
tag = "INSERT " + str(tag) + " data." if "INSERT" in query else tag
tag = "UPDATE " + str(tag) + " data." if "UPDATE" in query else tag
tag = "DELETE " + str(tag) + " data." if "DELETE" in query else tag
__log.write(ip, tag, table, query)
cursor.close()
connect.close()
return row if isinstance(row, tuple) else True
\ No newline at end of file
from flask import Flask as __flask
from flaskext.mysql import MySQL as __mysql
import os as __os, logger as __log
__app = __flask(__name__)
__app.config['MYSQL_DATABASE_HOST'] = __os.environ['MYSQL_HOST']
__app.config['MYSQL_DATABASE_PORT'] = int(__os.environ['MYSQL_PORT'])
__app.config['MYSQL_DATABASE_USER'] = __os.environ['MYSQL_USR']
__app.config['MYSQL_DATABASE_PASSWORD'] = __os.environ['MYSQL_PWD']
__app.config['MYSQL_DATABASE_DB'] = 'chiayi'
__mysql = __mysql()
__mysql.init_app(__app)
def select(table, columns="*"):
if isinstance(columns, list):
for column in columns:
fields = (fields + ", " if 'fields' in vars() else "") + "`" + column + "`"
else:
fields = "`" + columns + "`"
return "SELECT " + fields + " FROM `" + table + "`"
def insert(table, data):
for key in data.keys():
fields = (fields + ", " if 'fields' in vars() else "") + "`" + key + "`"
value = str(data[key])
values = (values + ", " if 'values' in vars() else "") + "'" + value + "'"
return "INSERT INTO `" + table + "` (" + fields + ") VALUES (" + values + ")"
def update(table, data):
for key in data.keys():
pair = "`" + key + "` = '" + str(data[key]) + "'"
pairs = (pairs + ", " if 'pairs' in vars() else "") + pair
return "UPDATE `" + table + "` SET " + pairs
def delete(table):
return "DELETE FROM `" + table + "`"
def where(query, column, logic, value):
condition = '`' + column + '` ' + logic + " '" + str(value) + "'"
return query + " WHERE " + condition
def where_in(query, column, values):
if isinstance(values, list):
for value in values:
temp = (temp + ", " if 'temp' in vars() else "") + "'" + value + "'"
else:
temp = "'" + values + "'"
return query + " WHERE `" + column + "` IN (" + temp + ")"
def where_between(query, column, start, end):
temp = "'" + str(start) + "' AND '" + str(end) + "'"
return query + " WHERE `" + column + "` BETWEEN " + temp
def where_like(query, column, like):
return query + " WHERE `" + column + "` LIKE '" + like + "'"
def where_or(query, column, logic, value):
condition = '`' + column + '` ' + logic + " '" + str(value) + "'"
return query + " OR " + condition
def where_and(query, column, logic, value):
condition = '`' + column + '` ' + logic + " '" + str(value) + "'"
return query + " AND " + condition
def orderby(query, column, desc=False):
return query + " ORDER BY `" + column + "` " + ("DESC" if desc else "ASC")
def fetchall(ip, table, query):
connect = __mysql.connect()
cursor = connect.cursor()
try:
cursor.execute(query)
rows = cursor.fetchall()
connect.commit()
except:
connect.rollback()
__log.write(ip, "ERROR", query)
return False
tag = str(connect.affected_rows())
tag = "SELECT " + tag + " data" if "SELECT" in query else tag
tag = "INSERT " + tag + " data" if "INSERT" in query else tag
tag = "UPDATE " + tag + " data" if "UPDATE" in query else tag
tag = "DELETE " + tag + " data" if "DELETE" in query else tag
__log.write(ip, tag, table, query)
cursor.close()
connect.close()
return rows if isinstance(rows, tuple) else True
def fetchone(ip, table, query):
connect = __mysql.connect()
cursor = connect.cursor()
try:
cursor.execute(query)
row = cursor.fetchone()
connect.commit()
except:
connect.rollback()
__log.write(ip, "ERROR", query)
return False
tag = str(connect.affected_rows())
tag = "SELECT " + tag + " data" if "SELECT" in query else tag
tag = "INSERT " + tag + " data" if "INSERT" in query else tag
tag = "UPDATE " + tag + " data" if "UPDATE" in query else tag
tag = "DELETE " + tag + " data" if "DELETE" in query else tag
__log.write(ip, tag, table, query)
cursor.close()
connect.close()
return row if isinstance(row, tuple) else True
\ No newline at end of file
import cv2
from skimage.transform import resize
import numpy as np
face_cascade = cv2.CascadeClassifier("Face-Clock/model/cv2/haarcascade_frontalface_alt2.xml")
print("人臉偵測cascade分類器載入完成")
# 人臉偵測處理回傳結果矩陣
image_size=160
def face_cropped(img,faces, margin):
aligned_images = []
for f in faces:
(x, y, w, h) = f
cropped = img[y-margin//2:y+h+margin//2,x-margin//2:x+w+margin//2, :]
aligned = resize(cropped, (image_size, image_size), mode='reflect')
aligned_images.append(aligned)
return np.array(aligned_images)
def get_face(img):
faces = face_cascade.detectMultiScale(img,scaleFactor=1.1,minNeighbors=3)
if(len(faces)==0):
return '偵測不到人臉請重新調整'
else:
return faces,face_cropped(img,faces,10)
\ No newline at end of file
# -*- coding: utf-8 -*-
"""Inception-ResNet V1 model for Keras.
# Reference
http://arxiv.org/abs/1602.07261
https://github.com/davidsandberg/facenet/blob/master/src/models/inception_resnet_v1.py
https://github.com/myutwo150/keras-inception-resnet-v2/blob/master/inception_resnet_v2.py
"""
from functools import partial
from keras.models import Model
from keras.layers import Activation
from keras.layers import BatchNormalization
from keras.layers import Concatenate
from keras.layers import Conv2D
from keras.layers import Dense
from keras.layers import Dropout
from keras.layers import GlobalAveragePooling2D
from keras.layers import Input
from keras.layers import Lambda
from keras.layers import MaxPooling2D
from keras.layers import add
from keras import backend as K
K.set_image_dim_ordering('tf')
import tensorflow as tf
import os
import numpy as np
def scaling(x, scale):
return x * scale
def conv2d_bn(x,
filters,
kernel_size,
strides=1,
padding='same',
activation='relu',
use_bias=False,
name=None):
x = Conv2D(filters,
kernel_size,
strides=strides,
padding=padding,
use_bias=use_bias,
name=name)(x)
if not use_bias:
bn_axis = 1 if K.image_data_format() == 'channels_first' else 3
bn_name = _generate_layer_name('BatchNorm', prefix=name)
x = BatchNormalization(axis=bn_axis, momentum=0.995, epsilon=0.001,
scale=False, name=bn_name)(x)
if activation is not None:
ac_name = _generate_layer_name('Activation', prefix=name)
x = Activation(activation, name=ac_name)(x)
return x
def _generate_layer_name(name, branch_idx=None, prefix=None):
if prefix is None:
return None
if branch_idx is None:
return '_'.join((prefix, name))
return '_'.join((prefix, 'Branch', str(branch_idx), name))
def _inception_resnet_block(x, scale, block_type, block_idx, activation='relu'):
channel_axis = 1 if K.image_data_format() == 'channels_first' else 3
if block_idx is None:
prefix = None
else:
prefix = '_'.join((block_type, str(block_idx)))
name_fmt = partial(_generate_layer_name, prefix=prefix)
if block_type == 'Block35':
branch_0 = conv2d_bn(x, 32, 1, name=name_fmt('Conv2d_1x1', 0))
branch_1 = conv2d_bn(x, 32, 1, name=name_fmt('Conv2d_0a_1x1', 1))
branch_1 = conv2d_bn(branch_1, 32, 3, name=name_fmt('Conv2d_0b_3x3', 1))
branch_2 = conv2d_bn(x, 32, 1, name=name_fmt('Conv2d_0a_1x1', 2))
branch_2 = conv2d_bn(branch_2, 32, 3, name=name_fmt('Conv2d_0b_3x3', 2))
branch_2 = conv2d_bn(branch_2, 32, 3, name=name_fmt('Conv2d_0c_3x3', 2))
branches = [branch_0, branch_1, branch_2]
elif block_type == 'Block17':
branch_0 = conv2d_bn(x, 128, 1, name=name_fmt('Conv2d_1x1', 0))
branch_1 = conv2d_bn(x, 128, 1, name=name_fmt('Conv2d_0a_1x1', 1))
branch_1 = conv2d_bn(branch_1, 128, [1, 7], name=name_fmt('Conv2d_0b_1x7', 1))
branch_1 = conv2d_bn(branch_1, 128, [7, 1], name=name_fmt('Conv2d_0c_7x1', 1))
branches = [branch_0, branch_1]
elif block_type == 'Block8':
branch_0 = conv2d_bn(x, 192, 1, name=name_fmt('Conv2d_1x1', 0))
branch_1 = conv2d_bn(x, 192, 1, name=name_fmt('Conv2d_0a_1x1', 1))
branch_1 = conv2d_bn(branch_1, 192, [1, 3], name=name_fmt('Conv2d_0b_1x3', 1))
branch_1 = conv2d_bn(branch_1, 192, [3, 1], name=name_fmt('Conv2d_0c_3x1', 1))
branches = [branch_0, branch_1]
else:
raise ValueError('Unknown Inception-ResNet block type. '
'Expects "Block35", "Block17" or "Block8", '
'but got: ' + str(block_type))
mixed = Concatenate(axis=channel_axis, name=name_fmt('Concatenate'))(branches)
up = conv2d_bn(mixed,
K.int_shape(x)[channel_axis],
1,
activation=None,
use_bias=True,
name=name_fmt('Conv2d_1x1'))
up = Lambda(scaling,
output_shape=K.int_shape(up)[1:],
arguments={'scale': scale})(up)
x = add([x, up])
if activation is not None:
x = Activation(activation, name=name_fmt('Activation'))(x)
return x
def InceptionResNetV1(input_shape=(160, 160, 3),
classes=128,
dropout_keep_prob=0.8,
weights_path=None):
inputs = Input(shape=input_shape)
x = conv2d_bn(inputs, 32, 3, strides=2, padding='valid', name='Conv2d_1a_3x3')
x = conv2d_bn(x, 32, 3, padding='valid', name='Conv2d_2a_3x3')
x = conv2d_bn(x, 64, 3, name='Conv2d_2b_3x3')
x = MaxPooling2D(3, strides=2, name='MaxPool_3a_3x3')(x)
x = conv2d_bn(x, 80, 1, padding='valid', name='Conv2d_3b_1x1')
x = conv2d_bn(x, 192, 3, padding='valid', name='Conv2d_4a_3x3')
x = conv2d_bn(x, 256, 3, strides=2, padding='valid', name='Conv2d_4b_3x3')
# 5x Block35 (Inception-ResNet-A block):
for block_idx in range(1, 6):
x = _inception_resnet_block(x,
scale=0.17,
block_type='Block35',
block_idx=block_idx)
# Mixed 6a (Reduction-A block):
channel_axis = 1 if K.image_data_format() == 'channels_first' else 3
name_fmt = partial(_generate_layer_name, prefix='Mixed_6a')
branch_0 = conv2d_bn(x,
384,
3,
strides=2,
padding='valid',
name=name_fmt('Conv2d_1a_3x3', 0))
branch_1 = conv2d_bn(x, 192, 1, name=name_fmt('Conv2d_0a_1x1', 1))
branch_1 = conv2d_bn(branch_1, 192, 3, name=name_fmt('Conv2d_0b_3x3', 1))
branch_1 = conv2d_bn(branch_1,
256,
3,
strides=2,
padding='valid',
name=name_fmt('Conv2d_1a_3x3', 1))
branch_pool = MaxPooling2D(3,
strides=2,
padding='valid',
name=name_fmt('MaxPool_1a_3x3', 2))(x)
branches = [branch_0, branch_1, branch_pool]
x = Concatenate(axis=channel_axis, name='Mixed_6a')(branches)
# 10x Block17 (Inception-ResNet-B block):
for block_idx in range(1, 11):
x = _inception_resnet_block(x,
scale=0.1,
block_type='Block17',
block_idx=block_idx)
# Mixed 7a (Reduction-B block): 8 x 8 x 2080
name_fmt = partial(_generate_layer_name, prefix='Mixed_7a')
branch_0 = conv2d_bn(x, 256, 1, name=name_fmt('Conv2d_0a_1x1', 0))
branch_0 = conv2d_bn(branch_0,
384,
3,
strides=2,
padding='valid',
name=name_fmt('Conv2d_1a_3x3', 0))
branch_1 = conv2d_bn(x, 256, 1, name=name_fmt('Conv2d_0a_1x1', 1))
branch_1 = conv2d_bn(branch_1,
256,
3,
strides=2,
padding='valid',
name=name_fmt('Conv2d_1a_3x3', 1))
branch_2 = conv2d_bn(x, 256, 1, name=name_fmt('Conv2d_0a_1x1', 2))
branch_2 = conv2d_bn(branch_2, 256, 3, name=name_fmt('Conv2d_0b_3x3', 2))
branch_2 = conv2d_bn(branch_2,
256,
3,
strides=2,
padding='valid',
name=name_fmt('Conv2d_1a_3x3', 2))
branch_pool = MaxPooling2D(3,
strides=2,
padding='valid',
name=name_fmt('MaxPool_1a_3x3', 3))(x)
branches = [branch_0, branch_1, branch_2, branch_pool]
x = Concatenate(axis=channel_axis, name='Mixed_7a')(branches)
# 5x Block8 (Inception-ResNet-C block):
for block_idx in range(1, 6):
x = _inception_resnet_block(x,
scale=0.2,
block_type='Block8',
block_idx=block_idx)
x = _inception_resnet_block(x,
scale=1.,
activation=None,
block_type='Block8',
block_idx=6)
# Classification block
x = GlobalAveragePooling2D(name='AvgPool')(x)
x = Dropout(1.0 - dropout_keep_prob, name='Dropout')(x)
# Bottleneck
x = Dense(classes, use_bias=False, name='Bottleneck')(x)
bn_name = _generate_layer_name('BatchNorm', prefix='Bottleneck')
x = BatchNormalization(momentum=0.995, epsilon=0.001, scale=False,
name=bn_name)(x)
# Create model
model = Model(inputs, x, name='inception_resnet_v1')
if weights_path is not None:
model.load_weights(weights_path)
return model
model = InceptionResNetV1()
def load_model():
global model
model.load_weights(os.path.abspath('./Face-Clock/model/keras/weights/facenet_keras_weights.h5'))
global graph
graph = tf.get_default_graph()
load_model()
# 影像預處理
def prewhiten(x):
if x.ndim == 4:
axis = (1, 2, 3)
size = x[0].size
elif x.ndim == 3:
axis = (0, 1, 2)
size = x.size
else:
print(x.ndim)
raise ValueError('Dimension should be 3 or 4')
mean = np.mean(x, axis=axis, keepdims=True)
std = np.std(x, axis=axis, keepdims=True)
std_adj = np.maximum(std, 1.0/np.sqrt(size))
y = (x - mean) / std_adj
return y
def l2_normalize(x, axis=-1, epsilon=1e-10):
output = x / np.sqrt(np.maximum(np.sum(np.square(x), axis=axis, keepdims=True), epsilon))
return output
# 人臉特徵預測
def calc_embs(faces, margin=10, batch_size=1):
aligned_images = prewhiten(faces)
pd = []
for start in range(0, len(aligned_images), batch_size):
with graph.as_default():
pd.append(model.predict_on_batch(aligned_images[start:start+batch_size]))
embs = l2_normalize(np.concatenate(pd))
return embs
192.168.5.202 - - [18/May/2019:04:22:57 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - admin [18/May/2019:04:22:57 +0000] "GET /api/param.cgi?req=General.Brand.CompanyName&req=General.Brand.ModelName HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - root [18/May/2019:04:22:57 +0000] "GET /api/param.cgi?req=General.Brand.CompanyName&req=General.Brand.ModelName HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [18/May/2019:04:22:57 +0000] "GET /get.oid?2.27 HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [18/May/2019:04:22:57 +0000] "GET /stw-cgi/attributes.cgi/attributes HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [18/May/2019:04:22:57 +0000] "GET /ISAPI/System/Network/Integrate HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [18/May/2019:04:22:57 +0000] "GET /ISAPI/Security/ONVIF/users/ HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [18/May/2019:04:22:57 +0000] "GET /get?model HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [18/May/2019:04:22:57 +0000] "POST /onvif/device_service HTTP/1.1" 500 32 "-" "gSOAP/2.8"
192.168.5.202 - - [18/May/2019:04:22:57 +0000] "POST /onvif/device_service HTTP/1.1" 500 32 "-" "gSOAP/2.8"
192.168.5.202 - - [18/May/2019:04:22:57 +0000] "GET /axis-cgi/param.cgi?action=list&group=root.Network.Bonjour.FriendlyName HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [18/May/2019:04:22:57 +0000] "GET /cgi-bin/system?USER=&PWD=&SYSTEM_INFO HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [18/May/2019:04:22:57 +0000] "GET /common/info.cgi HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [18/May/2019:04:23:12 +0000] "GET / HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [18/May/2019:04:23:12 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [18/May/2019:04:23:12 +0000] "GET /common/info.cgi HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [18/May/2019:04:23:12 +0000] "GET /get?model HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [18/May/2019:04:23:12 +0000] "GET /ISAPI/System/Network/Integrate HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [18/May/2019:04:23:12 +0000] "GET /ISAPI/Security/ONVIF/users/ HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [18/May/2019:04:23:12 +0000] "POST /onvif/device_service HTTP/1.1" 500 32 "-" "gSOAP/2.8"
192.168.5.202 - - [18/May/2019:04:23:12 +0000] "POST /onvif/device_service HTTP/1.1" 500 32 "-" "gSOAP/2.8"
192.168.5.202 - - [18/May/2019:04:23:12 +0000] "GET /cgi-bin/system?USER=&PWD=&SYSTEM_INFO HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [18/May/2019:04:23:12 +0000] "GET /stw-cgi/attributes.cgi/attributes HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [18/May/2019:04:23:12 +0000] "GET /axis-cgi/param.cgi?action=list&group=root.Network.Bonjour.FriendlyName HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - admin [18/May/2019:04:23:12 +0000] "GET /api/param.cgi?req=General.Brand.CompanyName&req=General.Brand.ModelName HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [18/May/2019:04:23:12 +0000] "GET /get.oid?2.27 HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - root [18/May/2019:04:23:12 +0000] "GET /api/param.cgi?req=General.Brand.CompanyName&req=General.Brand.ModelName HTTP/1.1" 500 32 "-" "-"
192.168.6.105 - - [20/May/2019:07:43:27 +0000] "GET / HTTP/1.1" 500 32 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36"
192.168.6.105 - - [20/May/2019:07:43:27 +0000] "GET /robots.txt HTTP/1.1" 500 32 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36"
192.168.6.105 - - [20/May/2019:07:43:27 +0000] "GET /favicon.ico HTTP/1.1" 500 32 "http://192.168.5.201/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36"
192.168.6.105 - - [20/May/2019:07:44:02 +0000] "GET /favicon.ico HTTP/1.1" 500 32 "http://192.168.5.201/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36"
192.168.5.202 - - [21/May/2019:06:33:53 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [21/May/2019:06:34:07 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [21/May/2019:06:34:31 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - admin [22/May/2019:07:37:47 +0000] "GET /get?model HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - admin [22/May/2019:07:38:02 +0000] "GET /get?model HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - admin [22/May/2019:07:38:17 +0000] "GET /get?model HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [22/May/2019:08:07:13 +0000] "\x00\x01\x00\x00\x00" 400 182 "-" "-"
192.168.5.202 - - [22/May/2019:08:07:13 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - admin [22/May/2019:08:07:13 +0000] "GET /get?model HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - admin [22/May/2019:08:07:13 +0000] "GET /axis-cgi/param.cgi?action=list&group=root.Network.Bonjour.FriendlyName HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - admin [22/May/2019:08:07:13 +0000] "GET /common/info.cgi HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [22/May/2019:08:07:13 +0000] "GET /stw-cgi/attributes.cgi/attributes HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:07:13 +0000] "GET /ISAPI/System/Network/Integrate HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:07:13 +0000] "GET /ISAPI/Security/ONVIF/users/ HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:07:13 +0000] "POST /onvif/device_service HTTP/1.1" 500 32 "-" "gSOAP/2.8"
192.168.5.202 - - [22/May/2019:08:07:13 +0000] "POST /onvif/device_service HTTP/1.1" 500 32 "-" "gSOAP/2.8"
192.168.5.202 - - [22/May/2019:08:07:13 +0000] "GET /cgi-bin/system?USER=admin&PWD=admin&SYSTEM_INFO HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [22/May/2019:08:07:13 +0000] "GET /get.oid?2.27 HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - admin [22/May/2019:08:07:13 +0000] "GET /api/param.cgi?req=General.Brand.CompanyName&req=General.Brand.ModelName HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [22/May/2019:08:11:19 +0000] "\x00\x01\x00\x00\x00" 400 182 "-" "-"
192.168.5.202 - - [22/May/2019:08:11:19 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - admin [22/May/2019:08:11:19 +0000] "GET /common/info.cgi HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - admin [22/May/2019:08:11:19 +0000] "GET /get?model HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [22/May/2019:08:11:19 +0000] "GET /cgi-bin/system?USER=admin&PWD=admin&SYSTEM_INFO HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - admin [22/May/2019:08:11:19 +0000] "GET /axis-cgi/param.cgi?action=list&group=root.Network.Bonjour.FriendlyName HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - admin [22/May/2019:08:11:19 +0000] "GET /api/param.cgi?req=General.Brand.CompanyName&req=General.Brand.ModelName HTTP/1.1" 500 32 "-" "-"
192.168.5.202 - - [22/May/2019:08:11:19 +0000] "GET /get.oid?2.27 HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:11:19 +0000] "GET /stw-cgi/attributes.cgi/attributes HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:11:19 +0000] "GET /ISAPI/System/Network/Integrate HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:11:19 +0000] "GET /ISAPI/Security/ONVIF/users/ HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:11:19 +0000] "POST /onvif/device_service HTTP/1.1" 500 32 "-" "gSOAP/2.8"
192.168.5.202 - - [22/May/2019:08:11:19 +0000] "POST /onvif/device_service HTTP/1.1" 500 32 "-" "gSOAP/2.8"
192.168.5.202 - - [22/May/2019:08:12:04 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:12:04 +0000] "GET / HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:15:12 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:15:12 +0000] "GET /test HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:15:43 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:16:38 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:39:26 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:08:46:03 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:09:00:40 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:09:20:25 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:09:39:53 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:09:47:52 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:09:55:45 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
192.168.5.202 - - [22/May/2019:10:09:14 +0000] "GET /page/factory/production/info HTTP/1.1" 500 32 "-" "Nx Witness/3.2.0.28738 (Network Optix) Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:36.0)"
*** Starting uWSGI 2.0.18 (64bit) on [Wed May 15 07:31:16 2019] ***
compiled with version: 7.4.0 on 15 May 2019 04:49:44
os: Linux-4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018
nodename: 30a7368646e4
machine: x86_64
clock source: unix
detected number of CPU cores: 8
current working directory: /notebooks
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /notebooks
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:5000 fd 3
uwsgi socket 1 bound to UNIX address /notebooks/uwsgi.sock fd 4
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55b74792ef10
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 364520 bytes (355 KB) for 5 cores
*** Operational MODE: preforking ***
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 7, cores: 1)
spawned uWSGI worker 2 (pid: 19, cores: 1)
spawned uWSGI worker 3 (pid: 20, cores: 1)
spawned uWSGI worker 4 (pid: 21, cores: 1)
spawned uWSGI worker 5 (pid: 22, cores: 1)
*** Starting uWSGI 2.0.18 (64bit) on [Thu May 16 07:42:07 2019] ***
compiled with version: 7.4.0 on 15 May 2019 04:49:44
os: Linux-4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018
nodename: bddbe8cafe82
machine: x86_64
clock source: unix
detected number of CPU cores: 8
current working directory: /notebooks
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /notebooks
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:5000 fd 3
uwsgi socket 1 bound to UNIX address /notebooks/uwsgi.sock fd 4
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55efdfad3f10
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 364520 bytes (355 KB) for 5 cores
*** Operational MODE: preforking ***
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 7, cores: 1)
spawned uWSGI worker 2 (pid: 19, cores: 1)
spawned uWSGI worker 3 (pid: 20, cores: 1)
spawned uWSGI worker 4 (pid: 21, cores: 1)
spawned uWSGI worker 5 (pid: 22, cores: 1)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/1] 192.168.5.202 () {36 vars in 569 bytes} [Sat May 18 04:22:57 2019] GET /page/factory/production/info => generated 21 bytes in 154 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/2] 192.168.5.202 () {30 vars in 488 bytes} [Sat May 18 04:22:57 2019] GET /api/param.cgi?req=General.Brand.CompanyName&req=General.Brand.ModelName => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/3] 192.168.5.202 () {36 vars in 536 bytes} [Sat May 18 04:22:57 2019] GET /get.oid?2.27 => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/4] 192.168.5.202 () {36 vars in 579 bytes} [Sat May 18 04:22:57 2019] GET /stw-cgi/attributes.cgi/attributes => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/5] 192.168.5.202 () {36 vars in 573 bytes} [Sat May 18 04:22:57 2019] GET /ISAPI/System/Network/Integrate => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/6] 192.168.5.202 () {30 vars in 488 bytes} [Sat May 18 04:22:57 2019] GET /api/param.cgi?req=General.Brand.CompanyName&req=General.Brand.ModelName => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/7] 192.168.5.202 () {36 vars in 567 bytes} [Sat May 18 04:22:57 2019] GET /ISAPI/Security/ONVIF/users/ => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/8] 192.168.5.202 () {28 vars in 320 bytes} [Sat May 18 04:22:57 2019] GET /get?model => generated 21 bytes in 30 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/9] 192.168.5.202 () {38 vars in 738 bytes} [Sat May 18 04:22:57 2019] POST /onvif/device_service => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/10] 192.168.5.202 () {38 vars in 738 bytes} [Sat May 18 04:22:57 2019] POST /onvif/device_service => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
--- no python application found, check your startup logs for errors ---
[pid: 20|app: -1|req: -1/12] 192.168.5.202 () {28 vars in 376 bytes} [Sat May 18 04:22:57 2019] GET /cgi-bin/system?USER=&PWD=&SYSTEM_INFO => generated 21 bytes in 37 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
[pid: 7|app: -1|req: -1/12] 192.168.5.202 () {28 vars in 442 bytes} [Sat May 18 04:22:57 2019] GET /axis-cgi/param.cgi?action=list&group=root.Network.Bonjour.FriendlyName => generated 21 bytes in 34 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/13] 192.168.5.202 () {28 vars in 333 bytes} [Sat May 18 04:22:57 2019] GET /common/info.cgi => generated 21 bytes in 54 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/14] 192.168.5.202 () {36 vars in 513 bytes} [Sat May 18 04:23:12 2019] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/15] 192.168.5.202 () {36 vars in 569 bytes} [Sat May 18 04:23:12 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/16] 192.168.5.202 () {28 vars in 333 bytes} [Sat May 18 04:23:12 2019] GET /common/info.cgi => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/17] 192.168.5.202 () {28 vars in 320 bytes} [Sat May 18 04:23:12 2019] GET /get?model => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/18] 192.168.5.202 () {36 vars in 573 bytes} [Sat May 18 04:23:12 2019] GET /ISAPI/System/Network/Integrate => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/19] 192.168.5.202 () {36 vars in 567 bytes} [Sat May 18 04:23:12 2019] GET /ISAPI/Security/ONVIF/users/ => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/20] 192.168.5.202 () {38 vars in 738 bytes} [Sat May 18 04:23:12 2019] POST /onvif/device_service => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/21] 192.168.5.202 () {38 vars in 738 bytes} [Sat May 18 04:23:12 2019] POST /onvif/device_service => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 20|app: -1|req: -1/22] 192.168.5.202 () {28 vars in 376 bytes} [Sat May 18 04:23:12 2019] GET /cgi-bin/system?USER=&PWD=&SYSTEM_INFO => generated 21 bytes in 13 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 7|app: -1|req: -1/23] 192.168.5.202 () {36 vars in 579 bytes} [Sat May 18 04:23:12 2019] GET /stw-cgi/attributes.cgi/attributes => generated 21 bytes in 21 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/24] 192.168.5.202 () {28 vars in 442 bytes} [Sat May 18 04:23:12 2019] GET /axis-cgi/param.cgi?action=list&group=root.Network.Bonjour.FriendlyName => generated 21 bytes in 22 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/25] 192.168.5.202 () {30 vars in 488 bytes} [Sat May 18 04:23:12 2019] GET /api/param.cgi?req=General.Brand.CompanyName&req=General.Brand.ModelName => generated 21 bytes in 5 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/26] 192.168.5.202 () {36 vars in 536 bytes} [Sat May 18 04:23:12 2019] GET /get.oid?2.27 => generated 21 bytes in 5 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/27] 192.168.5.202 () {30 vars in 488 bytes} [Sat May 18 04:23:12 2019] GET /api/param.cgi?req=General.Brand.CompanyName&req=General.Brand.ModelName => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
--- no python application found, check your startup logs for errors ---
[pid: 20|app: -1|req: -1/29] 192.168.6.105 () {44 vars in 804 bytes} [Mon May 20 07:43:27 2019] GET / => generated 21 bytes in 32 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
[pid: 7|app: -1|req: -1/29] 192.168.6.105 () {42 vars in 674 bytes} [Mon May 20 07:43:27 2019] GET /robots.txt => generated 21 bytes in 33 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 7|app: -1|req: -1/30] 192.168.6.105 () {44 vars in 749 bytes} [Mon May 20 07:43:27 2019] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/31] 192.168.6.105 () {44 vars in 749 bytes} [Mon May 20 07:44:02 2019] GET /favicon.ico => generated 21 bytes in 62 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/32] 192.168.5.202 () {36 vars in 569 bytes} [Tue May 21 06:33:53 2019] GET /page/factory/production/info => generated 21 bytes in 45 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/33] 192.168.5.202 () {36 vars in 569 bytes} [Tue May 21 06:34:07 2019] GET /page/factory/production/info => generated 21 bytes in 99 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 20|app: -1|req: -1/34] 192.168.5.202 () {36 vars in 569 bytes} [Tue May 21 06:34:31 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/35] 192.168.5.202 () {30 vars in 368 bytes} [Wed May 22 07:37:47 2019] GET /get?model => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/36] 192.168.5.202 () {30 vars in 368 bytes} [Wed May 22 07:38:02 2019] GET /get?model => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/37] 192.168.5.202 () {30 vars in 368 bytes} [Wed May 22 07:38:17 2019] GET /get?model => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/38] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 08:07:13 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/39] 192.168.5.202 () {30 vars in 486 bytes} [Wed May 22 08:07:13 2019] GET /axis-cgi/param.cgi?action=list&group=root.Network.Bonjour.FriendlyName => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/40] 192.168.5.202 () {30 vars in 364 bytes} [Wed May 22 08:07:13 2019] GET /get?model => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/41] 192.168.5.202 () {30 vars in 377 bytes} [Wed May 22 08:07:13 2019] GET /common/info.cgi => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/42] 192.168.5.202 () {38 vars in 601 bytes} [Wed May 22 08:07:13 2019] GET /ISAPI/System/Network/Integrate => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/43] 192.168.5.202 () {38 vars in 607 bytes} [Wed May 22 08:07:13 2019] GET /stw-cgi/attributes.cgi/attributes => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/44] 192.168.5.202 () {38 vars in 595 bytes} [Wed May 22 08:07:13 2019] GET /ISAPI/Security/ONVIF/users/ => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/45] 192.168.5.202 () {38 vars in 738 bytes} [Wed May 22 08:07:13 2019] POST /onvif/device_service => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/46] 192.168.5.202 () {38 vars in 738 bytes} [Wed May 22 08:07:13 2019] POST /onvif/device_service => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/47] 192.168.5.202 () {28 vars in 396 bytes} [Wed May 22 08:07:13 2019] GET /cgi-bin/system?USER=admin&PWD=admin&SYSTEM_INFO => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/48] 192.168.5.202 () {38 vars in 564 bytes} [Wed May 22 08:07:13 2019] GET /get.oid?2.27 => generated 21 bytes in 3 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/49] 192.168.5.202 () {30 vars in 488 bytes} [Wed May 22 08:07:13 2019] GET /api/param.cgi?req=General.Brand.CompanyName&req=General.Brand.ModelName => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/50] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 08:11:19 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/51] 192.168.5.202 () {30 vars in 377 bytes} [Wed May 22 08:11:19 2019] GET /common/info.cgi => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/52] 192.168.5.202 () {30 vars in 364 bytes} [Wed May 22 08:11:19 2019] GET /get?model => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/53] 192.168.5.202 () {28 vars in 396 bytes} [Wed May 22 08:11:19 2019] GET /cgi-bin/system?USER=admin&PWD=admin&SYSTEM_INFO => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/54] 192.168.5.202 () {30 vars in 486 bytes} [Wed May 22 08:11:19 2019] GET /axis-cgi/param.cgi?action=list&group=root.Network.Bonjour.FriendlyName => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/55] 192.168.5.202 () {30 vars in 488 bytes} [Wed May 22 08:11:19 2019] GET /api/param.cgi?req=General.Brand.CompanyName&req=General.Brand.ModelName => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/56] 192.168.5.202 () {38 vars in 564 bytes} [Wed May 22 08:11:19 2019] GET /get.oid?2.27 => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/57] 192.168.5.202 () {38 vars in 607 bytes} [Wed May 22 08:11:19 2019] GET /stw-cgi/attributes.cgi/attributes => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/58] 192.168.5.202 () {38 vars in 601 bytes} [Wed May 22 08:11:19 2019] GET /ISAPI/System/Network/Integrate => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/59] 192.168.5.202 () {38 vars in 595 bytes} [Wed May 22 08:11:19 2019] GET /ISAPI/Security/ONVIF/users/ => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 20|app: -1|req: -1/60] 192.168.5.202 () {38 vars in 738 bytes} [Wed May 22 08:11:19 2019] POST /onvif/device_service => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/61] 192.168.5.202 () {38 vars in 738 bytes} [Wed May 22 08:11:19 2019] POST /onvif/device_service => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/62] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 08:12:04 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/63] 192.168.5.202 () {38 vars in 541 bytes} [Wed May 22 08:12:04 2019] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/64] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 08:15:12 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 22|app: -1|req: -1/65] 192.168.5.202 () {38 vars in 549 bytes} [Wed May 22 08:15:12 2019] GET /test => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 7|app: -1|req: -1/66] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 08:15:43 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/67] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 08:16:38 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/68] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 08:39:26 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/69] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 08:46:03 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 19|app: -1|req: -1/70] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 09:00:40 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/71] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 09:20:25 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 7|app: -1|req: -1/72] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 09:39:53 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/73] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 09:47:52 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/74] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 09:55:45 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 21|app: -1|req: -1/75] 192.168.5.202 () {36 vars in 569 bytes} [Wed May 22 10:09:14 2019] GET /page/factory/production/info => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (1 switches on core 0)
*** Starting uWSGI 2.0.18 (64bit) on [Tue Jun 25 02:45:09 2019] ***
compiled with version: 7.4.0 on 15 May 2019 04:49:44
os: Linux-4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018
nodename: c5d5ea87b38b
machine: x86_64
clock source: unix
detected number of CPU cores: 8
current working directory: /notebooks
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /notebooks
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:5000 fd 3
uwsgi socket 1 bound to UNIX address /notebooks/uwsgi.sock fd 4
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55d6fc282f10
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 364520 bytes (355 KB) for 5 cores
*** Operational MODE: preforking ***
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 7, cores: 1)
spawned uWSGI worker 2 (pid: 28, cores: 1)
spawned uWSGI worker 3 (pid: 29, cores: 1)
spawned uWSGI worker 4 (pid: 30, cores: 1)
spawned uWSGI worker 5 (pid: 31, cores: 1)
*** Starting uWSGI 2.0.18 (64bit) on [Tue Jun 25 07:16:45 2019] ***
compiled with version: 7.4.0 on 15 May 2019 04:49:44
os: Linux-4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018
nodename: 589fe076d0c4
machine: x86_64
clock source: unix
detected number of CPU cores: 8
current working directory: /notebooks
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /notebooks
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:5000 fd 3
uwsgi socket 1 bound to UNIX address /notebooks/uwsgi.sock fd 4
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55db66d4af10
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 364520 bytes (355 KB) for 5 cores
*** Operational MODE: preforking ***
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 7, cores: 1)
spawned uWSGI worker 2 (pid: 19, cores: 1)
spawned uWSGI worker 3 (pid: 20, cores: 1)
spawned uWSGI worker 4 (pid: 21, cores: 1)
spawned uWSGI worker 5 (pid: 22, cores: 1)
*** Starting uWSGI 2.0.18 (64bit) on [Tue Jun 25 09:04:42 2019] ***
compiled with version: 7.4.0 on 15 May 2019 04:49:44
os: Linux-4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018
nodename: 589fe076d0c4
machine: x86_64
clock source: unix
detected number of CPU cores: 8
current working directory: /notebooks
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /notebooks
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:5000 fd 3
uwsgi socket 1 bound to UNIX address /notebooks/uwsgi.sock fd 4
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x560ebaf41f10
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 364520 bytes (355 KB) for 5 cores
*** Operational MODE: preforking ***
unable to load configuration from from multiprocessing.semaphore_tracker import main;main(5)
Using TensorFlow backend.
人臉偵測cascade分類器載入完成
Facenet預測模型載入完成
SVM分類器載入完成
Traceback (most recent call last):
File "./run.py", line 33, in <module>
import views, models, resources
File "./resources.py", line 4, in <module>
import predict
File "./predict.py", line 53, in <module>
os.mkdir(name_path)
FileNotFoundError: [Errno 2] No such file or directory: '/notebooks/nas/Face/Allen'
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 7, cores: 1)
spawned uWSGI worker 2 (pid: 56, cores: 1)
spawned uWSGI worker 3 (pid: 57, cores: 1)
spawned uWSGI worker 4 (pid: 58, cores: 1)
spawned uWSGI worker 5 (pid: 59, cores: 1)
*** Starting uWSGI 2.0.18 (64bit) on [Tue Jun 25 09:14:48 2019] ***
compiled with version: 7.4.0 on 15 May 2019 04:49:44
os: Linux-4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018
nodename: 75475320ed5e
machine: x86_64
clock source: unix
detected number of CPU cores: 8
current working directory: /notebooks
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /notebooks
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:5000 fd 3
uwsgi socket 1 bound to UNIX address /notebooks/uwsgi.sock fd 4
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55bbd8b16f10
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 364520 bytes (355 KB) for 5 cores
*** Operational MODE: preforking ***
Traceback (most recent call last):
File "./run.py", line 33, in <module>
import views, models, resources
File "./resources.py", line 4, in <module>
import predict
File "./predict.py", line 6, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 7, cores: 1)
spawned uWSGI worker 2 (pid: 30, cores: 1)
spawned uWSGI worker 3 (pid: 31, cores: 1)
spawned uWSGI worker 4 (pid: 32, cores: 1)
spawned uWSGI worker 5 (pid: 33, cores: 1)
*** Starting uWSGI 2.0.18 (64bit) on [Thu Jun 27 00:58:46 2019] ***
compiled with version: 7.4.0 on 15 May 2019 04:49:44
os: Linux-4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018
nodename: 75475320ed5e
machine: x86_64
clock source: unix
detected number of CPU cores: 8
current working directory: /notebooks
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /notebooks
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:5000 fd 3
uwsgi socket 1 bound to UNIX address /notebooks/uwsgi.sock fd 4
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x564b37010f10
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 364520 bytes (355 KB) for 5 cores
*** Operational MODE: preforking ***
Using TensorFlow backend.
unable to load configuration from from multiprocessing.semaphore_tracker import main;main(5)
SVM分類器載入完成
WSGI app 0 (mountpoint='') ready in 31 seconds on interpreter 0x564b37010f10 pid: 7 (default app)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 7, cores: 1)
spawned uWSGI worker 2 (pid: 56, cores: 1)
spawned uWSGI worker 3 (pid: 57, cores: 1)
spawned uWSGI worker 4 (pid: 58, cores: 1)
spawned uWSGI worker 5 (pid: 59, cores: 1)
*** Starting uWSGI 2.0.18 (64bit) on [Thu Jun 27 01:04:54 2019] ***
compiled with version: 7.4.0 on 15 May 2019 04:49:44
os: Linux-4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018
nodename: 75475320ed5e
machine: x86_64
clock source: unix
detected number of CPU cores: 8
current working directory: /notebooks
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /notebooks
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:5000 fd 3
uwsgi socket 1 bound to UNIX address /notebooks/uwsgi.sock fd 4
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55a9fd6bdf10
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 364520 bytes (355 KB) for 5 cores
*** Operational MODE: preforking ***
Using TensorFlow backend.
unable to load configuration from from multiprocessing.semaphore_tracker import main;main(5)
SVM分類器載入完成
WSGI app 0 (mountpoint='') ready in 24 seconds on interpreter 0x55a9fd6bdf10 pid: 7 (default app)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 7, cores: 1)
spawned uWSGI worker 2 (pid: 56, cores: 1)
spawned uWSGI worker 3 (pid: 57, cores: 1)
spawned uWSGI worker 4 (pid: 58, cores: 1)
spawned uWSGI worker 5 (pid: 59, cores: 1)
*** Starting uWSGI 2.0.18 (64bit) on [Thu Jun 27 02:48:49 2019] ***
compiled with version: 7.4.0 on 15 May 2019 04:49:44
os: Linux-4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018
nodename: 75475320ed5e
machine: x86_64
clock source: unix
detected number of CPU cores: 8
current working directory: /notebooks
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /notebooks
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:5000 fd 3
uwsgi socket 1 bound to UNIX address /notebooks/uwsgi.sock fd 4
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x55c1ed30af10
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 364520 bytes (355 KB) for 5 cores
*** Operational MODE: preforking ***
Using TensorFlow backend.
unable to load configuration from from multiprocessing.semaphore_tracker import main;main(5)
SVM分類器載入完成
WSGI app 0 (mountpoint='') ready in 17 seconds on interpreter 0x55c1ed30af10 pid: 7 (default app)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 7, cores: 1)
spawned uWSGI worker 2 (pid: 71, cores: 1)
spawned uWSGI worker 3 (pid: 72, cores: 1)
spawned uWSGI worker 4 (pid: 73, cores: 1)
spawned uWSGI worker 5 (pid: 74, cores: 1)
import os as __os, datetime as __datetime, pytz as __pytz
import sys as __sys, codecs as __codecs
def write(source, tag, table, message):
now = __datetime.datetime.now(tz=__pytz.timezone('Asia/Taipei'))
now = str(int(now.strftime("%Y%m%d%H%M")) - 191100000000)
date = __os.path.join("log", now[0:3], now[3:5])
# Create log folder if it't exists.
if not __os.path.exists(date):
__os.makedirs(date)
# Record SQL operator per day.
with __codecs.open(__os.path.join(date, now[5:7] + '.log'), "a", "utf-8") as f:
f.write(u"[" + source + "][" + now[7:9] + ":" + now[9:11] + "][" + tag + "][" + table + "]:\n" + message + "\n")
# try:
# __sys.stdout = __codecs.getwriter("utf-8")(__sys.stdout.detach())
# except:
# tag = "ERROR"
print(u"[" + source + "][" + now[7:9] + ":" + now[9:11] + "][" + table + "]:" + tag)
from keras.models import load_model
model=load_model('Face-Clock/model/keras/facenet_keras.h5')
# model._make_predict_function()
print("Facenet預測模型載入完成")
\ No newline at end of file
# coding: utf-8
# In[1]:
import cv2
from sklearn.externals import joblib
from skimage.transform import resize
from sklearn.preprocessing import LabelEncoder
from keras.models import load_model
import numpy as np
import os
import facenet_predict
# In[2]:
# 載入Facenet預測模型
# model=model_from_json(open("Face-Clock/model/keras/facenet_model.json","r").read())
# model.load_weights("Face-Clock/model/keras/facenet_weights.h5")
# model=load_model('Face-Clock/model/keras/facenet_keras.h5')
# model._make_predict_function()
# print("Facenet預測模型載入完成")
# 載入人臉偵測cascade分類器
# global face_cascade
face_cascade = cv2.CascadeClassifier("Face-Clock/model/cv2/haarcascade_frontalface_alt2.xml")
print("人臉偵測cascade分類器載入完成")
# In[3]:
# 載入Facenet預測模型
# model=model_from_json(open("Face-Clock/model/keras/facenet_model.json","r").read())
# model.load_weights("Face-Clock/model/keras/facenet_weights.h5")
# global model
# model=load_model('Face-Clock/model/keras/facenet_keras.h5')
# model._make_predict_function()
# print("Facenet預測模型載入完成")
# model.summary()
# In[4]:
# 載入SVM分類器
clf=joblib.load('Face-Clock/model/20190624135811/20190624135811.pkl')
# 載入LabelEncoder
le=LabelEncoder()
le.classes_ =np.load('Face-Clock/model/20190624135811/classes.npy')
print("SVM分類器載入完成")
# 建立儲存影像位置
with open('Face-Clock/model/20190624135811/labels.txt') as f:
lines = f.readlines()
for i in range(len(lines)):
name=lines[i].split('\n')[0]
save_path=os.path.abspath('nas/Face')
name_path=os.path.join(save_path,name)
if(not os.path.isdir(name_path)):
os.mkdir(name_path)
os.mkdir(os.path.join(name_path,'login_'))
os.mkdir(os.path.join(name_path,'logout_'))
os.mkdir(os.path.join(name_path,'error_'))
print("建立儲存影像位置完成")
# In[5]:
# 影像預處理
# def prewhiten(x):
# if x.ndim == 4:
# axis = (1, 2, 3)
# size = x[0].size
# elif x.ndim == 3:
# axis = (0, 1, 2)
# size = x.size
# else:
# print(x.ndim)
# raise ValueError('Dimension should be 3 or 4')
# mean = np.mean(x, axis=axis, keepdims=True)
# std = np.std(x, axis=axis, keepdims=True)
# std_adj = np.maximum(std, 1.0/np.sqrt(size))
# y = (x - mean) / std_adj
# return y
# def l2_normalize(x, axis=-1, epsilon=1e-10):
# output = x / np.sqrt(np.maximum(np.sum(np.square(x), axis=axis, keepdims=True), epsilon))
# return output
# In[6]:
# 人臉偵測處理回傳結果矩陣
image_size=160
def face_cropped(img,faces, margin):
aligned_images = []
for f in faces:
(x, y, w, h) = f
cropped = img[y-margin//2:y+h+margin//2,x-margin//2:x+w+margin//2, :]
aligned = resize(cropped, (image_size, image_size), mode='reflect')
aligned_images.append(aligned)
return np.array(aligned_images)
# In[7]:
# 取得人臉Facenet預測之特徵值
# def calc_embs(faces, margin=10, batch_size=1):
# aligned_images = prewhiten(faces)
# pd = []
# for start in range(0, len(aligned_images), batch_size):
# pd.append(model.predict_on_batch(aligned_images[start:start+batch_size]))
# embs = l2_normalize(np.concatenate(pd))
# return embs
# In[11]:
# 人臉辨識推斷
def infer(le, clf, img):
faces = face_cascade.detectMultiScale(img,scaleFactor=1.1,minNeighbors=3)
if(len(faces)==0):
return '偵測不到人臉請重新調整'
embs = facenet_predict.calc_embs(face_cropped(img,faces,10))
# pred = le.inverse_transform(clf.predict(embs))
# pred=get_labels(le,clf,embs)
results,confidences=get_labelsNconfidence(le,clf,embs)
return [faces,results,confidences]
# Labels 解析
def get_labels(le,clf,embs):
socres=clf.predict_proba(embs)
results=[]
for s in socres:
if(s[s.argmax()]>0.5):
results.append(le.inverse_transform([s.argmax()])[0])
else:
results.append('Unknow')
return results
# Labels 解析回傳結果與分數
def get_labelsNconfidence(le,clf,embs):
socres=clf.predict_proba(embs)
results=[]
confidences=[]
for s in socres:
results.append(le.inverse_transform([s.argmax()])[0])
confidences.append(s[s.argmax()])
return results,confidences
def get_result(img_path):
img=cv2.imread(img_path)
global le
global clf
return infer(le, clf, img)
\ No newline at end of file
from run import app
from flask_restful import Resource, reqparse
from werkzeug import datastructures
import datetime
import time
import cv2
import pytz
import os
import facenet_predict
import face_cascade
import svm_classification
import train
from influxdb import InfluxDBClient
import pymysql
class Whois(Resource):
def __init__(self):
self.reqparse = reqparse.RequestParser()
self.reqparse.add_argument('file',type=datastructures.FileStorage, location='files',required=True,help="Please slecet a image which incloud car to upload.")
@staticmethod
def save(self):
save_time=time.time()
dt = datetime.datetime.now(pytz.timezone('Asia/Taipei'))
dt = dt.strftime('%Y_%m_%d_%H_%M_%S_%f')+'.jpg'
filepath = os.path.abspath(os.path.join(app.config['UPLOAD_FOLDER'], dt))
args =self.reqparse.parse_args()
args['file'].save(filepath)
return save_time,filepath
def get(self):
return "hello world"
def post(self):
save_time,img_path = self.save(self)
# print(img_path)
img=cv2.imread(img_path)
faces=face_cascade.get_face(img)
if(len(faces)!=2):
return {'error':faces}
embs=facenet_predict.calc_embs(faces[1])
result=svm_classification.result(embs)
return {'time':save_time,'face_location':str(faces[0]),'name':result[0],'confidence':result[1]}
# if(len(result)!=3):
# return {'error':result}
# return {'face':str(result[0]),'name':result[1],'confidence':result[2]}
# result=train.get_result(img_path)
# return {'message':str(result)}
class Upload_image(Resource):
def __init__(self):
self.reqparse = reqparse.RequestParser()
self.reqparse.add_argument('name',required=True,help="Please write down your name and we will save your image to folder of train")
self.reqparse.add_argument('file',type=datastructures.FileStorage, location='files',required=True,help="Please slecet a image which incloud car to upload.")
@staticmethod
def save(self):
dt = datetime.datetime.now(pytz.timezone('Asia/Taipei'))
dt = dt.strftime('%Y_%m_%d_%H_%M_%S_%f')+'.jpg'
args =self.reqparse.parse_args()
fileroot=os.path.abspath(os.path.join('./nas/Face/train',args['name']))
filepath = os.path.join(fileroot,dt)
if(not os.path.isdir(fileroot)):
os.mkdir(fileroot)
args['file'].save(filepath)
return args['name'],filepath
def post(self):
name,img_path=self.save(self)
img=cv2.imread(img_path)
faces=face_cascade.get_face(img)
if(len(faces)!=2):
return {'error':'偵測不到人臉 請重新上傳'}
else:
return {'message':name+'已新增訓練樣本'}
class Train(Resource):
def get(self):
train.go_train()
return {'message':'training is done'}
class Clock(Resource):
def __init__(self):
self.reqparse = reqparse.RequestParser()
self.reqparse.add_argument('name',required=True,help="Please write down your name")
self.reqparse.add_argument('time',required=True,help="Please write down save time")
self.reqparse.add_argument('log',required=True,help="Please write down your login or logout")
self.reqparse.add_argument('status',required=True,help="Please write down your status")
def post(self):
args =self.reqparse.parse_args()
save_time=args['time']
save_name=args['name']
save_log=args['log']
status=args['status']
if(status == 'error_'):
save_log=status
utc_time=datetime.datetime.utcfromtimestamp(float(save_time))
tzutc_8 = datetime.timezone(datetime.timedelta(hours=8))
local_dt = utc_time.astimezone(tzutc_8)
img_file = local_dt.strftime('%Y_%m_%d_%H_%M_%S_%f')+'.jpg'
img=cv2.imread(os.path.join('./tmp/upload',img_file))
cv2.imwrite(os.path.abspath(os.path.join('./nas/Face',save_name,save_log,img_file)),img)
# 建立資料庫連線
client=InfluxDBClient(host='192.168.0.6',port=8086,username='root',password='xMd2k5aK',database='rd')
json_body = [
{
"measurement": save_log,
"time": utc_time,
"fields": {
"name": save_name,
'snapshot':save_log+'/'+img_file+'.jpg'
}
}
]
client.write_points(json_body)
client.close()
return {'message':save_name+'打卡成功'}
class Insert_employee(Resource):
def __init__(self):
self.reqparse = reqparse.RequestParser()
self.reqparse.add_argument('name',required=True,help="Please write down your name")
self.reqparse.add_argument('engname',required=True,help="Please write down save time")
self.reqparse.add_argument('phone',required=True,help="Please write down your login or logout")
self.reqparse.add_argument('years',required=True,help="Please write down your status")
def post(self):
args=self.reqparse.parse_args()
name=args['name']
engname=args['engname']
phone=args['phone']
years=args['years']
db=pymysql.connect('192.168.0.5','root','xMd2k5aK','rd')
cursor = db.cursor()
# 資料庫查詢此類別最後一組id避免重複
sql="SELECT id FROM employee WHERE id LIKE 'RD{0}%'".format(years)
a=cursor.execute(sql)
if(a==0):
full_num='RD'+years+'00'
else:
result=cursor.fetchall()
num=int(max(result)[0].split(years)[1])+1
full_num='RD'+years+str(num)
sql="""INSERT INTO `employee` (`id`, `name`, `english_name`, `phone`) VALUES ('{0}', '{1}', '{2}', '{3}')""".format(full_num,name,engname,phone)
try:
# 执行SQL语句
cursor.execute(sql)
# 提交到数据库执行
db.commit()
except:
# 发生错误时回滚
db.rollback()
db.close()
return {'message':str(args)}
\ No newline at end of file
from flask import Flask
from flask_restful import Api
from flask_sqlalchemy import SQLAlchemy
from flask_jwt_extended import JWTManager
def warn(*args, **kwargs):
pass
import warnings
warnings.warn = warn
app = Flask(__name__)
api = Api(app)
import os
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///app.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SECRET_KEY'] = 'some-secret-string'
app.config['UPLOAD_FOLDER'] = 'tmp/upload'
os.environ["CUDA_VISIBLE_DEVICES"] = "2"
db = SQLAlchemy(app)
app.config['JWT_SECRET_KEY'] = 'jwt-secret-string'
jwt = JWTManager(app)
app.config['JWT_BLACKLIST_ENABLED'] = True
app.config['JWT_BLACKLIST_TOKEN_CHECKS'] = ['access', 'refresh']
@jwt.token_in_blacklist_loader
def check_if_token_in_blacklist(decrypted_token):
jti = decrypted_token['jti']
return models.RevokedTokenModel.is_jti_blacklisted(jti)
import views, models, resources
api.add_resource(resources.Whois,'/whois')
api.add_resource(resources.Upload_image,'/upload/image')
api.add_resource(resources.Train,'/train')
api.add_resource(resources.Clock,'/clock')
api.add_resource(resources.Insert_employee,'/insert')
@app.before_first_request
def create_tables():
db.create_all()
if __name__ == '__main__':
# print(('* Loading Keras model and Flask starting server...'
# 'please wait until server has fully started'))
# perload_model()
app.run()
# app.run(host='0.0.0.0', port=8000, debug=True)
\ No newline at end of file
from sklearn.externals import joblib
from sklearn.preprocessing import LabelEncoder
import numpy as np
import os
svm_path=os.path.abspath('./nas/Face/model/svm')
svm_version=max(os.listdir(svm_path))
print('svm version:',svm_version)
# 載入SVM分類器
clf=joblib.load(os.path.join(svm_path,svm_version,svm_version+'.pkl'))
# 載入LabelEncoder
le=LabelEncoder()
le.classes_ =np.load(os.path.join(svm_path,svm_version,'classes.npy'))
print("SVM分類器載入完成")
# Labels 解析回傳結果與分數
def get_labelsNconfidence(le,clf,embs):
socres=clf.predict_proba(embs)
results=[]
confidences=[]
for s in socres:
results.append(le.inverse_transform([s.argmax()])[0])
confidences.append(s[s.argmax()])
return results,confidences
def result(embs):
global le
global clf
return get_labelsNconfidence(le,clf,embs)
\ No newline at end of file
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import inception_resnet_v1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"from skimage.transform import resize\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"img=cv2.imread('nas/Face/test/test2.jpg')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"face_cascade = cv2.CascadeClassifier(\"Face-Clock/model/cv2/haarcascade_frontalface_alt2.xml\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"faces = face_cascade.detectMultiScale(img,scaleFactor=1.1,minNeighbors=3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# 人臉偵測處理回傳結果矩陣\n",
"image_size=160\n",
"def face_cropped(img,faces, margin): \n",
" aligned_images = []\n",
" for f in faces:\n",
" (x, y, w, h) = f\n",
" cropped = img[y-margin//2:y+h+margin//2,x-margin//2:x+w+margin//2, :]\n",
" aligned = resize(cropped, (image_size, image_size), mode='reflect')\n",
" aligned_images.append(aligned)\n",
" \n",
" return np.array(aligned_images)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"inception_resnet_v1.calc_embs(face_cropped(img,faces,10))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from facenet_predict import InceptionResNetV1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"model=InceptionResNetV1()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"model.predict()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"import numpy as np\n",
"from skimage.transform import resize\n",
"# 人臉偵測處理回傳結果矩陣\n",
"def load_and_align_images(filepaths, margin):\n",
" image_size=160\n",
" cascade_path = 'Face-Clock/model/cv2/haarcascade_frontalface_alt2.xml'\n",
" cascade = cv2.CascadeClassifier(cascade_path)\n",
" \n",
" aligned_images = []\n",
" for filepath in filepaths:\n",
" img = cv2.imread(filepath)\n",
"\n",
" faces = cascade.detectMultiScale(img,\n",
" scaleFactor=1.1,\n",
" minNeighbors=3)\n",
" if(len(faces)==0):\n",
" print('notthing')\n",
" continue\n",
" (x, y, w, h) = faces[0]\n",
" cropped = img[y-margin//2:y+h+margin//2,\n",
" x-margin//2:x+w+margin//2, :]\n",
" aligned = resize(cropped, (image_size, image_size), mode='reflect')\n",
" aligned_images.append(aligned)\n",
" \n",
" return np.array(aligned_images)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"# 影像預處理\n",
"def prewhiten(x):\n",
" if x.ndim == 4:\n",
" axis = (1, 2, 3)\n",
" size = x[0].size\n",
" elif x.ndim == 3:\n",
" axis = (0, 1, 2)\n",
" size = x.size\n",
" else:\n",
" print(x.ndim)\n",
" raise ValueError('Dimension should be 3 or 4')\n",
"\n",
" mean = np.mean(x, axis=axis, keepdims=True)\n",
" std = np.std(x, axis=axis, keepdims=True)\n",
" std_adj = np.maximum(std, 1.0/np.sqrt(size))\n",
" y = (x - mean) / std_adj\n",
" return y\n",
"\n",
"def l2_normalize(x, axis=-1, epsilon=1e-10):\n",
" output = x / np.sqrt(np.maximum(np.sum(np.square(x), axis=axis, keepdims=True), epsilon))\n",
" return output"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[[[2.28072937, 2.2952711 , 2.24835543],\n",
" [2.28166012, 2.2952711 , 2.25576097],\n",
" [2.28720416, 2.2952711 , 2.26717278],\n",
" ...,\n",
" [2.16184803, 2.01388323, 1.99201755],\n",
" [2.13191541, 1.98395061, 1.97747582],\n",
" [2.14645715, 1.99201755, 1.98554277]],\n",
"\n",
" [[2.38347681, 2.25389947, 2.20539164],\n",
" [2.38312587, 2.26693064, 2.21842281],\n",
" [2.3810355 , 2.28232153, 2.2338137 ],\n",
" ...,\n",
" [2.05103365, 2.05347496, 1.98554277],\n",
" [2.05103365, 2.05347496, 1.98554277],\n",
" [2.05591627, 2.04137454, 1.97344234]],\n",
"\n",
" [[2.41171113, 2.19937659, 2.16541049],\n",
" [2.42687314, 2.21012699, 2.17616089],\n",
" [2.42550985, 2.23869632, 2.20473023],\n",
" ...,\n",
" [2.06871658, 2.05347496, 1.98554277],\n",
" [2.08266457, 2.05347496, 1.98554277],\n",
" [2.08584889, 2.05506712, 1.97761182]],\n",
"\n",
" ...,\n",
"\n",
" [[1.94411673, 1.95950762, 1.95950762],\n",
" [1.93397334, 1.94936423, 1.94936423],\n",
" [1.92223779, 1.92368069, 1.92368069],\n",
" ...,\n",
" [1.96841045, 1.95157667, 1.93618578],\n",
" [1.98372173, 1.95157667, 1.94936423],\n",
" [2.00252581, 1.96855972, 1.96269194]],\n",
"\n",
" [[1.93459362, 1.93459362, 1.93459362],\n",
" [1.93912531, 1.93703494, 1.93703494],\n",
" [1.95378911, 1.93924738, 1.93924738],\n",
" ...,\n",
" [1.93703494, 1.93567165, 1.95157667],\n",
" [1.93912531, 1.9224932 , 1.95157667],\n",
" [1.96789831, 1.93947625, 1.96301568]],\n",
"\n",
" [[1.94910816, 1.91761057, 1.9385999 ],\n",
" [1.96115418, 1.92129311, 1.95525921],\n",
" [1.95841633, 1.91333496, 1.94730106],\n",
" ...,\n",
" [1.91700356, 1.91052878, 1.93300146],\n",
" [1.91113579, 1.904661 , 1.91761057],\n",
" [1.92565032, 1.90866728, 1.92811884]]]])"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"prewhiten(load_and_align_images(['nas/Face/train/Bruce/Bruce02.jpg'],10))"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import time\n",
"from datetime import datetime,timezone,timedelta"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"t=time.time()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"dt=datetime.utcfromtimestamp(t)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"tzutc_8 = timezone(timedelta(hours=8))\n",
"local_dt = dt.astimezone(tzutc_8)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"dt = local_dt.strftime('%Y_%m_%d_%H_%M_%S_%f')+'.jpg'"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"a='1561612926.4031167'"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"import pymysql"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [],
"source": [
"db=pymysql.connect('192.168.0.5','root','xMd2k5aK','rd')"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [],
"source": [
"cursor = db.cursor()"
]
},
{
"cell_type": "code",
"execution_count": 120,
"metadata": {},
"outputs": [],
"source": [
"sql=\"SELECT id FROM employee WHERE id LIKE 'RD{0}%'\".format('105')"
]
},
{
"cell_type": "code",
"execution_count": 124,
"metadata": {},
"outputs": [],
"source": [
"a=cursor.execute(sql)\n",
"if(a==0):\n"
]
},
{
"cell_type": "code",
"execution_count": 125,
"metadata": {},
"outputs": [],
"source": [
"b=cursor.fetchall()"
]
},
{
"cell_type": "code",
"execution_count": 126,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(('RD10501',), ('RD10502',), ('RD10503',))"
]
},
"execution_count": 126,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b"
]
},
{
"cell_type": "code",
"execution_count": 104,
"metadata": {},
"outputs": [],
"source": [
"sql=\"\"\"INSERT INTO `employee` (`id`, `name`, `english_name`, `phone`) VALUES ('{0}', '{1}', '{2}', '{3}')\"\"\".format('RD10506','test','test','09875464')"
]
},
{
"cell_type": "code",
"execution_count": 105,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 105,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cursor.execute(sql)"
]
},
{
"cell_type": "code",
"execution_count": 106,
"metadata": {},
"outputs": [],
"source": [
"db.commit()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
from functools import partial
from keras.models import Model
from keras.layers import Activation
from keras.layers import BatchNormalization
from keras.layers import Concatenate
from keras.layers import Conv2D
from keras.layers import Dense
from keras.layers import Dropout
from keras.layers import GlobalAveragePooling2D
from keras.layers import Input
from keras.layers import Lambda
from keras.layers import MaxPooling2D
from keras.layers import add
from keras import backend as K
K.set_image_dim_ordering('tf')
import tensorflow as tf
import os
import numpy as np
import cv2
from sklearn.svm import SVC
from sklearn.preprocessing import LabelEncoder
from skimage.transform import resize
from sklearn.externals import joblib
import time
def scaling(x, scale):
return x * scale
def conv2d_bn(x,
filters,
kernel_size,
strides=1,
padding='same',
activation='relu',
use_bias=False,
name=None):
x = Conv2D(filters,
kernel_size,
strides=strides,
padding=padding,
use_bias=use_bias,
name=name)(x)
if not use_bias:
bn_axis = 1 if K.image_data_format() == 'channels_first' else 3
bn_name = _generate_layer_name('BatchNorm', prefix=name)
x = BatchNormalization(axis=bn_axis, momentum=0.995, epsilon=0.001,
scale=False, name=bn_name)(x)
if activation is not None:
ac_name = _generate_layer_name('Activation', prefix=name)
x = Activation(activation, name=ac_name)(x)
return x
def _generate_layer_name(name, branch_idx=None, prefix=None):
if prefix is None:
return None
if branch_idx is None:
return '_'.join((prefix, name))
return '_'.join((prefix, 'Branch', str(branch_idx), name))
def _inception_resnet_block(x, scale, block_type, block_idx, activation='relu'):
channel_axis = 1 if K.image_data_format() == 'channels_first' else 3
if block_idx is None:
prefix = None
else:
prefix = '_'.join((block_type, str(block_idx)))
name_fmt = partial(_generate_layer_name, prefix=prefix)
if block_type == 'Block35':
branch_0 = conv2d_bn(x, 32, 1, name=name_fmt('Conv2d_1x1', 0))
branch_1 = conv2d_bn(x, 32, 1, name=name_fmt('Conv2d_0a_1x1', 1))
branch_1 = conv2d_bn(branch_1, 32, 3, name=name_fmt('Conv2d_0b_3x3', 1))
branch_2 = conv2d_bn(x, 32, 1, name=name_fmt('Conv2d_0a_1x1', 2))
branch_2 = conv2d_bn(branch_2, 32, 3, name=name_fmt('Conv2d_0b_3x3', 2))
branch_2 = conv2d_bn(branch_2, 32, 3, name=name_fmt('Conv2d_0c_3x3', 2))
branches = [branch_0, branch_1, branch_2]
elif block_type == 'Block17':
branch_0 = conv2d_bn(x, 128, 1, name=name_fmt('Conv2d_1x1', 0))
branch_1 = conv2d_bn(x, 128, 1, name=name_fmt('Conv2d_0a_1x1', 1))
branch_1 = conv2d_bn(branch_1, 128, [1, 7], name=name_fmt('Conv2d_0b_1x7', 1))
branch_1 = conv2d_bn(branch_1, 128, [7, 1], name=name_fmt('Conv2d_0c_7x1', 1))
branches = [branch_0, branch_1]
elif block_type == 'Block8':
branch_0 = conv2d_bn(x, 192, 1, name=name_fmt('Conv2d_1x1', 0))
branch_1 = conv2d_bn(x, 192, 1, name=name_fmt('Conv2d_0a_1x1', 1))
branch_1 = conv2d_bn(branch_1, 192, [1, 3], name=name_fmt('Conv2d_0b_1x3', 1))
branch_1 = conv2d_bn(branch_1, 192, [3, 1], name=name_fmt('Conv2d_0c_3x1', 1))
branches = [branch_0, branch_1]
else:
raise ValueError('Unknown Inception-ResNet block type. '
'Expects "Block35", "Block17" or "Block8", '
'but got: ' + str(block_type))
mixed = Concatenate(axis=channel_axis, name=name_fmt('Concatenate'))(branches)
up = conv2d_bn(mixed,
K.int_shape(x)[channel_axis],
1,
activation=None,
use_bias=True,
name=name_fmt('Conv2d_1x1'))
up = Lambda(scaling,
output_shape=K.int_shape(up)[1:],
arguments={'scale': scale})(up)
x = add([x, up])
if activation is not None:
x = Activation(activation, name=name_fmt('Activation'))(x)
return x
def InceptionResNetV1(input_shape=(160, 160, 3),
classes=128,
dropout_keep_prob=0.8,
weights_path=None):
inputs = Input(shape=input_shape)
x = conv2d_bn(inputs, 32, 3, strides=2, padding='valid', name='Conv2d_1a_3x3')
x = conv2d_bn(x, 32, 3, padding='valid', name='Conv2d_2a_3x3')
x = conv2d_bn(x, 64, 3, name='Conv2d_2b_3x3')
x = MaxPooling2D(3, strides=2, name='MaxPool_3a_3x3')(x)
x = conv2d_bn(x, 80, 1, padding='valid', name='Conv2d_3b_1x1')
x = conv2d_bn(x, 192, 3, padding='valid', name='Conv2d_4a_3x3')
x = conv2d_bn(x, 256, 3, strides=2, padding='valid', name='Conv2d_4b_3x3')
# 5x Block35 (Inception-ResNet-A block):
for block_idx in range(1, 6):
x = _inception_resnet_block(x,
scale=0.17,
block_type='Block35',
block_idx=block_idx)
# Mixed 6a (Reduction-A block):
channel_axis = 1 if K.image_data_format() == 'channels_first' else 3
name_fmt = partial(_generate_layer_name, prefix='Mixed_6a')
branch_0 = conv2d_bn(x,
384,
3,
strides=2,
padding='valid',
name=name_fmt('Conv2d_1a_3x3', 0))
branch_1 = conv2d_bn(x, 192, 1, name=name_fmt('Conv2d_0a_1x1', 1))
branch_1 = conv2d_bn(branch_1, 192, 3, name=name_fmt('Conv2d_0b_3x3', 1))
branch_1 = conv2d_bn(branch_1,
256,
3,
strides=2,
padding='valid',
name=name_fmt('Conv2d_1a_3x3', 1))
branch_pool = MaxPooling2D(3,
strides=2,
padding='valid',
name=name_fmt('MaxPool_1a_3x3', 2))(x)
branches = [branch_0, branch_1, branch_pool]
x = Concatenate(axis=channel_axis, name='Mixed_6a')(branches)
# 10x Block17 (Inception-ResNet-B block):
for block_idx in range(1, 11):
x = _inception_resnet_block(x,
scale=0.1,
block_type='Block17',
block_idx=block_idx)
# Mixed 7a (Reduction-B block): 8 x 8 x 2080
name_fmt = partial(_generate_layer_name, prefix='Mixed_7a')
branch_0 = conv2d_bn(x, 256, 1, name=name_fmt('Conv2d_0a_1x1', 0))
branch_0 = conv2d_bn(branch_0,
384,
3,
strides=2,
padding='valid',
name=name_fmt('Conv2d_1a_3x3', 0))
branch_1 = conv2d_bn(x, 256, 1, name=name_fmt('Conv2d_0a_1x1', 1))
branch_1 = conv2d_bn(branch_1,
256,
3,
strides=2,
padding='valid',
name=name_fmt('Conv2d_1a_3x3', 1))
branch_2 = conv2d_bn(x, 256, 1, name=name_fmt('Conv2d_0a_1x1', 2))
branch_2 = conv2d_bn(branch_2, 256, 3, name=name_fmt('Conv2d_0b_3x3', 2))
branch_2 = conv2d_bn(branch_2,
256,
3,
strides=2,
padding='valid',
name=name_fmt('Conv2d_1a_3x3', 2))
branch_pool = MaxPooling2D(3,
strides=2,
padding='valid',
name=name_fmt('MaxPool_1a_3x3', 3))(x)
branches = [branch_0, branch_1, branch_2, branch_pool]
x = Concatenate(axis=channel_axis, name='Mixed_7a')(branches)
# 5x Block8 (Inception-ResNet-C block):
for block_idx in range(1, 6):
x = _inception_resnet_block(x,
scale=0.2,
block_type='Block8',
block_idx=block_idx)
x = _inception_resnet_block(x,
scale=1.,
activation=None,
block_type='Block8',
block_idx=6)
# Classification block
x = GlobalAveragePooling2D(name='AvgPool')(x)
x = Dropout(1.0 - dropout_keep_prob, name='Dropout')(x)
# Bottleneck
x = Dense(classes, use_bias=False, name='Bottleneck')(x)
bn_name = _generate_layer_name('BatchNorm', prefix='Bottleneck')
x = BatchNormalization(momentum=0.995, epsilon=0.001, scale=False,
name=bn_name)(x)
# Create model
model = Model(inputs, x, name='inception_resnet_v1')
if weights_path is not None:
model.load_weights(weights_path)
return model
model = InceptionResNetV1()
def load_model():
global model
model.load_weights(os.path.abspath('./Face-Clock/model/keras/weights/facenet_keras_weights.h5'))
global graph
graph = tf.get_default_graph()
load_model()
# 影像預處理
def prewhiten(x):
if x.ndim == 4:
axis = (1, 2, 3)
size = x[0].size
elif x.ndim == 3:
axis = (0, 1, 2)
size = x.size
else:
print(x.ndim)
raise ValueError('Dimension should be 3 or 4')
mean = np.mean(x, axis=axis, keepdims=True)
std = np.std(x, axis=axis, keepdims=True)
std_adj = np.maximum(std, 1.0/np.sqrt(size))
y = (x - mean) / std_adj
return y
def l2_normalize(x, axis=-1, epsilon=1e-10):
output = x / np.sqrt(np.maximum(np.sum(np.square(x), axis=axis, keepdims=True), epsilon))
return output
# 人臉偵測處理回傳結果矩陣
def load_and_align_images(filepaths, margin):
image_size=160
cascade_path = 'Face-Clock/model/cv2/haarcascade_frontalface_alt2.xml'
cascade = cv2.CascadeClassifier(cascade_path)
aligned_images = []
for filepath in filepaths:
img = cv2.imread(filepath)
faces = cascade.detectMultiScale(img,
scaleFactor=1.1,
minNeighbors=3)
if(len(faces)==0):
continue
(x, y, w, h) = faces[0]
cropped = img[y-margin//2:y+h+margin//2,
x-margin//2:x+w+margin//2, :]
aligned = resize(cropped, (image_size, image_size), mode='reflect')
aligned_images.append(aligned)
return np.array(aligned_images)
# 取得人臉Facenet預測之特徵值
def calc_embs(filepaths, margin=10, batch_size=1):
aligned_images = prewhiten(load_and_align_images(filepaths, margin))
pd = []
for start in range(0, len(aligned_images), batch_size):
with graph.as_default():
pd.append(model.predict_on_batch(aligned_images[start:start+batch_size]))
embs = l2_normalize(np.concatenate(pd))
return embs
# 人臉辨識訓練主程序
def train(dir_basepath, names, max_num_img=10):
print('starting train')
labels = []
embs = []
for name in names:
dirpath = os.path.abspath(os.path.join(dir_basepath,name))
filepaths = [os.path.join(dirpath, f) for f in os.listdir(dirpath)][:max_num_img]
embs_ = calc_embs(filepaths)
labels.extend([name] * len(embs_))
embs.append(embs_)
embs = np.concatenate(embs)
le = LabelEncoder().fit(labels)
y = le.transform(labels)
clf = SVC(kernel='linear', probability=True).fit(embs, y)
return le, clf
def go_train():
# 訓練圖片路徑
image_dir_basepath="nas/Face/train"
names=[]
for f in os.listdir(os.path.abspath(image_dir_basepath)):
if(os.path.isdir(os.path.join(os.path.abspath(image_dir_basepath),f))):
names.append(f)
print(names)
le, clf = train(image_dir_basepath, names)
# 模型保存SVM與laberencoder
model_name=time.strftime("%Y%m%d%H%M%S", time.localtime())
full_path=os.path.join(os.path.abspath("nas/Face/model/svm"),model_name)
if(not os.path.exists(full_path)):
os.mkdir(full_path)
else:
print('is exist')
joblib.dump(clf,os.path.join(full_path,model_name+'.pkl'))
np.save(os.path.join(full_path,'classes.npy'),le.classes_)
# 寫入所有classes以便查閱
f=open(os.path.join(full_path,'labels.txt'),'w')
for label in le.classes_:
f.write(label+'\n')
f.close()
\ No newline at end of file
[uwsgi]
module = run:app
http-socket = 0.0.0.0:5000
processes = 5
chdir = /notebooks
socket = /notebooks/uwsgi.sock
logto = /notebooks/log/uwsgi.log
chmod-socket = 006
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment