# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import os import sys sys.path.append('.') base_dir = sys.argv[1] #from ikalog.utils import WeaponRecoginizer from ikalog.utils.neuralnet.weapon import WeaponClassifier #weapons = WeaponRecoginizer() weapons = WeaponClassifier() weapons.load_model_from_file() #weapons.knn_train() weapons.test_samples_from_directory(base_dir) weapons.dump_test_results_html(short=True)
# from http.server import HTTPServer, SimpleHTTPRequestHandler import json import logging import time import ikalog.constants from ikalog.utils import * from ikalog.utils.character_recoginizer import DeadlyWeaponRecoginizer from ikalog.utils.neuralnet.weapon import WeaponClassifier import cv2 import numpy as np import umsgpack weapons = WeaponClassifier() weapons.load_model_from_file() abilities = GearPowerRecoginizer() abilities.load_model_from_file() abilities.knn_train() class APIServer(object): def _decode_deadly_weapons_image(self, payload): h = payload['sample_height'] w = payload['sample_width'] img_bytes = payload['samples'] samples1 = cv2.imdecode(np.fromstring(img_bytes, dtype='uint8'), 1) num_samples = int(samples1.shape[0] / h)