Pytorch and Torch testing code of CartoonGAN

Overview

CartoonGAN-Test-Pytorch-Torch

Pytorch and Torch testing code of CartoonGAN [Chen et al., CVPR18]. With the released pretrained models by the authors, I made these simple scripts for a quick test.

Getting started

  • Linux
  • NVIDIA GPU
  • Pytorch 0.3
  • Torch
git clone https://github.com/Yijunmaverick/CartoonGAN-Test-Pytorch-Torch
cd CartoonGAN-Test-Pytorch-Torch

Pytorch

The original pretrained models are Torch nngraph models, which cannot be loaded in Pytorch through load_lua. So I manually copy the weights (bias) layer by layer and convert them to .pth models.

  • Download the converted models:
sh pretrained_model/download_pth.sh
  • For testing:
python test.py --input_dir YourImgDir --style Hosoda --gpu 0

Torch

Working with the original models in Torch is also fine. I just convert the weights (bias) in their models from CudaTensor to FloatTensor so that cudnn is not required for loading models.

  • Download the converted models:
sh pretrained_model/download_t7.sh
  • For testing:
th test.lua -input_dir YourImgDir -style Hosoda -gpu 0

Examples (Left: input, Right: output)

Note

  • The training code should be similar to the popular GAN-based image-translation frameworks and thus is not included here.

Acknowledgement

You might also like...
Automatic number plate recognition using tech:  Yolo, OCR, Scene text detection, scene text recognation, flask, torch
Automatic number plate recognition using tech: Yolo, OCR, Scene text detection, scene text recognation, flask, torch

Automatic Number Plate Recognition Automatic Number Plate Recognition (ANPR) is the process of reading the characters on the plate with various optica

Image Restoration Toolbox (PyTorch). Training and testing codes for DPIR, USRNet, DnCNN, FFDNet, SRMD, DPSR, BSRGAN, SwinIR
Image Restoration Toolbox (PyTorch). Training and testing codes for DPIR, USRNet, DnCNN, FFDNet, SRMD, DPSR, BSRGAN, SwinIR

Image Restoration Toolbox (PyTorch). Training and testing codes for DPIR, USRNet, DnCNN, FFDNet, SRMD, DPSR, BSRGAN, SwinIR

Static-test - A playground to play with ideas related to testing the comparability of the code

Static test playground ⚠️ The code is just an experiment. Compiles and runs on U

This is the official source code for SLATE. We provide the code for the model, the training code, and a dataset loader for the 3D Shapes dataset. This code is implemented in Pytorch.

SLATE This is the official source code for SLATE. We provide the code for the model, the training code and a dataset loader for the 3D Shapes dataset.

An image base contains 490 images for learning (400 cars and 90 boats), and another 21 images for testingAn image base contains 490 images for learning (400 cars and 90 boats), and another 21 images for testing
An image base contains 490 images for learning (400 cars and 90 boats), and another 21 images for testingAn image base contains 490 images for learning (400 cars and 90 boats), and another 21 images for testing

SVM Données Une base d’images contient 490 images pour l’apprentissage (400 voitures et 90 bateaux), et encore 21 images pour fait des tests. Prétrait

This is the official repo for TransFill:  Reference-guided Image Inpainting by Merging Multiple Color and Spatial Transformations at CVPR'21. According to some product reasons, we are not planning to release the training/testing codes and models. However, we will release the dataset and the scripts to prepare the dataset.
A set of tools for creating and testing machine learning features, with a scikit-learn compatible API

Feature Forge This library provides a set of tools that can be useful in many machine learning applications (classification, clustering, regression, e

Implements the training, testing and editing tools for
Implements the training, testing and editing tools for "Pluralistic Image Completion"

Pluralistic Image Completion ArXiv | Project Page | Online Demo | Video(demo) This repository implements the training, testing and editing tools for "

A simple program for training and testing vit

Vit This is a simple program for training and testing vit. Key requirements: torch, torchvision and timm. Dataset I put 5 categories of the cub classi

Comments
  • Produce Larger Output Image

    Produce Larger Output Image

    Hi,

    Is it possible to produce larger output images? Currently, it seems the outputs are around 450x300. I tried adding a --load_size 1024 option but it returns with " TypeError: can't multiply sequence by non-int of type 'float' " . Would you happen to know how to generate larger images around 1024x1024? Thanks.

    opened by kyung645 6
  • Output error, sorry i'm new on this python language

    Output error, sorry i'm new on this python language

    Any idea how to fix it?

    (base) C:\Users\anton>D:\DFL\Anaconda\CartoonGAN-Pytorch-master\test.py Traceback (most recent call last): File "D:\DFL\Anaconda\CartoonGAN-Pytorch-master\test.py", line 25, in shutil.rmtree(opt.output_dir) File "D:\DFL\Anaconda\lib\shutil.py", line 500, in rmtree return _rmtree_unsafe(path, onerror) File "D:\DFL\Anaconda\lib\shutil.py", line 382, in _rmtree_unsafe onerror(os.listdir, path, sys.exc_info()) File "D:\DFL\Anaconda\lib\shutil.py", line 380, in _rmtree_unsafe names = os.listdir(path) FileNotFoundError: [WinError 3] The system cannot find the path specified: './output_lcy'

    opened by metantonio 0
  • Results not good for other images

    Results not good for other images

    @Yijunmaverick I tried the model on my local i3 CPU and could reproduce the results for the images already given in the code. However when I present some random images from my desktop the results arent good.

    Any reason why this might be happening?

    opened by sagar1garg 3
  • Commercial Use Allowed?

    Commercial Use Allowed?

    Hi, I was just kindly wondering if I could use an image that is converted to cartoon style using your model in a commercial work, like a background image of a poster or a game? Thanks a lot!

    opened by ja67 1
Owner
Yijun Li
人生自是有情痴,此恨不关风与月
Yijun Li
Pytorch Implementations of large number classical backbone CNNs, data enhancement, torch loss, attention, visualization and some common algorithms.

Torch-template-for-deep-learning Pytorch implementations of some **classical backbone CNNs, data enhancement, torch loss, attention, visualization and

Li Shengyan 270 Dec 31, 2022
Torch-mutable-modules - Use in-place and assignment operations on PyTorch module parameters with support for autograd

Torch Mutable Modules Use in-place and assignment operations on PyTorch module p

Kento Nishi 7 Jun 6, 2022
Torch-ngp - A pytorch implementation of the hash encoder proposed in instant-ngp

HashGrid Encoder (WIP) A pytorch implementation of the HashGrid Encoder from ins

hawkey 1k Jan 1, 2023
Sharpened cosine similarity torch - A Sharpened Cosine Similarity layer for PyTorch

Sharpened Cosine Similarity A layer implementation for PyTorch Install At your c

Brandon Rohrer 203 Nov 30, 2022
A machine learning library for spiking neural networks. Supports training with both torch and jax pipelines, and deployment to neuromorphic hardware.

Rockpool Rockpool is a Python package for developing signal processing applications with spiking neural networks. Rockpool allows you to build network

SynSense 21 Dec 14, 2022
Implements Stacked-RNN in numpy and torch with manual forward and backward functions

Recurrent Neural Networks Implements simple recurrent network and a stacked recurrent network in numpy and torch respectively. Both flavours implement

Vishal R 1 Nov 16, 2021
Simple torch.nn.module implementation of Alias-Free-GAN style filter and resample

Alias-Free-Torch Simple torch module implementation of Alias-Free GAN. This repository including Alias-Free GAN style lowpass sinc filter @filter.py A

이준혁(Junhyeok Lee) 64 Dec 22, 2022
A torch.Tensor-like DataFrame library supporting multiple execution runtimes and Arrow as a common memory format

TorchArrow (Warning: Unstable Prototype) This is a prototype library currently under heavy development. It does not currently have stable releases, an

Facebook Research 536 Jan 6, 2023
Torch-based tool for quantizing high-dimensional vectors using additive codebooks

Trainable multi-codebook quantization This repository implements a utility for use with PyTorch, and ideally GPUs, for training an efficient quantizer

Daniel Povey 41 Jan 7, 2023
Torch implementation of "Enhanced Deep Residual Networks for Single Image Super-Resolution"

NTIRE2017 Super-resolution Challenge: SNU_CVLab Introduction This is our project repository for CVPR 2017 Workshop (2nd NTIRE). We, Team SNU_CVLab, (B

Bee Lim 625 Dec 30, 2022