Exemple #1
0
    def test_animate(self):
        with patch('matplotlib.image.AxesImage') as mock_axes:
            with patch('matplotlib.pyplot.imshow',
                       return_value=mock_axes) as mock_imshow:
                with patch('matplotlib.pyplot.figure') as mock_figure:
                    with patch('matplotlib.pyplot.show',
                               return_value=mock_axes) as mock_show:
                        num_frames = 10
                        images = [
                            np.ndarray(shape=(10, 10, 3))
                            for i in range(num_frames)
                        ]
                        viewer.animate(images, auto_close=True)

                        assert mock_imshow.call_count == 1
                        assert mock_show.call_count == 1
Exemple #2
0
 def test_animate_unsupoprted_dimension(self):
     with patch('matplotlib.image.AxesImage') as mock_axes:
         with patch('matplotlib.pyplot.imshow',
                    return_value=mock_axes) as mock_imshow:
             with patch('matplotlib.pyplot.figure') as mock_figure:
                 with patch('matplotlib.pyplot.show') as mock_show:
                     with patch(
                             'matplotlib.pyplot.subplot') as mock_subplot:
                         num_frames = 10
                         images = [
                             np.ndarray(shape=(10, 10, 3))
                             for i in range(num_frames)
                         ]
                         with pytest.raises(ValueError):
                             viewer.animate(images=images,
                                            comparisons=[[images, images],
                                                         [images, images]],
                                            auto_close=True)
Exemple #3
0
def animate_predictions(model, dataset, mean_image, args):
    initial_frame = args.initial_frame
    last_frame = args.last_frame
    frames = dataset['frames'][initial_frame:last_frame]
    actions = dataset['actions'][initial_frame + 1:last_frame + 1]

    if args.lstm:
        ground_truths, predicted_frames = animate_lstm(model, frames, actions,
                                                       mean_image, args)
    else:
        ground_truths, predicted_frames = animate_ff(model, frames, actions,
                                                     mean_image, args)

    viewer.animate(ground_truths,
                   predicted_frames,
                   titles=['ground truth', 'predicted'],
                   fps=10,
                   repeat=True,
                   save_mp4=True,
                   auto_close=True)
Exemple #4
0
def show_sequence(images):
    viewer.animate(images=images, is_gray=True, save_mp4=True, save_gif=True)
Exemple #5
0
def animate_dataset(dataset, args):
    initial_frame = args.initial_frame
    last_frame = args.last_frame
    frames = [converter.chw2hwc(frame) for frame in dataset['frames']]
    viewer.animate(frames[initial_frame:last_frame], titles=['dataset'])