diff --git a/crates/lib/mysql_queries/src/payloads/generic_inference_args/generic_inference_args.rs b/crates/lib/mysql_queries/src/payloads/generic_inference_args/generic_inference_args.rs index cc88ebd3c9..ed4aa3e961 100644 --- a/crates/lib/mysql_queries/src/payloads/generic_inference_args/generic_inference_args.rs +++ b/crates/lib/mysql_queries/src/payloads/generic_inference_args/generic_inference_args.rs @@ -202,21 +202,24 @@ mod tests { let upload_path = "upload_path".to_string(); let lora_upload_path = "lora_upload_path".to_string(); let checkpoint = "checkpoint".to_string(); - + let type_of_inference = "type_of_inference".to_string(); let args = GenericInferenceArgs { inference_category: Some(InferenceCategoryAbbreviated::ImageGeneration), args: Some(PolymorphicInferenceArgs::Ig(StableDiffusionArgs { - maybe_video_source: Some(video_media_token), - maybe_image_source: Some(image_media_token), maybe_sd_model_token: Some(sd_model_token), maybe_lora_model_token: Some(lora_model_token), + maybe_height: Some(512), + maybe_width: Some(512), + maybe_cfg_scale: Some(7), maybe_prompt: Some(prompt), - maybe_a_prompt: Some(a_prompt), maybe_n_prompt: Some(n_prompt), + maybe_batch_count: Some(1), + maybe_batch_size: Some(1), + maybe_number_of_samples: Some(25), maybe_seed: Some(seed), maybe_upload_path: Some(upload_path), maybe_lora_upload_path: Some(lora_upload_path), - inference_type: Some(checkpoint) + type_of_inference: type_of_inference })), }; diff --git a/crates/lib/mysql_queries/src/payloads/generic_inference_args/image_generation_payload.rs b/crates/lib/mysql_queries/src/payloads/generic_inference_args/image_generation_payload.rs index 83415daea4..233f802533 100644 --- a/crates/lib/mysql_queries/src/payloads/generic_inference_args/image_generation_payload.rs +++ b/crates/lib/mysql_queries/src/payloads/generic_inference_args/image_generation_payload.rs @@ -45,10 +45,6 @@ pub struct StableDiffusionArgs { #[serde(skip_serializing_if = "Option::is_none")] pub maybe_prompt: Option, - #[serde(rename = "ap")] - #[serde(skip_serializing_if = "Option::is_none")] - pub maybe_a_prompt: Option, - #[serde(rename = "np")] #[serde(skip_serializing_if = "Option::is_none")] pub maybe_n_prompt: Option, diff --git a/crates/service/job/inference_job/config/inference-job.development.env b/crates/service/job/inference_job/config/inference-job.development.env index 58472916ad..bc9a8165ff 100644 --- a/crates/service/job/inference_job/config/inference-job.development.env +++ b/crates/service/job/inference_job/config/inference-job.development.env @@ -109,8 +109,8 @@ RERENDER_INFERENCE_EXECUTABLE_OR_COMMAND="venv/bin/python rerender.py" # STABLE DIFFUSION # # # # ================================= # - -STABLE_DIFFUSION_INFERENCE_COMMAND="/home/tensor/code/storyteller/storyteller-ml/image-gen" +STABLE_DIFFUSION_INFERENCE_ROOT_DIRECTORY="/home/tensor/code/storyteller/storyteller-ml/image_generation/Storyteller-Studio-Filter/" +STABLE_DIFFUSION_INFERENCE_COMMAND="venv/bin/python main.py" # ================================= # # # diff --git a/crates/service/job/inference_job/src/job/job_types/image_generation/process_single_ig_job.rs b/crates/service/job/inference_job/src/job/job_types/image_generation/process_single_ig_job.rs index 959642865f..a5f09ef9f9 100644 --- a/crates/service/job/inference_job/src/job/job_types/image_generation/process_single_ig_job.rs +++ b/crates/service/job/inference_job/src/job/job_types/image_generation/process_single_ig_job.rs @@ -2,7 +2,7 @@ use enums::by_table::generic_inference_jobs::inference_model_type::InferenceMode use mysql_queries::queries::generic_inference::job::list_available_generic_inference_jobs::AvailableInferenceJob; use crate::job::job_loop::job_success_result::JobSuccessResult; use crate::job::job_loop::process_single_job_error::ProcessSingleJobError; -use crate::job::job_types::image_generation::sd::process_job::process_job; +use crate::job::job_types::image_generation::sd::process_job::process_job_selection; use crate::job_dependencies::JobDependencies; use crate::job::job_types::image_generation::sd::process_job::StableDiffusionProcessArgs; use errors::anyhow; @@ -30,5 +30,5 @@ pub async fn dispatch_sd_job(job_dependencies: &JobDependencies, job: &Available job_dependencies, job, }; - process_job(args).await + process_job_selection(args).await } \ No newline at end of file diff --git a/crates/service/job/inference_job/src/job/job_types/image_generation/sd/mod.rs b/crates/service/job/inference_job/src/job/job_types/image_generation/sd/mod.rs index 17702a9f82..bf85551a02 100644 --- a/crates/service/job/inference_job/src/job/job_types/image_generation/sd/mod.rs +++ b/crates/service/job/inference_job/src/job/job_types/image_generation/sd/mod.rs @@ -1,4 +1,5 @@ pub mod process_job; + pub mod model_downloaders; pub mod sd_inference_command; pub mod stable_diffusion_dependencies; diff --git a/crates/service/job/inference_job/src/job/job_types/image_generation/sd/process_job.rs b/crates/service/job/inference_job/src/job/job_types/image_generation/sd/process_job.rs index 0d133492f1..c6b765888e 100644 --- a/crates/service/job/inference_job/src/job/job_types/image_generation/sd/process_job.rs +++ b/crates/service/job/inference_job/src/job/job_types/image_generation/sd/process_job.rs @@ -63,7 +63,39 @@ pub async fn sd_args_from_job( Ok(stable_diffusion_args) } -pub async fn process_job( + +pub async fn process_job_selection (args: StableDiffusionProcessArgs<'_> +) -> Result { + let job = args.job; + let sd_args = sd_args_from_job(&args).await?; + if sd_args.type_of_inference == "inference" { + process_job_inference(args).await + } + else if sd_args.type_of_inference == "lora" { + process_job_lora(args).await + } + else if sd_args.type_of_inference == "checkpoint"{ + process_job_inference(args).await + } + else { + Err(ProcessSingleJobError::Other(anyhow!("inference type doesn't exist!"))) + } +} + +pub async fn process_job_checkpoint(args: StableDiffusionProcessArgs<'_>) -> Result { + Ok(JobSuccessResult { + maybe_result_entity: None, + inference_duration: Duration::from_secs(0), + }) +} +pub async fn process_job_lora(args: StableDiffusionProcessArgs<'_>) -> Result { + Ok(JobSuccessResult { + maybe_result_entity: None, + inference_duration: Duration::from_secs(0), + }) +} + +pub async fn process_job_inference( args: StableDiffusionProcessArgs<'_> ) -> Result { let job = args.job; diff --git a/crates/service/job/inference_job/src/job/job_types/image_generation/sd/sd_inference_command.rs b/crates/service/job/inference_job/src/job/job_types/image_generation/sd/sd_inference_command.rs index 2c5b37c62d..5014b00602 100644 --- a/crates/service/job/inference_job/src/job/job_types/image_generation/sd/sd_inference_command.rs +++ b/crates/service/job/inference_job/src/job/job_types/image_generation/sd/sd_inference_command.rs @@ -83,9 +83,8 @@ pub struct InferenceArgs> { pub cfg_scale:i32, pub seed:i32, pub lora_path:P, - pub check_point:P, + pub checkpoint_path:P, pub vae:P, - pub batch_size:i32, pub batch_count:i32, } @@ -117,16 +116,12 @@ impl StableDiffusionInferenceCommand { let maybe_inference_command = easyenv::get_env_string_optional( "STABLE_DIFFUSION_INFERENCE_COMMAND"); - // Optional, eg. `./infer.py`. Typically we'll use the command form instead. - let maybe_inference_executable = easyenv::get_env_pathbuf_optional( - "STABLE_DIFFUSION_INFERENCE_EXECUTABLE"); let executable_or_command = match maybe_inference_command { Some(command) => ExecutableOrCommand::Command(command), - None => match maybe_inference_executable { - Some(executable) => ExecutableOrCommand::Executable(executable), - None => return Err(anyhow!("neither command nor executable passed")), - }, + None => { + return Err(anyhow!("neither command nor executable passed")); + } }; let maybe_virtual_env_activation_command = easyenv::get_env_string_optional( @@ -204,19 +199,16 @@ impl StableDiffusionInferenceCommand { // ===== Begin Python Args ===== command.push_str("--prompt "); command.push_str(&args.prompt.as_ref().to_string_lossy()); - + command.push_str(" --result_dir "); command.push_str(&args.work_dir.as_ref().to_string_lossy()); - + command.push_str(" --result_file "); command.push_str(&args.output_file.as_ref().to_string_lossy()); command.push_str(" --stderr_output_file "); command.push_str(&args.stderr_output_file.as_ref().to_string_lossy()); - - command.push_str(" --prompt "); - command.push_str(&args.prompt.as_ref().to_string_lossy()); - + command.push_str(" --negative_prompt "); command.push_str(&args.negative_prompt.as_ref().to_string_lossy()); @@ -242,14 +234,11 @@ impl StableDiffusionInferenceCommand { command.push_str(&args.lora_path.as_ref().to_string_lossy()); command.push_str(" --check_point "); - command.push_str(&args.check_point.as_ref().to_string_lossy()); + command.push_str(&args.checkpoint_path.as_ref().to_string_lossy()); command.push_str(" --vae "); command.push_str(&args.vae.as_ref().to_string_lossy()); - command.push_str(" --batch_size "); - command.push_str(&args.batch_size.to_string()); - command.push_str(" --batch_count "); command.push_str(&args.batch_count.to_string()); diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/image_gen/enqueue_image_generation.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/image_gen/enqueue_image_generation.rs index a84efdffcc..9f09505293 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/image_gen/enqueue_image_generation.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/image_gen/enqueue_image_generation.rs @@ -109,7 +109,6 @@ pub struct EnqueueImageGenRequest { maybe_sd_model_token: Option, maybe_lora_model_token: Option, maybe_prompt: Option, - maybe_a_prompt: Option, maybe_n_prompt: Option, maybe_seed: Option, maybe_width: Option, @@ -189,8 +188,10 @@ pub async fn enqueue_image_generation_request( ) -> Result { // TODO: Brandon need to figure out premium vs not premium + let mut maybe_user_token: Option = None; let visbility = enums::common::visibility::Visibility::Public; + let mut mysql_connection = server_state.mysql_pool.acquire().await.map_err(|err| { warn!("MySql pool error: {:?}", err); EnqueueImageGenRequestError::ServerError @@ -316,7 +317,6 @@ pub async fn enqueue_image_generation_request( let lora_token = ModelWeightToken(request.maybe_lora_model_token.clone().unwrap_or_default()); - let a_prompt = request.maybe_a_prompt.clone().unwrap_or_default(); let n_prompt = request.maybe_n_prompt.clone().unwrap_or_default(); // we can only do 1 upload type at a time. @@ -333,12 +333,10 @@ pub async fn enqueue_image_generation_request( let type_of_inference = request.type_of_inference.to_string().clone(); - let inference_args = StableDiffusionArgs { maybe_sd_model_token: Some(sd_weight_token), maybe_lora_model_token: Some(lora_token), maybe_prompt: Some(request.maybe_prompt.clone().unwrap_or_default()), - maybe_a_prompt: Some(a_prompt), maybe_n_prompt: Some(n_prompt), maybe_seed: Some(seed), maybe_upload_path: Some(upload_path),