def __init__(self): self.anchors_path = './model_data/yolo_anchors.txt' self.classes_path = './model_data/coco_classes.txt' self.class_names = read_classes(self.classes_path) self.anchors = read_anchors(self.anchors_path) self.threshold = threshold self.ignore_thresh = ignore_thresh self.INPUT_SIZE = (Input_shape, Input_shape ) # fixed size or (None, None) self.is_fixed_size = self.INPUT_SIZE != (None, None)
def __init__(self): self.anchors_path = anchors_path self.COCO = False self.trainable = True # self.args = self.argument() if args.COCO: print("-----------COCO-----------") self.COCO = True self.trainable = False self.class_names = read_classes(project_path + '/data/coco_classes.txt') else: print("----------{}-----------".format(dataset_name)) self.class_names = read_classes(dataset_class_file) self.anchors = read_anchors(self.anchors_path) self.threshold = threshold # threshold self.ignore_thresh = ignore_thresh self.INPUT_SIZE = (Input_shape, Input_shape ) # fixed size or (None, None) self.is_fixed_size = self.INPUT_SIZE != (None, None) # LOADING SESSION... self.boxes, self.scores, self.classes, self.sess = self.load()
def __init__(self): self.anchors_path = path + '/model/yolo_anchors.txt' self.COCO = False self.trainable = True args1 = sys.argv[2] if args1 == 'COCO': print("-----------COCO-----------") self.COCO = True self.classes_path = path + '/model/coco_classes.txt' self.trainable = False elif args1 == 'VOC': print("-----------VOC------------") self.classes_path = path + '/model/voc_classes.txt' elif args1 == 'boat': print("-----------boat-----------") self.classes_path = path + '/model/boat_classes.txt' # args = self.argument() # if args.COCO: # print("-----------COCO-----------") # self.COCO = True # self.classes_path = self.PATH + '/model/coco_classes.txt' # self.trainable = False # elif args.VOC: # print("-----------VOC------------") # self.classes_path = self.PATH + '/model/voc_classes.txt' # elif args.boat: # print("-----------boat-----------") # self.classes_path = self.PATH + '/model/boat_classes.txt' self.class_names = read_classes(self.classes_path) self.anchors = read_anchors(self.anchors_path) self.threshold = 0.5 # threshold self.ignore_thresh = ignore_thresh self.INPUT_SIZE = (Input_shape, Input_shape ) # fixed size or (None, None) self.is_fixed_size = self.INPUT_SIZE != (None, None) # LOADING SESSION... self.boxes, self.scores, self.classes, self.sess = self.load()
from utils.yolo_utils import get_training_data, read_anchors, read_classes, get_dac_batch_data from PIL import ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True import argparse import numpy as np import tensorflow as tf import time import os os.environ["CUDA_VISIBLE_DEVICES"] = visible_GPU np.random.seed(101) # PATH = path + '/yolo3' classes_data = read_classes(dataset_class_file) anchors = read_anchors(anchors_path) data_path_train = 'Do_not_use_for_now' data_path_valid = 'Do_not_use_for_now' data_path_test = 'Do_not_use_for_now' input_shape = (Input_shape, Input_shape) # multiple of 32 ######################################################################################################################## """ # Clear the current graph in each run, to avoid variable duplication # tf.reset_default_graph() """ print("Starting 1st session...") # Explicitly create a Graph object graph = tf.Graph()
# Add argument def argument(): parser = argparse.ArgumentParser(description='COCO or VOC or boat') parser.add_argument('--COCO', action='store_true', help='COCO flag') parser.add_argument('--VOC', action='store_true', help='VOC flag') parser.add_argument('--boat', action='store_true', help='boat flag') args = parser.parse_args() return args # Get Data ############################################################################################################# PATH = path classes_paths = PATH + '/model/classes.txt' classes_data = read_classes(classes_paths) anchors_paths = PATH + '/model/yolo_anchors.txt' anchors = read_anchors(anchors_paths) annotation_path_train = PATH + '/model/train.txt' annotation_path_valid = PATH + '/model/valid.txt' annotation_path_test = PATH + '/model/test.txt' data_path_train = PATH + '/model/train.npz' data_path_valid = PATH + '/model/valid.npz' data_path_test = PATH + '/model/test.npz' VOC = False args = argument() if args.VOC == True: VOC = True classes_paths = PATH + '/model/classes.txt'
colors = generate_colors(class_names) image = draw_boxes(image, out_scores, out_boxes, out_classes, class_names, colors) return image if __name__ == "__main__": sess = K.get_session() yolo_model = load_model("model_data/tiny-yolo.h5") #yolo_model.summary() class_names = read_classes("model_data/yolo_coco_classes.txt") anchors = read_anchors("model_data/yolo_anchors.txt") ''' # image detection image_file = "dog.jpg" image_path = "images/" image_shape = np.float32(cv2.imread(image_path + image_file).shape[:2]) yolo_outputs = yolo_head(yolo_model.output, anchors, len(class_names)) scores, boxes, classes = yolo_eval(yolo_outputs, image_shape=image_shape) out_scores, out_boxes, out_classes = image_detection(sess, image_path, image_file) ''' # video detection camera = cv2.VideoCapture(0)