コード例 #1
0
    masks : tf.Tensor of shape [batch, c, n_people, 1]
    """
    im_size = [512, 512]
    paf_sigma = 20
    keypoints = InputLayer(input_shape=[32, 24, 8, 2], name='keypoints')
    masks = InputLayer(input_shape=[32, 24, 8, 1], name='keypoints')

    paf_layer = PAFLayer(im_size=im_size,
                         sigma=paf_sigma,
                         skeleton=CONNECT_INDEXES_FOR_PAFF)
    paf = paf_layer([keypoints, masks])

    sess = tf.Session()
    paf_shape = sess.run(tf.shape(paf.get_data_tensor()),
                         feed_dict={
                             keypoints.get_data_tensor():
                             np.random.randn(32, 24, 8, 2),
                             masks.get_data_tensor():
                             np.random.randn(32, 24, 8, 1)
                         })
    print(paf)
    print(paf_shape)
    import matplotlib

    # For some reason matplotlib doesn't want to show the plot when it is called from PyCharm
    matplotlib.use('TkAgg')
    import seaborn as sns
    import matplotlib.pyplot as plt
    import math

    def put_paf_on_plane(vectormap, countmap, plane_idx, x1, y1, x2, y2,
コード例 #2
0
    from makiflow.layers import InputLayer

    # RUN A SANITY CHECK FIRST
    in_x = InputLayer(input_shape=[1, 3, 3, 100 * 2], name='offsets')
    # Never pass in a numpy array to the `custom_embedding` argument. Always use list.
    coords_ish = SkeletonEmbeddingLayer(embedding_dim=None, name='TestEmbedding', custom_embedding=points)(in_x)

    print('Coords MakiTensor', coords_ish)
    print('Coords TfTensor', coords_ish.get_data_tensor())

    sess = tf.Session()
    sess.run(tf.global_variables_initializer())
    coords = sess.run(
        coords_ish.get_data_tensor(),
        feed_dict={
            in_x.get_data_tensor(): np.zeros(shape=[1, 3, 3, 200], dtype='float32')
        }
    )

    # Visualize the circles
    import matplotlib

    # For some reason matplotlib doesn't want to show the plot when it is called from PyCharm
    matplotlib.use('TkAgg')
    import matplotlib.pyplot as plt

    coords = coords.reshape(-1, 2)
    plt.scatter(coords[:, 0], coords[:, 1])
    plt.show()

    from makiflow.core.debug import DebugContext
コード例 #3
0
ファイル: ssp_model.py プロジェクト: TaplierShiru/MakiFlow
    from .head import Head

    head = Head(coords, point_indicators, human_indicators)
    model = SSPModel(heads=[head], in_x=in_x)

    sess = tf.Session()
    model.set_session(sess)
    coords, _, _ = model._session.run(
        [
            model._regressed_points, model._point_indicators,
            model._human_indicators
        ],
        feed_dict={
            model._in_x.get_data_tensor():
            np.zeros(shape=[1, 3, 3, 200], dtype='float32'),
            point_indicators.get_data_tensor():
            np.ones(shape=[1, 3, 3, 100], dtype='float32'),
            human_indicators.get_data_tensor():
            np.ones(shape=[1, 3, 3, 1], dtype='float32')
        })

    # Visualize the circles
    import matplotlib

    # For some reason matplotlib doesn't want to show the plot when it is called from PyCharm
    matplotlib.use('TkAgg')
    import matplotlib.pyplot as plt

    coords = coords.reshape(-1, 2)
    plt.scatter(coords[:, 0], coords[:, 1])
    plt.show()