(self,
            checkpoint_dir,
            vid_dir,
            frame_ext,
            out_dir,
            amplification_factor,
            velocity_mag=False)
Magnify a video in the two-frames mode.

        Args:
            checkpoint_dir: checkpoint directory.
            vid_dir: directory containing video frames videos are processed
                in sorted order.
            out_dir: directory to place output frames and resulting video.
            amplification_factor: the amplification factor,
                with 0 being no change.
            velocity_mag: if True, process video in Dynamic mode.
Magnify a video in the two-frames mode.
Magnify a video in the two - frames mode .
def run(self,
            checkpoint_dir,
            vid_dir,
            frame_ext,
            out_dir,
            amplification_factor,
            velocity_mag=False):
        """Magnify a video in the two-frames mode.

        Args:
            checkpoint_dir: checkpoint directory.
            vid_dir: directory containing video frames videos are processed
                in sorted order.
            out_dir: directory to place output frames and resulting video.
            amplification_factor: the amplification factor,
                with 0 being no change.
            velocity_mag: if True, process video in Dynamic mode.
        """
        vid_name = os.path.basename(out_dir)
        # make folder
        mkdir(out_dir)
        vid_frames = sorted(glob(os.path.join(vid_dir, '*.' + frame_ext)))
        first_frame = vid_frames[0]
        im = imread(first_frame)
        image_height, image_width = im.shape
        if not self.is_graph_built:
            self.setup_for_inference(checkpoint_dir, image_width, image_height)
        try:
            i = int(self.ckpt_name.split('-')[-1])
            print("Iteration number is {:d}".format(i))
            vid_name = vid_name + '_' + str(i)
        except:
            print("Cannot get iteration number")
        if velocity_mag:
            print("Running in Dynamic mode")

        prev_frame = first_frame
        desc = vid_name if len(vid_name) < 10 else vid_name[:10]
        for frame in tqdm(vid_frames, desc=desc):
            file_name = os.path.basename(frame)
            out_amp = self.inference(prev_frame, frame, amplification_factor)

            im_path = os.path.join(out_dir, file_name)
            save_images(out_amp, [1, 1], im_path)
            if velocity_mag:
                prev_frame = frame

        # Try to combine it into a video
        call([DEFAULT_VIDEO_CONVERTER, '-y', '-f', 'image2', '-r', '30', '-i',
              os.path.join(out_dir, '%06d.png'), '-c:v', 'libx264',
              os.path.join(out_dir, vid_name + '.mp4')]
            )
def run ( self , checkpoint_dir , vid_dir , frame_ext , out_dir , amplification_factor , velocity_mag = False ) : vid_name = os . path . basename ( out_dir ) # make folder mkdir ( out_dir ) vid_frames = sorted ( glob ( os . path . join ( vid_dir , '*.' + frame_ext ) ) ) first_frame = vid_frames [ 0 ] im = imread ( first_frame ) image_height , image_width = im . shape if not self . is_graph_built : self . setup_for_inference ( checkpoint_dir , image_width , image_height ) try : i = int ( self . ckpt_name . split ( '-' ) [ - 1 ] ) print ( "Iteration number is {:d}" . format ( i ) ) vid_name = vid_name + '_' + str ( i ) except : print ( "Cannot get iteration number" ) if velocity_mag : print ( "Running in Dynamic mode" ) prev_frame = first_frame desc = vid_name if len ( vid_name ) < 10 else vid_name [ : 10 ] for frame in tqdm ( vid_frames , desc = desc ) : file_name = os . path . basename ( frame ) out_amp = self . inference ( prev_frame , frame , amplification_factor ) im_path = os . path . join ( out_dir , file_name ) save_images ( out_amp , [ 1 , 1 ] , im_path ) if velocity_mag : prev_frame = frame # Try to combine it into a video call ( [ DEFAULT_VIDEO_CONVERTER , '-y' , '-f' , 'image2' , '-r' , '30' , '-i' , os . path . join ( out_dir , '%06d.png' ) , '-c:v' , 'libx264' , os . path . join ( out_dir , vid_name + '.mp4' ) ] )