Пример #1
0
from datasets.data_manager import DataManager
from utils.boxes import create_prior_boxes
from utils.preprocessing import load_image
from utils.inference import plot_box_data
from utils.inference import get_colors
from utils.boxes import assign_prior_boxes
from utils.boxes import to_point_form
from utils.boxes import unregress_boxes
from utils.generator import ImageGenerator
import matplotlib.pyplot as plt

# data manager
# ------------------------------------------------------------------
split = 'train'
dataset_name = 'VOC2012'
dataset_manager = DataManager(dataset_name, split)
ground_truth_data = dataset_manager.load_data()
class_names = dataset_manager.class_names
print('Found:', len(ground_truth_data), 'images')
print('Class names: \n', class_names)

class_names = ['background', 'diningtable', 'chair']
dataset_manager = DataManager(dataset_name, split, class_names)
ground_truth_data = dataset_manager.load_data()
class_names = dataset_manager.class_names
print('Found:', len(ground_truth_data), 'images')
print('Class names: \n', class_names)

# prior boxes
# ------------------------------------------------------------------
# model = SSD300()
Пример #2
0
from utils.pytorch_multibox_loss import MultiBoxLoss as MultiboxLossTorch
from utils.boxes import create_prior_boxes, to_point_form
import torch
from torch.autograd import Variable
import numpy as np
from utils.pytorch_layers import PriorBox
from utils.pytorch_parameters import v2

# parameters
batch_size = 5
num_classes = 21
negative_positive_ratio = 3
prior_boxes = to_point_form(create_prior_boxes())

# loading training data
data_manager = DataManager('VOC2012', 'train')
train_data = data_manager.load_data()
arg_to_class = data_manager.arg_to_class

# generating output
generator = DataGenerator(train_data, prior_boxes, batch_size)
data = generator.flow('train')
output_1 = next(data)[1]['predictions']
output_2 = next(data)[1]['predictions']

multibox_loss = MultiboxLoss(num_classes, negative_positive_ratio, batch_size)

output_1 = K.variable(output_1)
output_2 = K.variable(output_2)
loss = multibox_loss.compute_loss(output_1, output_2)
session = K.get_session()
Пример #3
0
from datasets.data_manager import DataManager
from utils.boxes import create_prior_boxes
from utils.boxes import to_point_form
from utils.generator import ImageGenerator
from models.experimental_loss import MultiboxLoss
import keras.backend as K

# parameters
dataset_name = 'VOC2012'
batch_size = 5
num_classes = 21
negative_positive_ratio = 3
prior_boxes = to_point_form(create_prior_boxes())

# loading training data
data_manager = DataManager(dataset_name, 'train')
train_data = data_manager.load_data()
arg_to_class = data_manager.arg_to_class
# loading validation data
val_data = DataManager(dataset_name, 'val').load_data()

# generating output
data = ImageGenerator(train_data, val_data, prior_boxes, batch_size)
generator = data.flow('train')
output_1 = next(generator)[1]['predictions']
output_2 = next(generator)[1]['predictions']

multibox_loss = MultiboxLoss(num_classes, negative_positive_ratio, batch_size)

output_1 = K.variable(output_1)
output_2 = K.variable(output_2)