Giter Club home page Giter Club logo

Comments (7)

hiepph avatar hiepph commented on May 18, 2024 6

I was tired of waiting so I decided writing my own. It takes real_A.jpg as input and generates fake_B.png. You can parse images location as arguments as you need:

    # Load model
    model = create_model(opt)

    # Load image
    real = Image.open('./real_A.jpg')
    preprocess = transforms.Compose([
        transforms.Scale(opt.loadSize),
        transforms.RandomCrop(opt.fineSize),
        transforms.ToTensor(),
        transforms.Normalize((0.5, 0.5, 0.5),
                             (0.5, 0.5, 0.5)),
    ])  

    # Load input
    input_A = preprocess(real).unsqueeze_(0)
    model.input_A.resize_(input_A.size()).copy_(input_A)
    # Forward (model.real_A) through G and produce output (model.fake_B)
    model.test()

    # Convert image to numpy array
    fake = util.tensor2im(model.fake_B.data)
    # Save image
    util.save_image(fake, './fake_B.png')

You can check full example here: https://gist.github.com/hiepph/125ebe0795ca9f5bfac3328b4d604928

And you run it with, for example:

python gen.py --dataroot datasets --name edges2shoes_pix2pix

--dataroot is a must option of base options so I just add a random value here. It matters at --name ---> the name of the trained model.

from pytorch-cyclegan-and-pix2pix.

junyanz avatar junyanz commented on May 18, 2024 2

We will provide a test code for single image after NIPS deadline (May 19). For now, you can create a placeholder image B (e.g. white image).

from pytorch-cyclegan-and-pix2pix.

visonpon avatar visonpon commented on May 18, 2024

i also don't know how to do, did you make any progress? thks @jinfagang
and if there is any advises you can provide? @junyanz @phillipi

from pytorch-cyclegan-and-pix2pix.

hiepph avatar hiepph commented on May 18, 2024

Hi @junyanz, It's already May 23. Did you make any progress for this issue? Maybe a script, if I input an A image, it will produce a B generated image with trained model?

from pytorch-cyclegan-and-pix2pix.

lucasjinreal avatar lucasjinreal commented on May 18, 2024

@hiepph You are just waiting something as I am.

from pytorch-cyclegan-and-pix2pix.

junyanz avatar junyanz commented on May 18, 2024

Thanks, @hiepph for sharing the helpful script. Sorry for the delay. I just uploaded a new script for applying a pre-trained model to a collection of input images. Please use --dataset_mode single and --model test options.

from pytorch-cyclegan-and-pix2pix.

energy888666 avatar energy888666 commented on May 18, 2024

666

from pytorch-cyclegan-and-pix2pix.

Related Issues (20)

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.