mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 08:57:54 +00:00
Added strength parameters (#322)
Co-authored-by: Storyteller <storyteller@MacBook-Pro-de-Storyteller.local>
This commit is contained in:
1 parent
f584cd103f
commit
f844aa7016
6 files changed
+38
No files matched your search
@@ -142,4 +142,8 @@ pub struct WorkflowArgs {
|
||||
#[serde(rename = "up")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub use_upscaler: Option<bool>,
|
||||
|
||||
#[serde(rename = "s")]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub strength: Option<f32>,
|
||||
}
|
||||
+7
@@ -86,6 +86,7 @@ pub struct InferenceArgs<'s> {
|
||||
|
||||
pub face_detailer_enabled: bool,
|
||||
pub upscaler_enabled: bool,
|
||||
pub maybe_strength: Option<f32>,
|
||||
}
|
||||
|
||||
pub enum InferenceDetails<'s> {
|
||||
@@ -262,6 +263,12 @@ impl ComfyInferenceCommand {
|
||||
command.push_str(" --upscaler-enabled ");
|
||||
}
|
||||
|
||||
if let Some(strength) = args.maybe_strength {
|
||||
command.push_str(" --strength ");
|
||||
command.push_str(&strength.to_string());
|
||||
command.push_str(" ");
|
||||
}
|
||||
|
||||
if let Some(docker_options) = self.maybe_docker_options.as_ref() {
|
||||
command = docker_options.to_command_string(&command);
|
||||
}
|
||||
|
||||
@@ -399,8 +399,10 @@ pub async fn process_job(args: ComfyProcessJobArgs<'_>) -> Result<JobSuccessResu
|
||||
inference_details,
|
||||
face_detailer_enabled: comfy_args.use_face_detailer.unwrap_or(false),
|
||||
upscaler_enabled: comfy_args.use_upscaler.unwrap_or(false),
|
||||
maybe_strength: comfy_args.strength,
|
||||
});
|
||||
|
||||
|
||||
let inference_duration = Instant::now().duration_since(inference_start_time);
|
||||
|
||||
info!("Inference command exited with status: {:?}", command_exit_status);
|
||||
|
||||
+1
@@ -281,6 +281,7 @@ pub async fn enqueue_comfy_ui_handler(
|
||||
.map(|value| str_to_bool(&value)),
|
||||
use_face_detailer: None,
|
||||
use_upscaler: None,
|
||||
strength: None,
|
||||
};
|
||||
|
||||
info!("Creating ComfyUI job record...");
|
||||
|
||||
+23
@@ -48,6 +48,15 @@ const DEFAULT_TRIM_MILLISECONDS_END : u64 = 3_000;
|
||||
/// This is the maximum duration (for premium users)
|
||||
const MAXIMUM_DURATION_MILLIS : u64 = 10_000;
|
||||
|
||||
/// Strength of Diffusion:
|
||||
/// * Range (0.0 - 1.0)
|
||||
/// * 0.0 less dreamy
|
||||
/// * 1.0 dream more
|
||||
/// * The Python code will default to "1.0" if not supplied
|
||||
const MINIMUM_STRENGTH : f32 = 0.0;
|
||||
const MAXIMUM_STRENGTH : f32 = 1.0;
|
||||
const DEFAULT_STRENGTH : f32 = 1.0;
|
||||
|
||||
#[derive(Deserialize, ToSchema)]
|
||||
pub struct EnqueueVideoStyleTransferRequest {
|
||||
/// Entropy for request de-duplication (required)
|
||||
@@ -86,6 +95,9 @@ pub struct EnqueueVideoStyleTransferRequest {
|
||||
/// Only for premium accounts
|
||||
use_upscaler: Option<bool>,
|
||||
|
||||
/// Use Strength of the style transfer
|
||||
use_strength: Option<f32>,
|
||||
|
||||
/// Optional visibility setting override.
|
||||
creator_set_visibility: Option<Visibility>,
|
||||
|
||||
@@ -275,6 +287,16 @@ pub async fn enqueue_video_style_transfer_handler(
|
||||
}
|
||||
}
|
||||
|
||||
let maybe_strength = request.use_strength
|
||||
.map(|strength| {
|
||||
if strength < MINIMUM_STRENGTH || strength > MAXIMUM_STRENGTH {
|
||||
Err(EnqueueVideoStyleTransferError::BadInput("Strength must be between 0.0 and 1.0".to_string()))
|
||||
} else {
|
||||
Ok(strength)
|
||||
}
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
// Must have paid plan to remove watermark
|
||||
let remove_watermark = request.remove_watermark
|
||||
.map(|remove_watermark| remove_watermark && has_paid_plan);
|
||||
@@ -305,6 +327,7 @@ pub async fn enqueue_video_style_transfer_handler(
|
||||
.map(|value| str_to_bool(&value)),
|
||||
use_face_detailer: request.use_face_detailer,
|
||||
use_upscaler: request.use_upscaler,
|
||||
strength: maybe_strength,
|
||||
};
|
||||
|
||||
info!("Creating ComfyUI job record...");
|
||||
|
||||
+1
@@ -250,6 +250,7 @@ pub async fn enqueue_workflow_upload_request(
|
||||
.map(|value| str_to_bool(&value)),
|
||||
use_face_detailer: None,
|
||||
use_upscaler: None,
|
||||
strength: None,
|
||||
};
|
||||
|
||||
// create the inference args here
|
||||
|
||||
Reference in new issue
Block a user