else: OD_MODEL_NAME=model OD_MODEL_PATH='models/'+model+'/{}' if optimized: USE_OPTIMIZED=True else: USE_OPTIMIZED=False if single_class: NUM_CLASSES=1 else: NUM_CLASSES=90 return TestConfig() # Read sequentail Models or Gather all Models from models/ config = Config() if config.SEQ_MODELS: models = config.SEQ_MODELS else: for root, dirs, files in os.walk(MODELS_DIR): if root.count(os.sep) - MODELS_DIR.count(os.sep) == 0: for idx,model in enumerate(dirs): models=[] models.append(dirs) models = np.squeeze(models) models.sort() print("> start testing following sequention of models: \n{}".format(models)) for mod in models: print("> testing model: {}".format(mod)) # conditionals
def main(): model_type = 'dl' input_type = 'image' config = Config(model_type) model = DeepLabModel(config).prepare_model(input_type) model.run()
USE_OPTIMIZED = True else: USE_OPTIMIZED = False if single_class: NUM_CLASSES = 1 else: NUM_CLASSES = 90 def __init__(self): super(TestConfig, self).__init__(type) return TestConfig() # Read sequentail Models or Gather all Models from models/ config = Config('od') if config.SEQ_MODELS: model_names = config.SEQ_MODELS else: model_names = get_model_list(MODELS_DIR) # Sequential testing for model_name in model_names: print("> testing model: {}".format(model_name)) # conditionals optimized = False single_class = False # Test Model if 'hands' in model_name or 'person' in model_name: single_class = True if 'deeplab' in model_name:
else: masks = None # reformat detection num = int(num) boxes = np.squeeze(boxes) classes = np.squeeze(classes).astype(np.uint8) scores = np.squeeze(scores) # Visualization vis = vis_detection(frame, boxes, classes, scores, masks, category_index, timer.get_fps(), config.VISUALIZE, config.DET_INTERVAL, config.DET_TH, config.MAX_FRAMES, None, config.OD_MODEL_NAME + config._OPT) if not vis: break cv2.destroyAllWindows() timer.stop() if __name__ == '__main__': config = Config() config.display() model = Model('od', config.OD_MODEL_NAME, config.OD_MODEL_PATH, config.LABEL_PATH, config.NUM_CLASSES, config.SPLIT_MODEL, config.SSD_SHAPE).prepare_od_model() detection(model, config)
def main(): config = Config() model = Model('od', config.OD_MODEL_NAME, config.OD_MODEL_PATH, config.LABEL_PATH, config.NUM_CLASSES, config.SPLIT_MODEL, config.SSD_SHAPE).prepare_od_model() detection(model, config)
def main(): model_type = 'od' input_type = 'image' config = Config(model_type) model = ObjectDetectionModel(config).prepare_model(input_type) model.run()
if 'detection_masks' in output_dict: masks = output_dict['detection_masks'][0] else: masks = None # reformat detection num = int(num) boxes = np.squeeze(boxes) classes = np.squeeze(classes).astype(np.uint8) scores = np.squeeze(scores) # Visualization vis = visualize_objectdetection(frame,boxes,classes,scores,masks,category_index,timer.get_frame(), config.MAX_FRAMES,timer.get_fps(),config.PRINT_INTERVAL,config.PRINT_TH, config.OD_DISPLAY_NAME,config.VISUALIZE,config.VIS_FPS,config.DISCO_MOE,config.ALPHA) if not vis: break if config.SAVE_RESULT: cv2.imwrite('{}/{}_{}.jpg'.format(config.RESULT_PATH,timer.get_frame(),config.OD_DISPLAY_NAME),frame) cv2.destroyAllWindows() timer.stop() if __name__ == '__main__': config = Config() config.display() model = Model('od', config.OD_MODEL_NAME, config.OD_MODEL_PATH, config.LABEL_PATH, config.NUM_CLASSES, config.SPLIT_MODEL, config.SSD_SHAPE).prepare_od_model() detection(model,config)
class TestConfig(Config): LIMIT_IMAGES = 100 SPLIT_MODEL = False WRITE_TIMELINE = True if type is 'DL': DL_MODEL_PATH = model + '/{}' else: OD_MODEL_PATH = model + '/{}' if optimized: USE_OPTIMIZED = True return TestConfig() # Read sequentail Models or Gather all Models from models/ CONFIG = Config() if CONFIG.SEQ_MODELS: models = CONFIG.SEQ_MODELS else: MODELS_DIR = os.path.join(os.getcwd(), 'models') for root, dirs, files in os.walk(MODELS_DIR): if root.count(os.sep) - MODELS_DIR.count(os.sep) == 0: for idx, model in enumerate(dirs): models = [] models.append(dirs) models = np.squeeze(models) models.sort() print("> start testing following sequention of models: \n{}".format(models)) for mod in models: print("> testing model: {}".format(mod)) MODEL_DIR = os.path.join(os.getcwd(), 'models', mod)
# -*- coding: utf-8 -*- import tensorflow as tf import yaml import os import sys from rod.config import Config ## RUN THIS SCRIPT FROM THE ROOT DIR (NOT FROM /SCRIPTS) MODEL_TYPE = 'od' # Change to 'OD' or 'DL' NODE_NAMES = ['Momentum', 'Optimizer', 'BatchNorm', 'Loss'] NODE_OPS = ['Placeholder', 'Identity', 'CheckNumerics', 'BatchNorm'] ## Don't Change ## config = Config(MODEL_TYPE) MODEL_PATH = config.MODEL_PATH print("> exploring Model: {}".format(MODEL_PATH)) gf = tf.GraphDef() gf.ParseFromString(open(MODEL_PATH, 'rb').read()) print('>Looking for node Names:') for NAME in NODE_NAMES: print(NAME) print([n.name + '=>' + n.op for n in gf.node if NAME in n.name]) print('>Looking for node Ops:') for OP in NODE_OPS: print(OP)