                  frame_no = os.path.splitext(filename)[0][filename.rfind("_") + 1:]
                  logger.trace("Extracted frame_no %s from filename '%s'", frame_no, filename)
              retval = self.load_one_video_frame(int(frame_no))
          else:
              retval = cv2_read_img(filename, raise_error=True)
          return retval
  
      def load_one_video_frame(self, frame_no):
          """ Load a single frame from a video file """
          logger.trace("Loading video frame: %s", frame_no)
 
</s> remove             image = cv2_read_img(src, raise_error=True)
 </s> add             image = read_image(src, raise_error=True) </s> remove         image = cv2_read_img(filename, raise_error=True)
 </s> add         image = read_image(filename, raise_error=True) </s> remove def count_frames_and_secs(path, timeout=60):
    """
    Adapted From ffmpeg_imageio, to handle occasional hanging issue:
    https://github.com/imageio/imageio-ffmpeg

    Get the number of frames and number of seconds for the given video
    file. Note that this operation can be quite slow for large files.

    Disclaimer: I've seen this produce different results from actually reading
    the frames with older versions of ffmpeg (2.x). Therefore I cannot say
    with 100% certainty that the returned values are always exact.
    """
    # https://stackoverflow.com/questions/2017843/fetch-frame-count-with-ffmpeg

 </s> add def full_path_split(path):
    """ Split a given path into all of it's separate components """ </s> remove             logger.trace("Flip outside threshold. Not Flipping")
            retval = image
        logger.trace("Randomly flipped image")
 </s> add             logger.trace("Batch has no mask")
            retval = dict(targets=batch) </s> remove         except subprocess.CalledProcessError as err:
            out = err.output.decode(errors="ignore")
            raise RuntimeError("FFMEG call failed with {}:\n{}".format(err.returncode, out))
        except subprocess.TimeoutExpired as err:
            this_attempt = attempt + 1
            if this_attempt == attempts:
                msg = ("FFMPEG hung while attempting to obtain the frame count. "
                       "Sometimes this issue resolves itself, so you can try running again. "
                       "Otherwise use the Effmpeg Tool to extract the frames from your video into "
                       "a folder, and then run the requested Faceswap process on that folder.")
                raise FaceswapError(msg) from err
            logger.warning("FFMPEG hung while attempting to obtain the frame count. "
                           "Retrying %s of %s", this_attempt + 1, attempts)
            continue

    # Note that other than with the subprocess calls below, ffmpeg wont hang here.
    # Worst case Python will stop/crash and ffmpeg will continue running until done.

    nframes = nsecs = None
    for line in reversed(out.splitlines()):
        if not line.startswith(b"frame="):
            continue
        line = line.decode(errors="ignore")
        logger.debug("frame line: '%s'", line)
        idx = line.find("frame=")
        if idx >= 0:
            splitframes = line[idx:].split("=", 1)[-1].lstrip().split(" ", 1)[0].strip()
            nframes = int(splitframes)
        idx = line.find("time=")
        if idx >= 0:
            splittime = line[idx:].split("=", 1)[-1].lstrip().split(" ", 1)[0].strip()
            nsecs = convert_to_secs(*splittime.split(":"))
        logger.debug("nframes: %s, nsecs: %s", nframes, nsecs)
        return nframes, nsecs

    raise RuntimeError("Could not get number of frames")  # pragma: no cover
 </s> add         elif parts[1] == path:  # sentinel for relative paths
            allparts.insert(0, parts[1])
            break
        else:
            path = parts[0]
            allparts.insert(0, parts[1])
    logger.trace("path: %s, allparts: %s", path, allparts)
    return allparts
            retval = read_image(filename, raise_error=True)
                  frame_no = os.path.splitext(filename)[0][filename.rfind("_") + 1:]
                  logger.trace("Extracted frame_no %s from filename '%s'", frame_no, filename)
              retval = self.load_one_video_frame(int(frame_no))
          else:
            retval = read_image(filename, raise_error=True)
          return retval
  
      def load_one_video_frame(self, frame_no):
          """ Load a single frame from a video file """
          logger.trace("Loading video frame: %s", frame_no)
keep keep keep keep replace keep keep keep keep keep
 Optimize Data Augmentation (#881)

* Move image utils to lib.image
* Add .pylintrc file
* Remove some cv2 pylint ignores
* TrainingData: Load images from disk in batches
* TrainingData: get_landmarks to batch
* TrainingData: transform and flip to batches
* TrainingData: Optimize color augmentation
* TrainingData: Optimize target and random_warp
* TrainingData - Convert _get_closest_match for batching
* TrainingData: Warp To Landmarks optimized
* Save models to threadpoolexecutor
* Move stack_images, Rename ImageManipulation. ImageAugmentation Docstrings
* Masks: Set dtype and threshold for lib.masks based on input face
* Docstrings and Documentation 
scripts/fsmedia.py