GithubHelp home page GithubHelp logo

zhaodg / waifu2x-ios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imxieyi/waifu2x-ios

0.0 0.0 0.0 128.21 MB

iOS Core ML implementation of waifu2x

License: MIT License

Swift 91.33% Objective-C 0.98% Metal 7.70%

waifu2x-ios's Introduction

waifu2x on iOS

Introduction

This is a Core ML implementation of waifu2x. The target of this project is to run waifu2x models right on iOS devices even without network. For macOS version please refer to waifu2x-mac.

Requirements

  • XCode 9+
  • iOS 11+

Image format

Images with RGB color space works fine. Others should be converted to RGB before processing otherwise output image will be broken. Alpha channel is scaled using bicubic interpolation. Generally it runs on GPU. It automatically falls back to CPU if image is too large for Metal to process, which is extremely slow. (A bad idea)

About models

This repository includes all the models converted from waifu2x-caffe. If you want to dig into Core ML, it is recommended that you should convert them by yourself.

You can convert pre-trained models to Core ML format and then import them to XCode. The pre-trained model can be obtained from waifu2x-caffe.

You can use the same method described in MobileNet-CoreML. You should not specify any input and output layer in python script.

A working model should have input and output like the following example:

Benchmark

Environment

  • iPhone6s - waifu2x-ios on iPhone 6s with iOS 11.1
  • iPhone8 - waifu2x-ios on iPhone 8 with iOS 11.0
  • iPhone11Pro - waifu2x-ios on iPhone 11 Pro with iOS 13.1 (Neural Engine)
  • iPad - waifu2x-ios on iPad Pro 10.5 with iOS 11.1
  • PC - waifu2x-caffe on Windows 10 16278 with GTX 960M

Results

All of the tests are running denoise level 2 with scale 2x model on anime-style images from Pixiv.

Test1

Image resolution: 600*849

Device Time(s)
iPhone6s 6.8
iPhone8 4.0
iPhone11Pro 2.0
iPad 2.9
PC 2.1

Test2

Image resolution: 3000*3328

Device Time(s)
iPhone6s 129.2
iPhone8 73.5
iPhone11Pro 18.8
iPad 49.2
PC 37.5

Evolution

Device: iPad Image resolution: 3000*3328

Milestone Time(s) RAM usage(GB)
Before using upconv models 141.7 1.86
After using upconv models 63.6 1.28
After adding pipeline on output 56.8 1.28
After adding pipeline on prediction 49.2 0.38
Pure MPSCNN implementation* 29.6 1.06

*: With crop size of 384 and double command buffers.

Demo

waifu2x-ios's People

Contributors

imxieyi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.