Code Monkey home page Code Monkey logo

animearcanegan_mobile's Introduction

Mobile Implementation of AnimeGAN and ArcaneGAN

This project is a wrapper of the base model made by @TachibanaYoshino AnimeGANv2 and the weighted face model by @bryandlee animegan2-pytorch and Arcane model by @Alex Spirin ArcaneGANv0.3.

This project differs from commercial applications such as Prequel because the images are processed locally/natively on the device itself rather than through a cloud server.

Download the apk

Example

Elephant at sunset Elephant at sunset Elephant at sunset
Elephant at sunset Elephant at sunset Elephant at sunset
Original AnimeGAN_Mobile Arcane

Getting Started

Clone the project

git clone https://github.com/juanjaho/animeGAN_Mobile

Create gradle.properties inside android folder at

android/gradle.properties

Copy and paste the following into the gradle.properties:

android.useAndroidX=true
android.enableJetifier=true
FLIPPER_VERSION=0.99.0
MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias

Get the latest models from latest release and add wanted models to

android/app/src/main/assets

Enjoy :)

animearcanegan_mobile's People

Contributors

juanjaho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

animearcanegan_mobile's Issues

Issue when converting Arcane model

Hi, I use your code snippet to convert model
#1
The model from Arcane notebook
https://colab.research.google.com/drive/1r1hhciakk5wHaUn1eJk7TP58fV9mjy_W#scrollTo=vTK5g1xio5oe

from torch.utils.mobile_optimizer import optimize_for_mobile
from torchvision import transforms
from PIL import Image


v = '0.3' 

model_path = f'/content/ArcaneGANv{version}.jit' 

model = torch.jit.load(model_path, map_location="cpu").to('cpu').float().eval().cpu()
image = Image.open("/content/in/5.jpg").convert("RGB")


means = [0.485, 0.456, 0.406]
stds = [0.229, 0.224, 0.225]

img_transforms = transforms.Compose([
    transforms.ToTensor(),
    transforms.Normalize(means, stds)])

with torch.no_grad():
    image = img_transforms(image)[None, ...].cpu().float()
    traced_script_module = torch.jit.trace(model, image)
    optimized_traced_model = optimize_for_mobile(traced_script_module)
    optimized_traced_model._save_for_lite_interpreter(f"/content/drive/MyDrive/FloatArcaneGAN{v}.ptl")

But when I load model in android - I got this issue

com.facebook.jni.CppException: expected scalar type Float but found Half
      
      Debug info for handle(s): -1, was not found.
      
    Exception raised from data_ptr at aten/src/ATen/core/TensorMethods.cpp:18 (most recent call first):

I see that your code converts the model parameters to float, but it is still error.
Can you try again with the Arcane JIT model from the notebook and test the result on android again

What is the purpose of using setTimeout here?

From /components)/ProcessButton.js

What is the purpose of using setTimeout here? Why 500ms? What happens if there is no timeout set?

setTimeout(
() =>
inferImage(
props.selectedImage,
props.outputMax,
props.setSelectedImage,
props.setIsLoadingScreen,
props.selectedModel
),
500,

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.