#[allow(unused_imports)]
use crate::prelude::*;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[allow(unused_imports)]
use std::collections::HashMap;
#[cfg(any(
feature = "endpoints",
feature = "endpoints_fal-ai",
feature = "endpoints_fal-ai_stable-diffusion-v35-large"
))]
#[cfg_attr(
docsrs,
doc(cfg(any(
feature = "endpoints",
feature = "endpoints_fal-ai",
feature = "endpoints_fal-ai_stable-diffusion-v35-large"
)))
)]
pub mod image_to_image;
#[cfg(any(
feature = "endpoints",
feature = "endpoints_fal-ai",
feature = "endpoints_fal-ai_stable-diffusion-v35-large"
))]
#[cfg_attr(
docsrs,
doc(cfg(any(
feature = "endpoints",
feature = "endpoints_fal-ai",
feature = "endpoints_fal-ai_stable-diffusion-v35-large"
)))
)]
pub mod inpaint;
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ControlNet {
/// The scale of the control net weight. This is used to scale the control net weight
/// before merging it with the base model.
#[serde(skip_serializing_if = "Option::is_none")]
pub conditioning_scale: Option<f64>,
/// URL of the image to be used as the control image.
pub control_image_url: String,
/// The percentage of the image to end applying the controlnet in terms of the total timesteps.
#[serde(skip_serializing_if = "Option::is_none")]
pub end_percentage: Option<f64>,
/// URL or the path to the control net weights.
pub path: String,
/// The percentage of the image to start applying the controlnet in terms of the total timesteps.
#[serde(skip_serializing_if = "Option::is_none")]
pub start_percentage: Option<f64>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct HTTPValidationError {
#[serde(skip_serializing_if = "Option::is_none")]
pub detail: Option<Vec<Option<ValidationError>>>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct IPAdapter {
/// Path to the Image Encoder for the IP-Adapter, for example 'openai/clip-vit-large-patch14'
pub image_encoder_path: String,
/// Subfolder in which the image encoder weights exist.
#[serde(skip_serializing_if = "Option::is_none")]
pub image_encoder_subfolder: Option<String>,
/// Name of the image encoder.
#[serde(skip_serializing_if = "Option::is_none")]
pub image_encoder_weight_name: Option<String>,
/// URL of Image for IP-Adapter conditioning.
pub image_url: String,
/// URL of the mask for the control image.
#[serde(skip_serializing_if = "Option::is_none")]
pub mask_image_url: Option<String>,
/// Threshold for mask.
#[serde(skip_serializing_if = "Option::is_none")]
pub mask_threshold: Option<f64>,
/// Hugging Face path to the IP-Adapter
pub path: String,
/// Scale for ip adapter.
pub scale: f64,
/// Subfolder in which the ip_adapter weights exist
#[serde(skip_serializing_if = "Option::is_none")]
pub subfolder: Option<String>,
/// Name of the safetensors file containing the ip-adapter weights
#[serde(skip_serializing_if = "Option::is_none")]
pub weight_name: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct Image {
#[serde(skip_serializing_if = "Option::is_none")]
pub content_type: Option<String>,
pub height: i64,
pub url: String,
pub width: i64,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ImageSize {
/// The height of the generated image.
#[serde(skip_serializing_if = "Option::is_none")]
pub height: Option<i64>,
/// The width of the generated image.
#[serde(skip_serializing_if = "Option::is_none")]
pub width: Option<i64>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ImageToImageInput {
/// ControlNet for inference.
#[serde(skip_serializing_if = "Option::is_none")]
pub controlnet: Option<Option<ControlNet>>,
/// If set to true, the safety checker will be enabled.
#[serde(skip_serializing_if = "Option::is_none")]
pub enable_safety_checker: Option<bool>,
/// The CFG (Classifier Free Guidance) scale is a measure of how close you want
/// the model to stick to your prompt when looking for a related image to show you.
#[serde(skip_serializing_if = "Option::is_none")]
pub guidance_scale: Option<f64>,
/// The size of the generated image. Defaults to landscape_4_3 if no controlnet has been passed, otherwise defaults to the size of the controlnet conditioning image.
#[serde(skip_serializing_if = "Option::is_none")]
pub image_size: Option<ImageSizeProperty>,
/// URL of Image for Image-to-Image
/// "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
pub image_url: String,
/// IP-Adapter to use during inference.
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_adapter: Option<Option<IPAdapter>>,
/// The LoRAs to use for the image generation. You can use any number of LoRAs
/// and they will be merged together to generate the final image.
#[serde(skip_serializing_if = "Option::is_none")]
pub loras: Option<Vec<Option<LoraWeight>>>,
/// The negative prompt to use. Use it to address details that you don't want
/// in the image. This could be colors, objects, scenery and even the small details
/// (e.g. moustache, blurry, low resolution).
/// ""
#[serde(skip_serializing_if = "Option::is_none")]
pub negative_prompt: Option<String>,
/// The number of images to generate.
#[serde(skip_serializing_if = "Option::is_none")]
pub num_images: Option<i64>,
/// The number of inference steps to perform.
#[serde(skip_serializing_if = "Option::is_none")]
pub num_inference_steps: Option<i64>,
/// The format of the generated image.
#[serde(skip_serializing_if = "Option::is_none")]
pub output_format: Option<String>,
/// The prompt to generate an image from.
/// "Cat sitting on a bench"
pub prompt: String,
/// The same seed and the same prompt given to the same version of the model
/// will output the same image every time.
#[serde(skip_serializing_if = "Option::is_none")]
pub seed: Option<i64>,
/// Strength for Image-to-Image.
#[serde(skip_serializing_if = "Option::is_none")]
pub strength: Option<f64>,
/// If set to true, the function will wait for the image to be generated and uploaded
/// before returning the response. This will increase the latency of the function but
/// it allows you to get the image directly in the response without going through the CDN.
#[serde(skip_serializing_if = "Option::is_none")]
pub sync_mode: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ImageToImageTurboInput {
/// If set to true, the safety checker will be enabled.
#[serde(skip_serializing_if = "Option::is_none")]
pub enable_safety_checker: Option<bool>,
/// The CFG (Classifier Free Guidance) scale is a measure of how close you want
/// the model to stick to your prompt when looking for a related image to show you.
#[serde(skip_serializing_if = "Option::is_none")]
pub guidance_scale: Option<f64>,
/// The size of the generated image. Defaults to landscape_4_3 if no controlnet has been passed, otherwise defaults to the size of the controlnet conditioning image.
#[serde(skip_serializing_if = "Option::is_none")]
pub image_size: Option<ImageSizeProperty>,
/// URL of Image for Image-to-Image
/// "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
pub image_url: String,
/// The negative prompt to use. Use it to address details that you don't want
/// in the image. This could be colors, objects, scenery and even the small details
/// (e.g. moustache, blurry, low resolution).
/// ""
#[serde(skip_serializing_if = "Option::is_none")]
pub negative_prompt: Option<String>,
/// The number of images to generate.
#[serde(skip_serializing_if = "Option::is_none")]
pub num_images: Option<i64>,
/// The number of inference steps to perform.
#[serde(skip_serializing_if = "Option::is_none")]
pub num_inference_steps: Option<i64>,
/// The format of the generated image.
#[serde(skip_serializing_if = "Option::is_none")]
pub output_format: Option<String>,
/// The prompt to generate an image from.
/// "Cat sitting on a bench"
pub prompt: String,
/// The same seed and the same prompt given to the same version of the model
/// will output the same image every time.
#[serde(skip_serializing_if = "Option::is_none")]
pub seed: Option<i64>,
/// Strength for Image-to-Image.
#[serde(skip_serializing_if = "Option::is_none")]
pub strength: Option<f64>,
/// If set to true, the function will wait for the image to be generated and uploaded
/// before returning the response. This will increase the latency of the function but
/// it allows you to get the image directly in the response without going through the CDN.
#[serde(skip_serializing_if = "Option::is_none")]
pub sync_mode: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct InpaintInput {
/// ControlNet for inference.
#[serde(skip_serializing_if = "Option::is_none")]
pub controlnet: Option<Option<ControlNet>>,
/// If set to true, the safety checker will be enabled.
#[serde(skip_serializing_if = "Option::is_none")]
pub enable_safety_checker: Option<bool>,
/// The CFG (Classifier Free Guidance) scale is a measure of how close you want
/// the model to stick to your prompt when looking for a related image to show you.
#[serde(skip_serializing_if = "Option::is_none")]
pub guidance_scale: Option<f64>,
/// The size of the generated image. Defaults to landscape_4_3 if no controlnet has been passed, otherwise defaults to the size of the controlnet conditioning image.
#[serde(skip_serializing_if = "Option::is_none")]
pub image_size: Option<ImageSizeProperty>,
/// URL of Image for inpainting
/// "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
pub image_url: String,
/// IP-Adapter to use during inference.
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_adapter: Option<Option<IPAdapter>>,
/// The LoRAs to use for the image generation. You can use any number of LoRAs
/// and they will be merged together to generate the final image.
#[serde(skip_serializing_if = "Option::is_none")]
pub loras: Option<Vec<Option<LoraWeight>>>,
/// URL of mask image for inpainting.
/// "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png"
pub mask_image_url: String,
/// The negative prompt to use. Use it to address details that you don't want
/// in the image. This could be colors, objects, scenery and even the small details
/// (e.g. moustache, blurry, low resolution).
/// ""
#[serde(skip_serializing_if = "Option::is_none")]
pub negative_prompt: Option<String>,
/// The number of images to generate.
#[serde(skip_serializing_if = "Option::is_none")]
pub num_images: Option<i64>,
/// The number of inference steps to perform.
#[serde(skip_serializing_if = "Option::is_none")]
pub num_inference_steps: Option<i64>,
/// The format of the generated image.
#[serde(skip_serializing_if = "Option::is_none")]
pub output_format: Option<String>,
/// The prompt to generate an image from.
/// "Tiger sitting on a bench."
pub prompt: String,
/// The same seed and the same prompt given to the same version of the model
/// will output the same image every time.
#[serde(skip_serializing_if = "Option::is_none")]
pub seed: Option<i64>,
/// Strength for Image-to-Image.
#[serde(skip_serializing_if = "Option::is_none")]
pub strength: Option<f64>,
/// If set to true, the function will wait for the image to be generated and uploaded
/// before returning the response. This will increase the latency of the function but
/// it allows you to get the image directly in the response without going through the CDN.
#[serde(skip_serializing_if = "Option::is_none")]
pub sync_mode: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct InpaintTurboInput {
/// If set to true, the safety checker will be enabled.
#[serde(skip_serializing_if = "Option::is_none")]
pub enable_safety_checker: Option<bool>,
/// The CFG (Classifier Free Guidance) scale is a measure of how close you want
/// the model to stick to your prompt when looking for a related image to show you.
#[serde(skip_serializing_if = "Option::is_none")]
pub guidance_scale: Option<f64>,
/// The size of the generated image. Defaults to landscape_4_3 if no controlnet has been passed, otherwise defaults to the size of the controlnet conditioning image.
#[serde(skip_serializing_if = "Option::is_none")]
pub image_size: Option<ImageSizeProperty>,
/// URL of Image for inpainting
/// "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"
pub image_url: String,
/// URL of mask image for inpainting.
/// "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png"
pub mask_image_url: String,
/// The negative prompt to use. Use it to address details that you don't want
/// in the image. This could be colors, objects, scenery and even the small details
/// (e.g. moustache, blurry, low resolution).
/// ""
#[serde(skip_serializing_if = "Option::is_none")]
pub negative_prompt: Option<String>,
/// The number of images to generate.
#[serde(skip_serializing_if = "Option::is_none")]
pub num_images: Option<i64>,
/// The number of inference steps to perform.
#[serde(skip_serializing_if = "Option::is_none")]
pub num_inference_steps: Option<i64>,
/// The format of the generated image.
#[serde(skip_serializing_if = "Option::is_none")]
pub output_format: Option<String>,
/// The prompt to generate an image from.
/// "Tiger sitting on a bench."
pub prompt: String,
/// The same seed and the same prompt given to the same version of the model
/// will output the same image every time.
#[serde(skip_serializing_if = "Option::is_none")]
pub seed: Option<i64>,
/// Strength for Image-to-Image.
#[serde(skip_serializing_if = "Option::is_none")]
pub strength: Option<f64>,
/// If set to true, the function will wait for the image to be generated and uploaded
/// before returning the response. This will increase the latency of the function but
/// it allows you to get the image directly in the response without going through the CDN.
#[serde(skip_serializing_if = "Option::is_none")]
pub sync_mode: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct LoraWeight {
/// URL or the path to the LoRA weights.
pub path: String,
/// The scale of the LoRA weight. This is used to scale the LoRA weight
/// before merging it with the base model.
#[serde(skip_serializing_if = "Option::is_none")]
pub scale: Option<f64>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Output {
/// Whether the generated images contain NSFW concepts.
pub has_nsfw_concepts: Vec<bool>,
/// The generated image files info.
pub images: Vec<Image>,
/// The prompt used for generating the image.
pub prompt: String,
/// Seed of the generated Image. It will be the same value of the one passed in the
/// input or the randomly generated that was used in case none was passed.
pub seed: i64,
pub timings: Timings,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct TextToImageInput {
/// ControlNet for inference.
#[serde(skip_serializing_if = "Option::is_none")]
pub controlnet: Option<Option<ControlNet>>,
/// If set to true, the safety checker will be enabled.
#[serde(skip_serializing_if = "Option::is_none")]
pub enable_safety_checker: Option<bool>,
/// The CFG (Classifier Free Guidance) scale is a measure of how close you want
/// the model to stick to your prompt when looking for a related image to show you.
#[serde(skip_serializing_if = "Option::is_none")]
pub guidance_scale: Option<f64>,
/// The size of the generated image. Defaults to landscape_4_3 if no controlnet has been passed, otherwise defaults to the size of the controlnet conditioning image.
#[serde(skip_serializing_if = "Option::is_none")]
pub image_size: Option<ImageSizeProperty>,
/// IP-Adapter to use during inference.
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_adapter: Option<Option<IPAdapter>>,
/// The LoRAs to use for the image generation. You can use any number of LoRAs
/// and they will be merged together to generate the final image.
#[serde(skip_serializing_if = "Option::is_none")]
pub loras: Option<Vec<Option<LoraWeight>>>,
/// The negative prompt to use. Use it to address details that you don't want
/// in the image. This could be colors, objects, scenery and even the small details
/// (e.g. moustache, blurry, low resolution).
/// ""
#[serde(skip_serializing_if = "Option::is_none")]
pub negative_prompt: Option<String>,
/// The number of images to generate.
#[serde(skip_serializing_if = "Option::is_none")]
pub num_images: Option<i64>,
/// The number of inference steps to perform.
#[serde(skip_serializing_if = "Option::is_none")]
pub num_inference_steps: Option<i64>,
/// The format of the generated image.
#[serde(skip_serializing_if = "Option::is_none")]
pub output_format: Option<String>,
/// The prompt to generate an image from.
/// "A dreamlike Japanese garden in perpetual twilight, bathed in bioluminescent cherry blossoms that emit a soft pink-purple glow. Floating paper lanterns drift lazily through the scene, their warm light creating dancing reflections in a mirror-like koi pond. Ethereal mist weaves between ancient stone pathways lined with glowing mushrooms in pastel blues and purples. A traditional wooden bridge arches gracefully over the water, dusted with fallen petals that sparkle like stardust. The scene is captured through a cinematic lens with perfect bokeh, creating an otherworldly atmosphere. In the background, a crescent moon hangs impossibly large in the sky, surrounded by a sea of stars and auroral wisps in teal and violet. Crystal formations emerge from the ground, refracting the ambient light into rainbow prisms. The entire composition follows the golden ratio, with moody film-like color grading reminiscent of Studio Ghibli, enhanced by volumetric god rays filtering through the luminous foliage. 8K resolution, masterful photography, hyperdetailed, magical realism."
pub prompt: String,
/// The same seed and the same prompt given to the same version of the model
/// will output the same image every time.
#[serde(skip_serializing_if = "Option::is_none")]
pub seed: Option<i64>,
/// If set to true, the function will wait for the image to be generated and uploaded
/// before returning the response. This will increase the latency of the function but
/// it allows you to get the image directly in the response without going through the CDN.
#[serde(skip_serializing_if = "Option::is_none")]
pub sync_mode: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct TextToImageTurboInput {
/// If set to true, the safety checker will be enabled.
#[serde(skip_serializing_if = "Option::is_none")]
pub enable_safety_checker: Option<bool>,
/// The CFG (Classifier Free Guidance) scale is a measure of how close you want
/// the model to stick to your prompt when looking for a related image to show you.
#[serde(skip_serializing_if = "Option::is_none")]
pub guidance_scale: Option<f64>,
/// The size of the generated image. Defaults to landscape_4_3 if no controlnet has been passed, otherwise defaults to the size of the controlnet conditioning image.
#[serde(skip_serializing_if = "Option::is_none")]
pub image_size: Option<ImageSizeProperty>,
/// The negative prompt to use. Use it to address details that you don't want
/// in the image. This could be colors, objects, scenery and even the small details
/// (e.g. moustache, blurry, low resolution).
/// ""
#[serde(skip_serializing_if = "Option::is_none")]
pub negative_prompt: Option<String>,
/// The number of images to generate.
#[serde(skip_serializing_if = "Option::is_none")]
pub num_images: Option<i64>,
/// The number of inference steps to perform.
#[serde(skip_serializing_if = "Option::is_none")]
pub num_inference_steps: Option<i64>,
/// The format of the generated image.
#[serde(skip_serializing_if = "Option::is_none")]
pub output_format: Option<String>,
/// The prompt to generate an image from.
/// "A dreamlike Japanese garden in perpetual twilight, bathed in bioluminescent cherry blossoms that emit a soft pink-purple glow. Floating paper lanterns drift lazily through the scene, their warm light creating dancing reflections in a mirror-like koi pond. Ethereal mist weaves between ancient stone pathways lined with glowing mushrooms in pastel blues and purples. A traditional wooden bridge arches gracefully over the water, dusted with fallen petals that sparkle like stardust. The scene is captured through a cinematic lens with perfect bokeh, creating an otherworldly atmosphere. In the background, a crescent moon hangs impossibly large in the sky, surrounded by a sea of stars and auroral wisps in teal and violet. Crystal formations emerge from the ground, refracting the ambient light into rainbow prisms. The entire composition follows the golden ratio, with moody film-like color grading reminiscent of Studio Ghibli, enhanced by volumetric god rays filtering through the luminous foliage. 8K resolution, masterful photography, hyperdetailed, magical realism."
pub prompt: String,
/// The same seed and the same prompt given to the same version of the model
/// will output the same image every time.
#[serde(skip_serializing_if = "Option::is_none")]
pub seed: Option<i64>,
/// If set to true, the function will wait for the image to be generated and uploaded
/// before returning the response. This will increase the latency of the function but
/// it allows you to get the image directly in the response without going through the CDN.
#[serde(skip_serializing_if = "Option::is_none")]
pub sync_mode: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ValidationError {
pub loc: Vec<serde_json::Value>,
pub msg: String,
#[serde(rename = "type")]
pub ty: String,
}
#[derive(Debug, Serialize, Deserialize, smart_default::SmartDefault)]
#[allow(non_camel_case_types)]
pub enum ImageSizeProperty {
#[default]
ImageSize(ImageSize),
#[serde(rename = "square_hd")]
SquareHd,
#[serde(rename = "square")]
Square,
#[serde(rename = "portrait_4_3")]
Portrait43,
#[serde(rename = "portrait_16_9")]
Portrait169,
#[serde(rename = "landscape_4_3")]
Landscape43,
#[serde(rename = "landscape_16_9")]
Landscape169,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct Timings {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "type")]
pub ty: Option<serde_json::Value>,
}
/// Stable Diffusion 3.5 Large
///
/// Category: text-to-image
/// Machine Type: A100
/// License Type: commercial
pub fn turbo(params: TextToImageTurboInput) -> FalRequest<TextToImageTurboInput, Output> {
FalRequest::new("fal-ai/stable-diffusion-v35-large/turbo", params)
}