AnimationKit: AI Upscaling & Interpolation using Real-ESRGAN+RIFE

Overview

ALPHA 2.5: Frostbite Revival (Released 12/23/21)

Changelog:

[ UI ] Chained design. All steps link to one another! Use the master override toggles to skip processes.
[ Upscaling ] GFPGAN face-enhance toggle (embedded in Real-ESRGAN)
[ Interpolation ] Practical-RIFE implementation; 4.0 model
[ File mgmt ] Compatibility with padded filenames, File overwrite protection, verification of completion
[ Misc ] Forked essential dependencies for long-term backwards compatibility; if needed.

*This updates brings AnKit back to a functioning state. Upcoming updates will make use of recent prerequisite updates and coinciding AI advances. *


AnimationKit - AI Upscaling & Interpolation using Real-ESRGAN+RIFE

Your (eventual) all-in-one AI post-processing tool!

Early Alpha Google Colab Notebook

  1. AnimationKit Colab Notebook for Real-ESRGAN google colab logo.

Features:

  • Real-ESRGAN video upscaling (Raise your resolution by up to 4x!)
  • Practical-RIFE motion smoothing / video interpolation (Make choppy footage smooth)
  • Chained design - No need to sort through multiple cells! Set your options and forget it.
  • Google Colab (with basic UI) & Google Drive support
  • Import either mp4 files or an individual frame folder

Real-ESRGAN video upscaling, RIFE interpolation/motion smoothing, and FFMPEG hevc_nvenc (h265) compression


Credits: Motion smoothing conceived from "Zoom animation processing and motion interpolation" added by https://twitter.com/unltd_dream_co. This part of the script uses RIFE real-time video interpolation to smooth out the resulting video.

Upscaling uses Real-ESRGAN (https://github.com/xinntao/Real-ESRGAN). A demo notebook for static images can be found here: https://colab.research.google.com/drive/1k2Zod6kSHEvraybHl50Lys0LerhyTMCo?usp=sharing. The demo was based on the following paper: ''Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data''.

Feature additions & bugfixes:


Feel free to report bugs and/or help with developments! See the "Issues" page for documentation and development notes-

#Prior Changelog (Incomplete)

##ALPHA 2: Released 9/4/21 Feature additions

  • : 🔻 : Deflickering [Depcrecated]
  • Upscaling from individual frames (P2)
  • Target length (in seconds) for RIFE interpolation - Replaces old length_multiplier option

#Alpha 1 release: All major bugs have (hopefully) been patched. New functions will be released in the testing branch until debugged.

  • Anime model for realesrgan
  • 2x model
  • target output path
  • omission of outscaling (note, may need to check defaults in inference.py)
  • target fps no longer causes duplicates prior to ffmpeg end-phase (prevents upscaler from wasting gpu cycles on duplicate frames; major speed increase)
  • notebook set to high memory - necessary for RIFE
Comments
  • AnKit 2022 Barebones Revival Progress

    AnKit 2022 Barebones Revival Progress

    Since my temporary departure from developments 2-3 months ago, a variety of bugs have sprung up, likely as a result of ever-changing dependencies. This thread will track the status of bringing AnKit back to its previous functioning state.

    documentation 
    opened by sadnow 7
  • AnKit: Fix filename sorting for individual frame processing

    AnKit: Fix filename sorting for individual frame processing

    Some programs output as 1.jpg, 2.jpg, 3.jpg etc. whereas others output as 001.jpg, 002.jpg. etc.

    Right now, the non-botched build does the former.

    I need to make it auto-recognize the flow of a directory and have it sort accordingly.

    bug enhancement 
    opened by sadnow 7
  • AnKit 2.6 Dev Logs - Adding Real-ESRGAN video models, Sound, Preserving Old Methods

    AnKit 2.6 Dev Logs - Adding Real-ESRGAN video models, Sound, Preserving Old Methods

    a16434f41a8998b6efd9f64b813269ffd8aa5a81 hides the following options:

    "'RealESRGANv2-anime-xsx2','RealESRGANv2-animevideo-xsx2-nousm','RealESRGANv2-animevideo-xsx2','RealESRGANv2-anime-xsx4','RealESRGANv2-animevideo-xsx4-nousm','RealESRGANv2-animevideo-xsx4"

    Originally posted by @sadnow in https://github.com/sadnow/AnimationKit-AI/issues/5#issuecomment-1000061506

    These newer Real-ESRGAN's functions will be tested and integrated. Prior functions will be preserved and left as a toggle for users.

    • [x] differentiate AnKit chained process into 2 methods, recognized by vars method_a and method_b
    • [x] #14
    • [ ] Outscale option for Method B (possibly mixed w/ with rife_scale) - intended for lower-power gpu's
    • [x] #11
    • [x] RIFE sound support in method B
    • [ ] Compare current splitframes, frames2video methods to the examples listed in https://github.com/xinntao/Real-ESRGAN/blob/master/docs/anime_video_model.md#step-1-use-ffmpeg-to-extract-frames-from-video
    • [ ] #17
    • [ ] c:v hevc_nvenc support for new_method inference_py file
    • [ ] fps detection occurs before RIFE
    • [ ] source_fps option for individual_frames (with a default being "default" (24fps)

    For documentation, I guess I could refer to this as Method-A & Method-B AnKit Chaining. Sounds fancy.

    Reference links: https://github.com/xinntao/Real-ESRGAN/blob/master/docs/anime_video_model.md https://stackoverflow.com/questions/678236/how-to-get-the-filename-without-the-extension-from-a-path-in-python?rq=1

    --- Code overhaul

    • [ ] #20
    documentation enhancement 
    opened by sadnow 5
  • Nixing netscale

    Nixing netscale

    Hurdle: "error: unrecognized arguments: --netscale 4"

    Originally posted by @sadnow in https://github.com/sadnow/AnimationKit-AI/issues/2#issuecomment-1000048704

    bug 
    opened by sadnow 2
  • Model_path needs changed to model_name

    Model_path needs changed to model_name

    "inference_realesrgan.py: error: unrecognized arguments: --model_path /content/Real-ESRGAN/experiments/pretrained_models/RealESRGAN_x4plus.pth --netscale 4 /content/Real-ESRGAN/results"

    Re-evaluating available params

    Originally posted by @sadnow in https://github.com/sadnow/AnimationKit-AI/issues/2#issuecomment-1000042722

    bug 
    opened by sadnow 2
  • ModuleNotFoundError: No module named 'gfpgan.archs.stylegan2_cleanonnx_arch'

    ModuleNotFoundError: No module named 'gfpgan.archs.stylegan2_cleanonnx_arch'

    hmm, getting the following error since this afternoon:

    Creating /content/frames_storage/upscaled_frame_storage ...
    /content/Real-ESRGAN
    Traceback (most recent call last):
      File "inference_realesrgan.py", line 128, in <module>
        main()
      File "inference_realesrgan.py", line 84, in main
        from gfpgan import GFPGANer
      File "/usr/local/lib/python3.7/dist-packages/gfpgan/__init__.py", line 2, in <module>
        from .archs import *
      File "/usr/local/lib/python3.7/dist-packages/gfpgan/archs/__init__.py", line 10, in <module>
        _arch_modules = [importlib.import_module(f'gfpgan.archs.{file_name}') for file_name in arch_filenames]
      File "/usr/local/lib/python3.7/dist-packages/gfpgan/archs/__init__.py", line 10, in <listcomp>
        _arch_modules = [importlib.import_module(f'gfpgan.archs.{file_name}') for file_name in arch_filenames]
      File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "/usr/local/lib/python3.7/dist-packages/gfpgan/archs/gfpganv1_cleanonnx_arch.py", line 8, in <module>
        from .stylegan2_cleanonnx_arch import StyleGAN2GeneratorCleanONNX
    ModuleNotFoundError: No module named 'gfpgan.archs.stylegan2_cleanonnx_arch'
    

    Investigating.

    opened by danielpuglisi 0
  • Final Video Output Compression Error?

    Final Video Output Compression Error?

    I LOVE THIS NOTEBOOK! Major props. One question, the first few videos came out H265 and perfect, but after a few times running the notebook with different videos/input frame folders, the video fails to compress properly? Example, the video will save to my drive and will be available for download, but once I download and attempt to play the video, it won't open on any media player, yet will play while still loaded in my drive? I'm thinking that it could be a compression issue, but any help will be appreciated as I LOVE this notebook, if I haven't said it again. Thanks in advance, and amazing work!

    opened by AIManifest 0
  • I'm getting out of memory on cuda, and I want to specify the tile size, but I need to know what code to insert where!

    I'm getting out of memory on cuda, and I want to specify the tile size, but I need to know what code to insert where!

    I'm using the animation kit-AI on google colab and cuda is running out of memory, I want to specify the tile size, please tell me where to insert the code! -I want to specify the tile size, but I need to know where to insert the code! What code do I put it in? ↓URL https://colab.research.google.com/github/sadnow/AnimationKit-AI_Upscaling-Interpolation_RIFE-RealESRGAN/blob/main/AnimationKit_Rife_RealESRGAN_Upscaling_Interpolation.ipynb#scrollTo=MhMORNgduDyt

    Error message " Error CUDA out of memory.Tried to allocate 7.91 GiB (GPU 0; 14.76 GiB total capacity; 2.51 GiB already allocated; 2.81 GiB free; 10.90 GiB reserved in total by PyTorch) If reserved memory is more than allocated memory, try setting max_split_size_mb to prevent fragmentation. See the documentation on memory management and PYTORCH_CUDA_ALLOC_CONF. If CUDA runs out of memory, try setting -tile to a smaller number. Test 428 A00429 "

    opened by tom21001112 1
  • Include RIFE model in repo

    Include RIFE model in repo

    The google drive version of the RIFE model can no longer be downloaded programatically, so the notebook fails to run. This PR mirrors the RIFE model here and uses the mirrored version instead.

    opened by chigozienri 0
  • SadKit class: handles specific Path, Audio, Video, Image functions

    SadKit class: handles specific Path, Audio, Video, Image functions

    This is an evolution of the previous classes and functions AnKit utilized pre-2.5.

    Rough draft:

    class SadKit:
      def __init__(self):
        ## instantiating the 'Inner' class
        #self.debug = self.Debug()
        self.path = self.Path()
        self.image_tools = self.Image_tools()
        #Ank = self.AnimationKit_colab
        # self.dprint = self.dprint
        #dprint = self.debug_print
        import os.path
        from os import path
      def debug_print(self, msg): #debug print
        print(msg)  #make this colored eventually
        #code to clear screen
      class Image_tools:
        def frames2video(self, input):
          #!ffmpeg -framerate $_target_fps -pattern_type glob -i '*.png' -y '/content/frames2video.mp4' #old method
          print("RUNNING THE EXPERIMENTAL")
          !ffmpeg -r 24 -pattern_type glob -i '*.png' -c:v libx264 -r 23.98 -pix_fmt yuv420p '/content/frames_storage/init_frame_storage/frames2video.mp4'  #documented example realsrgan-video.md
            #note: detect_fps might be wonky
    
      class Path:
        #intent(s): detect, create, insert, type_id, remove_extension, append_prefix, append_suffix
        #  
        def detect_dir(self, input):  #/content/example.mp4 would become /content/
          dir = os.path.dirname(input)
          return dir
        def make(self, input):
          !mkdir -p $input
        def type_id(self, input): #determine whether file or directory
          #types: file,dir
          import os.path
          from os import path
          input = self.sanitize(input)
          if os.path.isdir(input):  type = 'dir'
          elif os.path.isfile(input): type = 'file'
          else: type = 'error'
          #print(type)
          return type
          #else: print("ERROR: Your input file is neither an mp4 nor a frame directory.")
        def sanitize(self, input):
          import os.path
          input = os.path.normpath(input)
          return input
        def filter_by_extension(self, input_dir, output_dir, file_ext): #sorts a dir's files by extension and copies matching files to new dir
          #print("\n Beginning sortFrames... ")
          if not self.query(output_dir):
            self.make(output_dir)
          #print("\n Copying frames to "+'/content/frames_storage/init_frame_storage'+" for processing...\n")
          %cd $input
          #!find -maxdepth 1 -name '*.png' -print0 | xargs -0 cp -t '/content/frames_storage/init_frame_storage'
          !find -maxdepth 1 -name '*.'$file_ext -print0 | xargs -0 cp -t $output
          %cd $output
          !find . -type f -name "*."$file_ext -execdir bash -c 'mv "$0" "${0##*_}"' {} \;  #removes anything not numbered (junk files) from new dir
          self.dir_file_suffix_padding(output_dir)
          print("\n Finished copying frames to "+'/content/frames_storage/init_frame_storage'+".\n")
          print("Completed sortFrames... \n")
        def dir_file_suffix_padding(input_dir): #pads all filenames within a dir
          %cd $input_dir
          !rename 's/\d+/sprintf("%05d",$&)/e' *  #adds padding to numbers
          return
        def query(self, input):
          if self.type_id(input) == 'file' or self.type_id(input) == 'dir': 
            #print(self.type_id(input))
            return True
          else: return False
        def upload(self, input):
          import os
          from google.colab import files
          import shutil
          # upload images
          upload_folder = 'upload'
          result_folder = 'results'
          if os.path.isdir(upload_folder):
            shutil.rmtree(upload_folder)
          if os.path.isdir(result_folder):
            shutil.rmtree(result_folder)
          os.mkdir(upload_folder)
          os.mkdir(result_folder)
          #
          uploaded = files.upload()
          for filename in uploaded.keys():
            dst_path = os.path.join(upload_folder, filename)
            print(f'move {filename} to {dst_path}')
            shutil.move(filename, dst_path)
    ######################
    
    documentation enhancement 
    opened by sadnow 0
Owner
I have twisted and crawled and churned through the absurd in search of the truth but alas, this is all just paper flying in our faces.
null
RIFE: Real-Time Intermediate Flow Estimation for Video Frame Interpolation

RIFE - Real Time Video Interpolation arXiv | YouTube | Colab | Tutorial | Demo Table of Contents Introduction Collection Usage Evaluation Training and

hzwer 3k Jan 4, 2023
RIFE - Real-Time Intermediate Flow Estimation for Video Frame Interpolation

RIFE - Real-Time Intermediate Flow Estimation for Video Frame Interpolation YouTube | BiliBili 16X interpolation results from two input images: Introd

旷视天元 MegEngine 28 Dec 9, 2022
Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data

Real-ESRGAN Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data Ported from https://github.com/xinntao/Real-ESRGAN Depend

Holy Wu 44 Dec 27, 2022
SE3 Pose Interp - Interpolate camera pose or trajectory in SE3, pose interpolation, trajectory interpolation

SE3 Pose Interpolation Pose estimated from SLAM system are always discrete, and

Ran Cheng 4 Dec 15, 2022
Real-ESRGAN aims at developing Practical Algorithms for General Image Restoration.

Real-ESRGAN Colab Demo for Real-ESRGAN . Portable Windows executable file. You can find more information here. Real-ESRGAN aims at developing Practica

Xintao 17.2k Jan 2, 2023
PyTorch implementation of a Real-ESRGAN model trained on custom dataset

Real-ESRGAN PyTorch implementation of a Real-ESRGAN model trained on custom dataset. This model shows better results on faces compared to the original

Sber AI 160 Jan 4, 2023
My usage of Real-ESRGAN to upscale anime, some test and results in the test_img folder

anime upscaler My usage of Real-ESRGAN to upscale anime, I hope to use this on a proper GPU cuz doing this on CPU is completely shit ?? , I even tried

Shangar Muhunthan 29 Jan 7, 2023
Unsupervised Video Interpolation using Cycle Consistency

Unsupervised Video Interpolation using Cycle Consistency Project | Paper | YouTube Unsupervised Video Interpolation using Cycle Consistency Fitsum A.

NVIDIA Corporation 100 Nov 30, 2022
an implementation of Revisiting Adaptive Convolutions for Video Frame Interpolation using PyTorch

revisiting-sepconv This is a reference implementation of Revisiting Adaptive Convolutions for Video Frame Interpolation [1] using PyTorch. Given two f

Simon Niklaus 59 Dec 22, 2022
An implementation of Video Frame Interpolation via Adaptive Separable Convolution using PyTorch

This work has now been superseded by: https://github.com/sniklaus/revisiting-sepconv sepconv-slomo This is a reference implementation of Video Frame I

Simon Niklaus 984 Dec 16, 2022
FLAVR is a fast, flow-free frame interpolation method capable of single shot multi-frame prediction

FLAVR is a fast, flow-free frame interpolation method capable of single shot multi-frame prediction. It uses a customized encoder decoder architecture with spatio-temporal convolutions and channel gating to capture and interpolate complex motion trajectories between frames to generate realistic high frame rate videos. This repository contains original source code for the paper accepted to CVPR 2021.

Tarun K 280 Dec 23, 2022
ICLR 2021, Fair Mixup: Fairness via Interpolation

Fair Mixup: Fairness via Interpolation Training classifiers under fairness constraints such as group fairness, regularizes the disparities of predicti

Ching-Yao Chuang 49 Nov 22, 2022
Code of paper "CDFI: Compression-Driven Network Design for Frame Interpolation", CVPR 2021

CDFI (Compression-Driven-Frame-Interpolation) [Paper] (Coming soon...) | [arXiv] Tianyu Ding*, Luming Liang*, Zhihui Zhu, Ilya Zharkov IEEE Conference

Tianyu Ding 95 Dec 4, 2022
VOGUE: Try-On by StyleGAN Interpolation Optimization

VOGUE is a StyleGAN interpolation optimization algorithm for photo-realistic try-on. Top: shirt try-on automatically synthesized by our method in two different examples.

Wei ZHANG 66 Dec 9, 2022
This is the official repository of XVFI (eXtreme Video Frame Interpolation)

XVFI This is the official repository of XVFI (eXtreme Video Frame Interpolation), https://arxiv.org/abs/2103.16206 Last Update: 20210607 We provide th

Jihyong Oh 195 Dec 29, 2022
Repository relating to the CVPR21 paper TimeLens: Event-based Video Frame Interpolation

TimeLens: Event-based Video Frame Interpolation This repository is about the High Speed Event and RGB (HS-ERGB) dataset, used in the 2021 CVPR paper T

Robotics and Perception Group 544 Dec 19, 2022
Simple sinc interpolation in PyTorch.

Kazane: simple sinc interpolation for 1D signal in PyTorch Kazane utilize FFT based convolution to provide fast sinc interpolation for 1D signal when

Chin-Yun Yu 10 May 3, 2022
Asymmetric Bilateral Motion Estimation for Video Frame Interpolation, ICCV2021

ABME (ICCV2021) Junheum Park, Chul Lee, and Chang-Su Kim Official PyTorch Code for "Asymmetric Bilateral Motion Estimation for Video Frame Interpolati

Junheum Park 86 Dec 28, 2022
N-gram models- Unsmoothed, Laplace, Deleted Interpolation

N-gram models- Unsmoothed, Laplace, Deleted Interpolation

Ravika Nagpal 1 Jan 4, 2022