Struct stable_diffusion_api::Img2ImgRequest

source ·
pub struct Img2ImgRequest {
Show 44 fields pub init_images: Option<Vec<String>>, pub resize_mode: Option<u32>, pub denoising_strength: Option<f64>, pub image_cfg_scale: Option<u32>, pub mask: Option<String>, pub mask_blur: Option<u32>, pub inpainting_fill: Option<u32>, pub inpaint_full_res: Option<bool>, pub inpaint_full_res_padding: Option<u32>, pub inpainting_mask_invert: Option<u32>, pub initial_noise_multiplier: Option<u32>, pub prompt: Option<String>, pub styles: Option<Vec<String>>, pub seed: Option<i64>, pub subseed: Option<i64>, pub subseed_strength: Option<u32>, pub seed_resize_from_h: Option<i32>, pub seed_resize_from_w: Option<i32>, pub sampler_name: Option<String>, pub batch_size: Option<u32>, pub n_iter: Option<u32>, pub steps: Option<u32>, pub cfg_scale: Option<f64>, pub width: Option<u32>, pub height: Option<u32>, pub restore_faces: Option<bool>, pub tiling: Option<bool>, pub do_not_save_samples: Option<bool>, pub do_not_save_grid: Option<bool>, pub negative_prompt: Option<String>, pub eta: Option<u32>, pub s_churn: Option<f64>, pub s_tmax: Option<f64>, pub s_tmin: Option<f64>, pub s_noise: Option<f64>, pub override_settings: Option<HashMap<String, Value>>, pub override_settings_restore_afterwards: Option<bool>, pub script_args: Option<Vec<Value>>, pub sampler_index: Option<String>, pub include_init_images: Option<bool>, pub script_name: Option<String>, pub send_images: Option<bool>, pub save_images: Option<bool>, pub alwayson_scripts: Option<HashMap<String, Value>>,
}
Expand description

Struct representing an image to image request.

Fields§

§init_images: Option<Vec<String>>

Initial images.

§resize_mode: Option<u32>

Resize mode.

§denoising_strength: Option<f64>

Strength of denoising applied to the image.

§image_cfg_scale: Option<u32>

CFG scale.

§mask: Option<String>

Mask.

§mask_blur: Option<u32>

Blur to apply to the mask.

§inpainting_fill: Option<u32>

Amount of inpainting to apply.

§inpaint_full_res: Option<bool>

Whether to perform inpainting at full resolution.

§inpaint_full_res_padding: Option<u32>

Padding to apply when performing inpainting at full resolution.

§inpainting_mask_invert: Option<u32>

Whether to invert the inpainting mask.

§initial_noise_multiplier: Option<u32>

Initial noise multiplier.

§prompt: Option<String>

Text prompt for generating the image.

§styles: Option<Vec<String>>

List of style prompts for generating the image.

§seed: Option<i64>

Seed.

§subseed: Option<i64>

Subseed.

§subseed_strength: Option<u32>

Strength of the subseed.

§seed_resize_from_h: Option<i32>

Height to resize the seed image from.

§seed_resize_from_w: Option<i32>

Width to resize the seed image from.

§sampler_name: Option<String>

Name of the sampler.

§batch_size: Option<u32>

Batch size.

§n_iter: Option<u32>

Number of iterations.

§steps: Option<u32>

Number of steps.

§cfg_scale: Option<f64>

CFG scale.

§width: Option<u32>

Width of the generated image.

§height: Option<u32>

Height of the generated image.

§restore_faces: Option<bool>

Whether to restore faces in the generated image.

§tiling: Option<bool>

Whether tiling for the generated image.

§do_not_save_samples: Option<bool>

Whether to save samples when generating multiple images.

§do_not_save_grid: Option<bool>

Whether to save the grid when generating multiple images.

§negative_prompt: Option<String>

Negative prompt.

§eta: Option<u32>

Eta value.

§s_churn: Option<f64>

Churn value.

§s_tmax: Option<f64>

Maximum temperature value.

§s_tmin: Option<f64>

Minimum temperature value.

§s_noise: Option<f64>

Amount of noise.

§override_settings: Option<HashMap<String, Value>>

Settings to override when generating the image.

§override_settings_restore_afterwards: Option<bool>

Whether to restore the settings after generating the image.

§script_args: Option<Vec<Value>>

Arguments to pass to the script.

§sampler_index: Option<String>

Index of the sampler.

§include_init_images: Option<bool>

Whether to include initial images in the output.

§script_name: Option<String>

Name of the script.

§send_images: Option<bool>

Whether to send the generated images.

§save_images: Option<bool>

Whether to save the generated images.

§alwayson_scripts: Option<HashMap<String, Value>>

Scripts to always run.

Implementations§

source§

impl Img2ImgRequest

source

pub fn with_prompt(&mut self, prompt: String) -> &mut Self

Adds a prompt to the request.

§Arguments
  • prompt - A String representing the prompt to be used for image generation.
§Example
let mut req = Img2ImgRequest::default();
req.with_prompt("A blue sky with green grass".to_string());
source

pub fn with_image<T>(&mut self, image: T) -> &mut Self
where T: AsRef<[u8]>,

Adds a single image to the request.

§Arguments
  • image - array bytes of the image to be added.
§Examples
use std::fs;
let mut req = Img2ImgRequest::default();
let image_data = fs::read("path/to/image.jpg").unwrap();
req.with_image(image_data);
source

pub fn with_images<T>(&mut self, images: Vec<T>) -> &mut Self
where T: AsRef<[u8]>,

Adds multiple images to the request.

§Arguments
  • images - A vector of byte arrays that represents the images to be added.
§Examples
use std::fs;
let mut req = Img2ImgRequest::default();
let image_data1 = fs::read("path/to/image1.jpg").unwrap();
let image_data2 = fs::read("path/to/image2.jpg").unwrap();
req.with_images(vec![image_data1, image_data2]);
source

pub fn with_styles(&mut self, styles: Vec<String>) -> &mut Self

Adds styles to the request.

§Arguments
  • styles - A vector of Strings representing the styles to be used for image generation.
§Examples
let mut req = Img2ImgRequest::default();
req.with_styles(vec!["cubism".to_string(), "impressionism".to_string()]);
source

pub fn with_style(&mut self, style: String) -> &mut Self

Adds a style to the request.

§Arguments
  • style - A String representing the style to be used for image generation.
§Examples
let mut req = Img2ImgRequest::default();
req.with_style("cubism".to_string());
source

pub fn with_denoising_strength(&mut self, denoising_strength: f64) -> &mut Self

Sets the denoising strength for image generation.

§Arguments
  • denoising_strength - A f64 value representing the denoising strength parameter.
§Examples
let mut req = Img2ImgRequest::default();
req.with_denoising_strength(0.4);
source

pub fn with_seed(&mut self, seed: i64) -> &mut Self

Sets the seed for random number generation.

§Arguments
  • seed - An i64 value representing the seed for random number generation. Set to -1 to randomize.
§Example
let mut req = Img2ImgRequest::default();
req.with_seed(12345);
source

pub fn with_subseed(&mut self, subseed: i64) -> &mut Self

Sets the subseed for random number generation.

§Arguments
  • subseed - An i64 value representing the subseed for random number generation. Set to -1 to randomize.
§Example
let mut req = Img2ImgRequest::default();
req.with_subseed(12345);
source

pub fn with_subseed_strength(&mut self, subseed_strength: u32) -> &mut Self

Sets the strength of the subseed parameter for image generation.

§Arguments
  • subseed_strength - A u32 value representing the strength of the subseed parameter.
§Example
let mut req = Img2ImgRequest::default();
req.with_subseed_strength(5);
source

pub fn with_sampler_name(&mut self, sampler_name: String) -> &mut Self

Sets the sampler name for image generation.

§Arguments
  • sampler_name - A String representing the sampler name to be used.
§Examples
let mut req = Img2ImgRequest::default();
req.with_sampler_name("Euler".to_string());
source

pub fn with_batch_size(&mut self, batch_size: u32) -> &mut Self

Sets the batch size for image generation.

§Arguments
  • batch_size - A u32 value representing the batch size to be used.
§Examples
let mut req = Img2ImgRequest::default();
req.with_batch_size(16);
source

pub fn with_n_iter(&mut self, n_iter: u32) -> &mut Self

Sets the number of iterations for image generation.

§Arguments
  • n_iter - A u32 value representing the number of iterations to run for image generation.
§Examples
let mut req = Img2ImgRequest::default();
req.with_n_iter(1000);
source

pub fn with_steps(&mut self, steps: u32) -> &mut Self

Sets the number of steps for image generation.

§Arguments
  • steps - A u32 value representing the number of steps for image generation.
§Examples
let mut req = Img2ImgRequest::default();
req.with_steps(50);
source

pub fn with_cfg_scale(&mut self, cfg_scale: f64) -> &mut Self

Sets the cfg scale for image generation.

§Arguments
  • cfg_scale - A f64 value representing the cfg scale parameter.
§Examples
let mut req = Img2ImgRequest::default();
req.with_cfg_scale(0.7);
source

pub fn with_width(&mut self, width: u32) -> &mut Self

Sets the width for image generation.

§Arguments
  • width - A u32 value representing the image width.
§Examples
let mut req = Img2ImgRequest::default();
req.with_width(512);
source

pub fn with_height(&mut self, height: u32) -> &mut Self

Sets the height for image generation.

§Arguments
  • height - A u32 value representing the image height.
§Examples
let mut req = Img2ImgRequest::default();
req.with_height(512);
source

pub fn with_restore_faces(&mut self, restore_faces: bool) -> &mut Self

Enable or disable face restoration.

§Arguments
  • restore_faces - A bool value to enable or disable face restoration.
§Examples
let mut req = Img2ImgRequest::default();
req.with_restore_faces(true);
source

pub fn with_tiling(&mut self, tiling: bool) -> &mut Self

Enable or disable image tiling.

§Arguments
  • tiling - A bool value to enable or disable tiling.
§Examples
let mut req = Img2ImgRequest::default();
req.with_tiling(true);
source

pub fn with_negative_prompt(&mut self, negative_prompt: String) -> &mut Self

Adds a negative prompt to the request.

§Arguments
  • negative_prompt - A String representing the negative prompt to be used for image generation.
§Example
let mut req = Img2ImgRequest::default();
req.with_prompt("bad, ugly, worst quality".to_string());
source

pub fn merge(&self, request: Self) -> Self

Merges the given settings with the request’s settings.

§Arguments
  • request - A Img2ImgRequest containing the settings to merge.

Trait Implementations§

source§

impl Clone for Img2ImgRequest

source§

fn clone(&self) -> Img2ImgRequest

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Img2ImgRequest

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Img2ImgRequest

source§

fn default() -> Img2ImgRequest

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Img2ImgRequest

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for Img2ImgRequest

source§

fn eq(&self, other: &Img2ImgRequest) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Img2ImgRequest

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for Img2ImgRequest

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,