Skip to content

Commit

Permalink
feat: support negative_prompt in image_edit_handler
Browse files Browse the repository at this point in the history
Signed-off-by: Xin Liu <sam@secondstate.io>
  • Loading branch information
apepkuss committed Oct 11, 2024
1 parent 81912da commit 9335c7d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/backend/sd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,31 @@ pub(crate) async fn image_edit_handler(req: Request<Body>) -> Response<Body> {
return error::internal_server_error(err_msg);
}
},
"negative_prompt" => match field.is_text() {
true => {
let mut negative_prompt = String::new();

if let Err(e) = field.data.read_to_string(&mut negative_prompt) {
let err_msg = format!("Failed to read the prompt. {}", e);

// log
error!(target: "stdout", "{}", &err_msg);

return error::internal_server_error(err_msg);
}

image_request.prompt = negative_prompt;
}
false => {
let err_msg =
"Failed to get the prompt. The prompt field in the request should be a text field.";

// log
error!(target: "stdout", "{}", &err_msg);

return error::internal_server_error(err_msg);
}
},
"mask" => {
let filename = match field.headers.filename {
Some(filename) => filename,
Expand Down

0 comments on commit 9335c7d

Please sign in to comment.