A python implementation of Deep-Image-Analogy based on pytorch.

Overview

Deep-Image-Analogy

996.ICU

This project is a python implementation of Deep Image Analogy.https://arxiv.org/abs/1705.01088.

Some results

Requirements

  • python 3

  • opencv3

    If you use anaconda, you can install opencv3 by conda install opencv

  • pytorch

    See pytorch for installation

    Codes in branch "master" works with pytorch 0.4

    Codes in branch "pytorch0.3" works with pytorch 0.3

  • cuda (CPU version is not implemented yet)

Usage (demo)

python main.py --resize_ratio 0.5 --weight 2 --img_A_path data/demo/ava.png --img_BP_path data/demo/mona.png --use_cuda True

Acknowledgments

My project acknowledge the official code Deep-Image-Analogy, pytorch, and another pytorch implementation. Especially, thanks for the authors of this amazing algorithm.

Comments
  • Vgg19.py giving me this error

    Vgg19.py giving me this error

    /home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/VGG19.py:137: UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
      return loss.data[0], grad
    Traceback (most recent call last):
      File "main.py", line 49, in <module>
        img_AP, img_B = analogy(img_A, img_BP, config)
      File "/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/DeepAnalogy.py", line 85, in analogy
        iters=400, display=False)
      File "/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/VGG19.py", line 142, in get_deconvoluted_feat
        noise, stat = lbfgs(f, noise, maxIter=iters, gEps=1e-4, histSize=4, lr=lr, display=display)
      File "/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/lbfgs.py", line 60, in lbfgs
        step, stat_ls, args = linesearch(xk.clone(), z, f, fk, gk.clone(), fkm1,gkm1.clone(), 10000, lr)
      File "/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/lbfgs.py", line 131, in linesearch
        strong_wolfe = (np.abs(phi_prime_alpha) <= -c2 * phi_prime_0)
    RuntimeError: Expected object of type torch.DoubleTensor but found type torch.cuda.DoubleTensor for argument #2 'other'
    
    
    opened by neelkadia-zz 5
  • /libmkl_core.so: invalid ELF header

    /libmkl_core.so: invalid ELF header

    I cannot run it at all! I tried different versions of py-torch and cuda, but I keep getting ELF header error. My OS is latest Ubuntu (just in case).

    ImportError: /data/miniconda3/envs/analogy4/lib/python3.6/site-packages/torch/lib/../../../../libmkl_core.so: invalid ELF header
    
    opened by antonkulaga 4
  • urllib.error.HTTPError: HTTP Error 403: Forbidden

    urllib.error.HTTPError: HTTP Error 403: Forbidden

    Unable to access the model url in VGG19.py. "https://s3-us-west-2.amazonaws.com/jcjohns-models/vgg19-d01eb7cb.pth" seems to be forbidden can you please check or suggest alternate.

    opened by aradhyamathur 2
  • Runtime can be reduced

    Runtime can be reduced

    I use numba instead of parallel computing. The PatchMatch process runtime can be reduced. Python is not good for 'for' loops and numba can solve this. The main time cost is in the LBFGS process.

    opened by shuzy17 0
  •  Expected object of type torch.DoubleTensor but found type torch.cuda.DoubleTensor for argument #2 'other

    Expected object of type torch.DoubleTensor but found type torch.cuda.DoubleTensor for argument #2 'other

    sudo python3 main.py
    libpng warning: iCCP: known incorrect sRGB profile
    patch_size:3; iters:10; rand_d:32
    Done All Iterations
    patch_size:3; iters:10; rand_d:32
    Done All Iterations
    12 20 29
    Traceback (most recent call last):
      File "main.py", line 49, in <module>
        img_AP, img_B = analogy(img_A, img_BP, config)
      File "/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/DeepAnalogy.py", line 85, in analogy
        iters=400, display=False)
      File "/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/VGG19.py", line 142, in get_deconvoluted_feat
        noise, stat = lbfgs(f, noise, maxIter=iters, gEps=1e-4, histSize=4, lr=lr, display=display)
      File "/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/lbfgs.py", line 60, in lbfgs
        step, stat_ls, args = linesearch(xk.clone(), z, f, fk, gk.clone(), fkm1,gkm1.clone(), 10000, lr)
      File "/home/kadia/Documents/Deep-Image-Analogy-PyTorch-master/lbfgs.py", line 131, in linesearch
        strong_wolfe = torch.DoubleTensor(np.abs(phi_prime_alpha) <= -c2 * phi_prime_0)
    RuntimeError: Expected object of type torch.DoubleTensor but found type torch.cuda.DoubleTensor for argument #2 'other'
    
    

    @Ben-Louis Can you help me in this?

    opened by neelkadia-zz 0
  • Differences from my implementation

    Differences from my implementation

    Hi,

    I maintain my own version https://github.com/Ben-Louis/Deep-Image-Analogy-PyTorch of this paper, but I was unable to get results close to the paper.

    However, your results match almost perfectly. Could you tell me if there is anything different that I am doing, or I should try out ?

    opened by harveyslash 3
  • Double check with run-time

    Double check with run-time

    Hi, thanks for this great pytorch implementation. I run the code for the demo image pair on GPU and it takes about 40min. The result is good. Just double check, is my run-time close to yours?

    opened by Yijunmaverick 6
  • Adam vs lbfgs

    Adam vs lbfgs

    Hey, just got this running. My test case is:

    image

    to:

    image

    Using weight 2. Testing with weight 3 now. A couple questions for you as I'm relatively new to ML.

    I notice that Harvey Slash made some modifications, moving to adam optimizer for example. Is there a reason you stuck with lbfgs? Would it be worth attempting a few of his changes?

    This is very fun, thanks for releasing it. Any tips are much appreciated.

    opened by natew 3
Owner
Peng Lu
Peng Lu
A pytorch-based deep learning framework for multi-modal 2D/3D medical image segmentation

A 3D multi-modal medical image segmentation library in PyTorch We strongly believe in open and reproducible deep learning research. Our goal is to imp

Adaloglou Nikolas 1.2k Dec 27, 2022
PyTorch implementation of the Deep SLDA method from our CVPRW-2020 paper "Lifelong Machine Learning with Deep Streaming Linear Discriminant Analysis"

Lifelong Machine Learning with Deep Streaming Linear Discriminant Analysis This is a PyTorch implementation of the Deep Streaming Linear Discriminant

Tyler Hayes 41 Dec 25, 2022
šŸ§  A PyTorch implementation of 'Deep CORAL: Correlation Alignment for Deep Domain Adaptation.', ECCV 2016

Deep CORAL A PyTorch implementation of 'Deep CORAL: Correlation Alignment for Deep Domain Adaptation. B Sun, K Saenko, ECCV 2016' Deep CORAL can learn

Andy Hsu 200 Dec 25, 2022
Official PyTorch implementation of the paper "Deep Constrained Least Squares for Blind Image Super-Resolution", CVPR 2022.

Deep Constrained Least Squares for Blind Image Super-Resolution [Paper] This is the official implementation of 'Deep Constrained Least Squares for Bli

MEGVII Research 141 Dec 30, 2022
Official pytorch implementation of paper "Image-to-image Translation via Hierarchical Style Disentanglement".

HiSD: Image-to-image Translation via Hierarchical Style Disentanglement Official pytorch implementation of paper "Image-to-image Translation

null 364 Dec 14, 2022
This is the PyTorch implementation of GANs Nā€™ Roses: Stable, Controllable, Diverse Image to Image Translation

Official PyTorch repo for GAN's N' Roses. Diverse im2im and vid2vid selfie to anime translation.

null 1.1k Jan 1, 2023
Accurate 3D Face Reconstruction with Weakly-Supervised Learning: From Single Image to Image Set (CVPRW 2019). A PyTorch implementation.

Accurate 3D Face Reconstruction with Weakly-Supervised Learning: From Single Image to Image Set ā€”ā€” PyTorch implementation This is an unofficial offici

Sicheng Xu 833 Dec 28, 2022
PyTorch implementation of "Image-to-Image Translation Using Conditional Adversarial Networks".

pix2pix-pytorch PyTorch implementation of Image-to-Image Translation Using Conditional Adversarial Networks. Based on pix2pix by Phillip Isola et al.

mrzhu 383 Dec 17, 2022
U-Net Implementation: Convolutional Networks for Biomedical Image Segmentation" using the Carvana Image Masking Dataset in PyTorch

U-Net Implementation By Christopher Ley This is my interpretation and implementation of the famous paper "U-Net: Convolutional Networks for Biomedical

Christopher Ley 1 Jan 6, 2022
A general framework for deep learning experiments under PyTorch based on pytorch-lightning

torchx Torchx is a general framework for deep learning experiments under PyTorch based on pytorch-lightning. TODO list gan-like training wrapper text

Yingtian Liu 6 Mar 17, 2022
Official implementation of deep Gaussian process (DGP)-based multi-speaker speech synthesis with PyTorch.

Multi-speaker DGP This repository provides official implementation of deep Gaussian process (DGP)-based multi-speaker speech synthesis with PyTorch. O

sarulab-speech 24 Sep 7, 2022
Implementation of "A Deep Learning Loss Function based on Auditory Power Compression for Speech Enhancement" by pytorch

This repository is used to suspend the results of our paper "A Deep Learning Loss Function based on Auditory Power Compression for Speech Enhancement"

ScorpioMiku 19 Sep 30, 2022
Pytorch implementation of "MOSNet: Deep Learning based Objective Assessment for Voice Conversion"

MOSNet pytorch implementation of "MOSNet: Deep Learning based Objective Assessment for Voice Conversion" https://arxiv.org/abs/1904.08352 Dependency L

null 9 Nov 18, 2022
Image-popularity-score - A novel deep regression method for image scoring.

Image-popularity-score - A novel deep regression method for image scoring.

Shoaib ahmed 1 Dec 26, 2021
PyTorch implementation of CVPR 2020 paper (Reference-Based Sketch Image Colorization using Augmented-Self Reference and Dense Semantic Correspondence) and pre-trained model on ImageNet dataset

Reference-Based-Sketch-Image-Colorization-ImageNet This is a PyTorch implementation of CVPR 2020 paper (Reference-Based Sketch Image Colorization usin

Yuzhi ZHAO 11 Jul 28, 2022
PyTorch implementation of paper "IBRNet: Learning Multi-View Image-Based Rendering", CVPR 2021.

IBRNet: Learning Multi-View Image-Based Rendering PyTorch implementation of paper "IBRNet: Learning Multi-View Image-Based Rendering", CVPR 2021. IBRN

Google Interns 371 Jan 3, 2023
Pytorch implementation of Make-A-Scene: Scene-Based Text-to-Image Generation with Human Priors

Make-A-Scene - PyTorch Pytorch implementation (inofficial) of Make-A-Scene: Scene-Based Text-to-Image Generation with Human Priors (https://arxiv.org/

Casual GAN Papers 259 Dec 28, 2022
Code of U2Fusion: a unified unsupervised image fusion network for multiple image fusion tasks, including multi-modal, multi-exposure and multi-focus image fusion.

U2Fusion Code of U2Fusion: a unified unsupervised image fusion network for multiple image fusion tasks, including multi-modal (VIS-IR, medical), multi

Han Xu 129 Dec 11, 2022