Struct stable_diffusion_api::Txt2ImgRequest

source ·
pub struct Txt2ImgRequest {
Show 41 fields pub enable_hr: Option<bool>, pub denoising_strength: Option<f64>, pub firstphase_width: Option<u32>, pub firstphase_height: Option<u32>, pub hr_scale: Option<f64>, pub hr_upscaler: Option<String>, pub hr_second_pass_steps: Option<u32>, pub hr_resize_x: Option<u32>, pub hr_resize_y: 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 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 a text to image request.

Fields§

§enable_hr: Option<bool>

Whether to enable high resolution mode.

§denoising_strength: Option<f64>

Strength of denoising applied to the image.

§firstphase_width: Option<u32>

Width of the image in the first phase.

§firstphase_height: Option<u32>

Height of the image in the first phase.

§hr_scale: Option<f64>

Scale factor for high resolution mode.

§hr_upscaler: Option<String>

Upscaler used in high resolution mode.

§hr_second_pass_steps: Option<u32>

Number of steps in the second pass of high resolution mode.

§hr_resize_x: Option<u32>

Width of the image after resizing in high resolution mode.

§hr_resize_y: Option<u32>

Height of the image after resizing in high resolution mode.

§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 for generating the image.

§subseed: Option<i64>

Subseed for generating the image.

§subseed_strength: Option<u32>

Strength of subseed.

§seed_resize_from_h: Option<i32>

Height of the seed image.

§seed_resize_from_w: Option<i32>

Width of the seed image.

§sampler_name: Option<String>

Name of the sampler.

§batch_size: Option<u32>

Batch size used in generating images.

§n_iter: Option<u32>

Number of images to generate per batch.

§steps: Option<u32>

Number of steps.

§cfg_scale: Option<f64>

CFG scale factor.

§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 to use tiling mode in 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 text 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>

Noise value.

§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 for the script.

§sampler_index: Option<String>

Index of the sampler.

§script_name: Option<String>

Name of the script.

§send_images: Option<bool>

Whether to send the generated images.

§save_images: Option<bool>

Whether to send the generated images.

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

Scripts to always run.

Implementations§

source§

impl Txt2ImgRequest

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 = Txt2ImgRequest::default();
req.with_prompt("A blue sky with green grass".to_string());
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 = Txt2ImgRequest::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 = Txt2ImgRequest::default();
req.with_style("cubism".to_string());
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 = Txt2ImgRequest::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 = Txt2ImgRequest::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 = Txt2ImgRequest::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 = Txt2ImgRequest::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 = Txt2ImgRequest::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 = Txt2ImgRequest::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 = Txt2ImgRequest::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 = Txt2ImgRequest::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 = Txt2ImgRequest::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 = Txt2ImgRequest::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 = Txt2ImgRequest::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 = Txt2ImgRequest::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 = Txt2ImgRequest::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 Txt2ImgRequest containing the settings to merge.

Trait Implementations§

source§

impl Clone for Txt2ImgRequest

source§

fn clone(&self) -> Txt2ImgRequest

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 Txt2ImgRequest

source§

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

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

impl Default for Txt2ImgRequest

source§

fn default() -> Txt2ImgRequest

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

impl<'de> Deserialize<'de> for Txt2ImgRequest

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 Txt2ImgRequest

source§

fn eq(&self, other: &Txt2ImgRequest) -> 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 Txt2ImgRequest

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 Txt2ImgRequest

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>,