Fix Imaginate node types to prevent an immediate crash

This commit is contained in:
Dennis Kobert 2023-07-14 15:28:54 +02:00 committed by Keavon Chambers
parent aaf28ba7b7
commit d52ea18a1f
4 changed files with 17 additions and 16 deletions

View file

@ -1802,14 +1802,14 @@ pub static IMAGINATE_NODE: Lazy<DocumentNodeType> = Lazy::new(|| DocumentNodeTyp
NodeInput::Network(concrete!(Option<DVec2>)),
NodeInput::Network(concrete!(u32)),
NodeInput::Network(concrete!(ImaginateSamplingMethod)),
NodeInput::Network(concrete!(f64)),
NodeInput::Network(concrete!(f32)),
NodeInput::Network(concrete!(String)),
NodeInput::Network(concrete!(String)),
NodeInput::Network(concrete!(bool)),
NodeInput::Network(concrete!(f64)),
NodeInput::Network(concrete!(f32)),
NodeInput::Network(concrete!(Option<Vec<u64>>)),
NodeInput::Network(concrete!(bool)),
NodeInput::Network(concrete!(f64)),
NodeInput::Network(concrete!(f32)),
NodeInput::Network(concrete!(ImaginateMaskStartingFill)),
NodeInput::Network(concrete!(bool)),
NodeInput::Network(concrete!(bool)),
@ -1831,7 +1831,7 @@ pub static IMAGINATE_NODE: Lazy<DocumentNodeType> = Lazy::new(|| DocumentNodeTyp
default: NodeInput::Network(concrete!(WasmEditorApi)),
},
DocumentInputType::value("Controller", TaggedValue::ImaginateController(Default::default()), false),
DocumentInputType::value("Seed", TaggedValue::F32(0.), false), // Remember to keep index used in `ImaginateRandom` updated with this entry's index
DocumentInputType::value("Seed", TaggedValue::F64(0.), false), // Remember to keep index used in `ImaginateRandom` updated with this entry's index
DocumentInputType::value("Resolution", TaggedValue::OptionalDVec2(None), false),
DocumentInputType::value("Samples", TaggedValue::U32(30), false),
DocumentInputType::value("Sampling Method", TaggedValue::ImaginateSamplingMethod(ImaginateSamplingMethod::EulerA), false),

View file

@ -264,14 +264,14 @@ pub async fn imaginate<'a, P: Pixel>(
res: impl Future<Output = Option<DVec2>>,
samples: impl Future<Output = u32>,
sampling_method: impl Future<Output = ImaginateSamplingMethod>,
prompt_guidance: impl Future<Output = f64>,
prompt_guidance: impl Future<Output = f32>,
prompt: impl Future<Output = String>,
negative_prompt: impl Future<Output = String>,
adapt_input_image: impl Future<Output = bool>,
image_creativity: impl Future<Output = f64>,
image_creativity: impl Future<Output = f32>,
masking_layer: impl Future<Output = Option<Vec<u64>>>,
inpaint: impl Future<Output = bool>,
mask_blur: impl Future<Output = f64>,
mask_blur: impl Future<Output = f32>,
mask_starting_fill: impl Future<Output = ImaginateMaskStartingFill>,
improve_faces: impl Future<Output = bool>,
tiling: impl Future<Output = bool>,
@ -332,14 +332,14 @@ async fn imaginate_maybe_fail<'a, P: Pixel, F: Fn(ImaginateStatus)>(
res: impl Future<Output = Option<DVec2>>,
samples: impl Future<Output = u32>,
sampling_method: impl Future<Output = ImaginateSamplingMethod>,
prompt_guidance: impl Future<Output = f64>,
prompt_guidance: impl Future<Output = f32>,
prompt: impl Future<Output = String>,
negative_prompt: impl Future<Output = String>,
adapt_input_image: impl Future<Output = bool>,
image_creativity: impl Future<Output = f64>,
image_creativity: impl Future<Output = f32>,
_masking_layer: impl Future<Output = Option<Vec<u64>>>,
_inpaint: impl Future<Output = bool>,
_mask_blur: impl Future<Output = f64>,
_mask_blur: impl Future<Output = f32>,
_mask_starting_fill: impl Future<Output = ImaginateMaskStartingFill>,
improve_faces: impl Future<Output = bool>,
tiling: impl Future<Output = bool>,
@ -361,7 +361,7 @@ async fn imaginate_maybe_fail<'a, P: Pixel, F: Fn(ImaginateStatus)>(
prompt: prompt.await,
seed: seed.await,
steps: samples.await,
cfg_scale: prompt_guidance.await,
cfg_scale: prompt_guidance.await as f64,
width: res.x,
height: res.y,
restore_faces: improve_faces.await,
@ -376,7 +376,7 @@ async fn imaginate_maybe_fail<'a, P: Pixel, F: Fn(ImaginateStatus)>(
override_settings: Default::default(),
init_images: vec![base64_data],
denoising_strength: image_creativity.await * 0.01,
denoising_strength: image_creativity.await as f64 * 0.01,
mask: None,
};
let url = join_url(&base_url, SDAPI_IMAGE_TO_IMAGE)?;

View file

@ -475,14 +475,14 @@ generate_imaginate_node! {
res: Res: Option<DVec2>,
samples: Samples: u32,
sampling_method: SamplingMethod: ImaginateSamplingMethod,
prompt_guidance: PromptGuidance: f64,
prompt_guidance: PromptGuidance: f32,
prompt: Prompt: String,
negative_prompt: NegativePrompt: String,
adapt_input_image: AdaptInputImage: bool,
image_creativity: ImageCreativity: f64,
image_creativity: ImageCreativity: f32,
masking_layer: MaskingLayer: Option<Vec<u64>>,
inpaint: Inpaint: bool,
mask_blur: MaskBlur: f64,
mask_blur: MaskBlur: f32,
mask_starting_fill: MaskStartingFill: ImaginateMaskStartingFill,
improve_faces: ImproveFaces: bool,
tiling: Tiling: bool,

View file

@ -21,6 +21,7 @@ use graphene_std::wasm_application_io::*;
use gpu_executor::{GpuExecutor, ShaderInput, ShaderInputFrame};
use graphene_std::raster::*;
use graphene_std::wasm_application_io::WasmEditorApi;
#[cfg(feature = "gpu")]
use wgpu_executor::WgpuExecutor;
use dyn_any::StaticType;
@ -481,7 +482,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
vec![
fn_type!(WasmEditorApi),
fn_type!(ImaginateController),
fn_type!(f32),
fn_type!(f64),
fn_type!(Option<DVec2>),
fn_type!(u32),
fn_type!(ImaginateSamplingMethod),