def show_prediction(data_index):
    with open("../data/data_detect_local_evaluate_100.json") as json_file:
        data = json.load(json_file)

    if (data_index not in data):
        print("Index {} out of range".format(data_index))
        return

    yolo = Yolo()
    yolo.load_weights("./weights/yolo")

    img_path = "../pictures/pictures_detect_local_evaluate_100/{}.png".format(
        data_index)
    img = get_img(img_path)
    preds = yolo(img)
    boxes = get_boxes(preds)
    show(data_index, img_path, boxes)
Exemple #2
0
def train():
    yolo = Yolo()
    yolo.load_weights("./weights/yolo")

    opt = Adam(learning_rate=5e-5)
    with open("../data/data_detect_local_train.json") as json_file:
        data = json.load(json_file)
    data_index = 0
    while str(data_index) in data:
        img = get_img("../pictures/pictures_detect_local_train/{}.png".format(
            data_index))
        true_labels, true_boxes, true_preds = get_localization_data(
            data[str(data_index)])

        def get_loss():
            preds = yolo(img)
            return calculate_loss(preds, true_labels, true_boxes, true_preds)

        opt.minimize(get_loss, [yolo.trainable_weights])

        if (data_index % 100 == 99):
            yolo.save_weights("./weights/yolo")
        data_index += 1
Exemple #3
0
images = args.images
batch_size = args.batch_size
nms_thresh = args.nms_thresh
confidence = args.confidence

CUDA = torch.cuda.is_available()
start = 0
num_classes = 80

# Load the classes
classes = load_classes("data/coco.names")

# Set up the neural network and load weights
print("Loading network.....")
model = Yolo(args.cfgfile)
model.load_weights(args.weightsfile)
print("Network successfully loaded")

# get the input dimension (we assume square images)
inp_dim = int(model.net_info["height"])
assert inp_dim % 32 == 0
assert inp_dim > 32

#If there's a GPU availible, put the model on GPU
if CUDA:
    model.cuda()

#Set the model in evaluation mode
model.eval()

read_dir = time.time()