Crunchyroll
Published in

Crunchyroll

Scaling up Anime with Machine Learning and Smart Real Time Algorithms

Authored By Chris Kennedy, Nick Fujita & Michael Dale

What your TV/Device/Browser does today.

As we look to improve the situation, it’s important to understand the current process. The majority of up-scaling uses efficient generic up-scaling algorithms like bilinear interpolation–essentially using mathematical equations to estimate and fill in visual data to account for the difference between the source video and a monitor’s resolution (for more information on this and other related algorithms, check out the Wikipedia page). In most cases your browser or your mobile app will use bilinear or bicubic interpolation to upscale videos and images. These algorithms work by creating weighted values for pixels by comparing adjacent pixels.

ML Upscale Encoding

What you should know first is that we pursued two different types of upscaling: 1. upscaling that occurs on the video file level (which we will call the encode level) (before the file is even accessed for streaming) and 2. dynamic upscaling that occurs in real time as the file is being streamed. For upscaling on the encode level, we are using the software Waifu2x. Waifu2x is authored by GitHub user Nagadomi and inspired by SRCNN[1] (Super-Resolution Using Deep Convolutional Networks) techniques–applied machine learning used for upscaling images. It leverages a Convolutional Neural Network (CNN) model that compensates for kinds of details that are commonly lost as content is scaled up. It uses that model to predict and fill in the details as content is scaled to a resolution larger than its source.

Evaluation of upscale performance

For us to rollout these encodes to our fans (even in a limited experiment); it was important to obtain some objective measures of the quality gains by leveraging this technique. To test the upscale performance we had to establish benchmarks with assets that already included high resolution source videos. We downsampled (we took a source video at 720P resolution and made its resolution smaller) to 360P to represent the available quality of some of our early catalog titles; and then scaled up to 720P. We then compared the original 720P video to the videos that had been enlarged from 360P. We compared bilinear interpolation, bicubic interpolation, and Waifu2x. From these measurements, Waifu2x had significant gains towards accurate representation of the target material over traditional scaling techniques. An overview of what the scripting looks like for generation this data can be viewed here.

What about upscaling to 4k?

The changes in image resolution from 1080P to 2160P (4K) are much more difficult to notice unless using very large displays. When you already have a very detailed 1080P source material, there is less opportunity to noticeably clean things up. The Waifu2x and traditional source scaling are often not noticeably different at 4k display per our comparison. With extreme zoom some deltas of bicubic interpolation vs Waifu2x start to be noticeable.

Where Can I see these upscale encodes?

We are experimenting with this up scaled technique on a few pieces of our historically low resolution content. Accessing this content on any Crunchyroll supported platform will consume the higher quality versions of these encodes.

RealTime up-scaling

Waifu2x offers a solution at the video file level, but you will remember above that we were also exploring real time upscaling that happens as the file is being streamed (client level). For client level upscaling, GPU Anime4k is a leading solution. Anime4k was built by GitHub user bloc97 and is a “state of the art real-time anime upscale algorithm that can be implemented in arbitrary programming languages”. In the case of web experience, a WebGL shader (shaders are computer programs traditionally used to produce shades on 3D objects, but are now used widely in video post-processing) is used to support real-time up scaling within a web browser at resolutions up to 4k / 2160p. Interestingly, because Crunchyroll leverages soft subtitles (subtitles that are overlaid onto the video instead of existing as part of the original video file), we leverage browser compositing to scale the video and subtitle displays separately where possible.

How to play with real-time upscaling ?

The real-time upscale tools are available only on the web on select browsers where WebGL is available. The feature is very much still in the alpha phase, so please keep that in mind. You can see the selection under advanced quality controls for Premium Crunchyroll users of Chrome & Edge browsers. Here is the process:

Which approach is better?

The approach used in both encode and client upscaling is very different and they hit very different use cases. The ideal setup may be leveraging both as we look towards improving content scaling across the diversity of source files, contexts for streaming, and bandwidth constraints.

Future work

We aim to elicit feedback from the community around scaling filters or encodes. Another important aspect of this work would be, of course, to bring these upscale capabilities (and 4k versions of our applications) to game console and UHD streaming devices that are connected to 4k televisions where these techniques’ impact would be most apparent. Likewise, on mobile where the in-network constrained environment would allow for clear benefits towards anime specific upscaling on client vs the lossy traditional scaling techniques used today.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store