示例#1
0
    def watch_for_retraining_facenet(self):
        """"""
        # Read previous_item_count
        prev_count = db.get_prev_count_encode()

        # Get count item in DB 
        curr_count = db.get_curr_count_encode()

        if curr_count < prev_count:
            print("WARNING ! current count is smaller than previous count ! Please reset previous count")

        # Check if percent of change is larger than threshold
        change_percent = abs((curr_count - prev_count)/prev_count) * 100
        
        if change_percent > int(self.threshold):
            # Call retrain
            facenet = FacenetEngine()
            facenet.train()

            # Update previous item count
            db.update_prev_count_encode(curr_count)
            print("Previous count updated !")
示例#2
0
import sys

# 関連外部ライブラリ
from flask import Blueprint
from flask_uploads import UploadSet, DATA, DOCUMENTS
from flask import jsonify, request

# 内部ライブラリ
sys.path.insert(0,
                os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from engine.facenet.facenet_engine import FacenetEngine
from database.db_utilities import DBUtility
from watcher.watcher import Watcher

# Instance generation
facenet = FacenetEngine()
db_util = DBUtility()
watcher = Watcher()

uploads = Blueprint('uploads', __name__)
files = UploadSet('files', DATA + DOCUMENTS)

SAVING_IMAGE_FOLDER_NAME = "images"

# Debug mode
DEBUG_MODE = True


@uploads.route("/api/uploads", methods=['POST'])
def upload_binary():
    """