Skip to content
This repository has been archived by the owner on Oct 28, 2023. It is now read-only.

Inpaint using other image as example runtime error #165

Open
MassimilianoBiancucci opened this issue Feb 1, 2022 · 0 comments
Open

Inpaint using other image as example runtime error #165

MassimilianoBiancucci opened this issue Feb 1, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@MassimilianoBiancucci
Copy link

MassimilianoBiancucci commented Feb 1, 2022

I'm trying to use the library directly without the CLI interface.
I'm trying the impainting example as explained inside the library in a comment over inpaint_example() method, below the cited comment:

    /// Inpaints an example. Due to how inpainting works, a size must also be
    /// provided, as all examples, as well as the inpaint mask, must be the same
    /// size as each other, as well as the final output image. Using
    /// `resize_input` or `output_size` is ignored if this method is called.
    ///
    /// To prevent sampling from the example, you can specify
    /// `SamplingMethod::Ignore` with `Example::set_sample_method`.
    ///
    /// See [`examples/05_inpaint`](https://github.com/EmbarkStudios/texture-synthesis/tree/main/lib/examples/05_inpaint.rs)
    ///
    /// # Examples
    ///
    /// ```no_run
    /// let tex_synth = texture_synthesis::Session::builder()
    ///     .add_examples(&[&"imgs/1.jpg", &"imgs/3.jpg"])
    ///     .inpaint_example(
    ///         &"masks/inpaint.jpg",
    ///         // This will prevent sampling from the imgs/2.jpg, note that
    ///         // we *MUST* provide at least one example to source from!
    ///         texture_synthesis::Example::builder(&"imgs/2.jpg")
    ///             .set_sample_method(texture_synthesis::SampleMethod::Ignore),
    ///         texture_synthesis::Dims::square(400)
    ///     )
    ///     .build().expect("failed to build session");
    /// ```

using exactly the script in this comment present in the file session.rs:122 I got this error:

thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', lib/src/ms.rs:696:18
stack backtrace:
   0: rust_begin_unwind
             at /rustc/51126be1b260216b41143469086e6e6ee567647e/library/std/src/panicking.rs:577:5
   1: core::panicking::panic_fmt
             at /rustc/51126be1b260216b41143469086e6e6ee567647e/library/core/src/panicking.rs:135:14
   2: core::panicking::panic_bounds_check
             at /rustc/51126be1b260216b41143469086e6e6ee567647e/library/core/src/panicking.rs:77:5
   3: texture_synthesis::ms::Generator::next_pyramid_level
             at ./lib/src/ms.rs:696:18
   4: texture_synthesis::ms::Generator::resolve
             at ./lib/src/ms.rs:797:17
   5: texture_synthesis::session::Session::run
             at ./lib/src/session.rs:55:9

This behavior appears only if I pass texture_synthesis::SampleMethod::Ignore as parameter for set_sample_method() of the example inside the inpaint_example method.
Instead, texture_synthesis::SampleMethod::All and an image as argument work smoothly.

I'm using cargo 1.60.0-nightly (95bb3c92b 2022-01-18)

Anyone know how to solve this bug?

@MassimilianoBiancucci MassimilianoBiancucci added the bug Something isn't working label Feb 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant