Exemplo n.º 1
0
def main():
    with K.get_session():
        """ Used for testing'
        """

        train_name = 'with_bridge'
        use_bridge = True

        dataset = ClopemaLoader()
        m = SimpleNet(dataset.image_shape(), dataset.n_garment_cats(),
                      dataset.n_landmark_cats(), use_bridge)
        display = Display(dataset, m.bb_size)

        data = dataset.fetch_data('val')
        data_x, data_y = data

        predictions = m.predict_combined(data_x, train_name)
        pred = m.loader.as_output(tuple(predictions))
        gt_loss = m.loader.as_input(tuple(data))

        display.show_landmark_stats(dataset.landmark_names, predictions,
                                    gt_loss)
        display.show_garment_stats(pred, data_y)

        display.history_charts(load_losses(train_name))
        display.show_multiple_results(
            data_x,
            pred,
            annotations=data_y,
            rpn_ground_truths=m.get_rpn_ground_truths(data))
Exemplo n.º 2
0
def main():
    with K.get_session():
        """ Used for testing'
        """
        dataset = ClopemaLoader()

        m = SimpleNet(dataset.image_shape(), dataset.n_garment_cats(),
                      dataset.n_landmark_cats(), False)
        display = Display(dataset, m.bb_size)

        train_data, val_data = dataset.fetch_multiple_data(['train', 'val'])
        # train_data = augment(train_data)

        results = m.train_global('global', train_data, val_data, n_epochs=40)

        display.history_charts(results[0])
Exemplo n.º 3
0
def main():
    with K.get_session():
        """ Used for testing'
        """

        dataset = ClopemaLoader()
        plot = Display(dataset)

        m = TreeNet((224, 224, 3), dataset.n_garment_cats(),
                    dataset.n_landmark_cats())

        train_data, val_data = dataset.fetch_multiple_data(['train', 'val'])
        val_data = (filter_by_n_landmarks(filter_class(val_data, 0)))

        # plot.show_results(val_data[0], predictions=m.load_losses(val_data), annotations=val_data[1])
        train_data = augment(filter_by_n_landmarks(filter_class(train_data,
                                                                0)))

        results = m.train_roi_pants('pants_overfit_again_night_1',
                                    train_data,
                                    val_data,
                                    n_epochs=10)

        plot.history_charts(results[0])
        plot.show_results(val_data[0],
                          predictions=results[1],
                          annotations=val_data[1])
Exemplo n.º 4
0
def main():
    with K.get_session():
        """ Used for testing'
        """
        dataset = ClopemaLoader()
        m = TridNet((224, 224, 3), dataset.n_garment_cats(),
                    dataset.n_landmark_cats())
        m.build(True)
        m.compile()
        m.load_weights(m.landmark_detector, 'train_roi')
        data = dataset.fetch_data('val')
        plot = Display(dataset)

        # print(m[0].shape)
        pred = m.predict_rois(data[0])
        ground_truths = m.get_rpn_ground_truths(data)
        for i in range(15):
            slc = slice(i * 6, (i + 1) * 6)
            plot.show_results(data[0][slc],
                              pred[slc],
                              annotations=data[1][slc],
                              ground_truths=ground_truths[slc])
            return
Exemplo n.º 5
0
def main():
    with K.get_session():
        """ Used for testing'
        """
        dataset = ClopemaLoader()
        m = SimpleNet(dataset.image_shape(), dataset.n_garment_cats(), dataset.n_landmark_cats())
        display = Display(dataset, m.bb_size)

        data = dataset.fetch_data('val')

        predictions = m.predict_landmarks(data[0], 'landmarks_with_spacial_constraint', ground_truths=data)
        pred = m.loader.as_output(tuple(predictions) + (None, None))
        gt_loss = m.loader.as_input(tuple(data))

        display.show_landmark_stats(dataset.landmark_names, predictions, gt_loss)

        display.history_charts(load_losses('landmarks_with_spacial_constraint'))
        display.show_multiple_results(data[0], pred,
                                      annotations=data[1],
                                      rpn_ground_truths=m.get_rpn_ground_truths(data))
Exemplo n.º 6
0
def main():
    with K.get_session():
        """ Used for testing'
        """
        dataset = ClopemaLoader()

        m = SimpleNet(dataset.image_shape(), dataset.n_garment_cats(),
                      dataset.n_landmark_cats(), False)
        display = Display(dataset, m.bb_size)

        data = dataset.fetch_data('val')
        data_x, data_y = data

        predictions = m.predict_global(data_x, 'global')
        pred = m.loader.as_output((None, None) + tuple(predictions))

        display.show_garment_stats(pred, data_y)

        display.history_charts(load_losses('global'))
        display.show_multiple_results(data_x, pred, data_y)
Exemplo n.º 7
0
def main():
    with k.get_session():
        """ Used for testing'
        """
        dataset = ClopemaLoader()

        m = SimpleNet(dataset.image_shape(), dataset.n_garment_cats(),
                      dataset.n_landmark_cats(), False)
        plot = Display(dataset, m.bb_size)

        train_data, val_data = dataset.fetch_multiple_data(['train', 'val'])
        # train_data = augment(train_data)
        # print(train_data[0].shape)

        ground_truths = m.get_rpn_ground_truths(val_data)

        results = m.train_landmarks('landmarks_with_spacial_constraint',
                                    train_data,
                                    val_data,
                                    n_epochs=40)
Exemplo n.º 8
0
def main():
    with K.get_session():
        """ Used for testing'
        """
        dataset = ClopemaLoader()
        m = TridNet((224, 224, 3), dataset.n_garment_cats(),
                    dataset.n_landmark_cats())
        display = Display(dataset)

        data = dataset.fetch_data('train')
        pred = m.predict_rpns(data[0], 'train_rpn')
        display.history_charts(load_losses('train_rpn'))
        display.show_multiple_results(
            data[0],
            pred,
            annotations=data[1],
            rpn_ground_truths=m.get_rpn_ground_truths(data))
Exemplo n.º 9
0
def main():
    with K.get_session():
        """ Used for testing'
        """

        dataset = ClopemaLoader()
        plot = Display(dataset)

        m = TridNet((224, 224, 3), dataset.n_garment_cats(),
                    dataset.n_landmark_cats())

        train_data, val_data = dataset.fetch_multiple_data(['train', 'val'])

        results = m.train_roi('train_roi', train_data, val_data, n_epochs=10)

        plot.history_charts(results[0])
        plot.show_results(val_data[0],
                          results[1],
                          val_data[1],
                          ground_truths=results[2])
Exemplo n.º 10
0
from glld.modules.trid_net import TridNet
from glld.datasets.clopema import ClopemaLoader
from glld.util.display import Display
from keras import backend as K
from skimage.transform import resize, rotate
from skimage.data import imread
import numpy as np

with K.get_session():
    dataset = ClopemaLoader()
    resolution = (352, 288)
    ratio = (352 / 224, 288 / 224)
    m = TridNet((224, 224, 3), dataset.n_garment_cats(),
                dataset.n_landmark_cats())
    data = dataset.fetch_data('val')
    plot = Display(dataset)

    # this is where one sets how long the script
    # sleeps for, between frames.sleeptime__in_seconds = 0.05
    # initialise the display window
    screen = pygame.display.set_mode(list(resolution))
    pygame.init()
    pygame.camera.init()
    # set up a camera object
    cam = pygame.camera.Camera("/dev/video0", resolution)
    # start the camera
    cam.start()

    m.load_weights(m.predict_global, 'global_training_3')
    while 1:
        # sleep between every frame