mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 01:38:44 +00:00
refactor rembg
This commit is contained in:
1 parent
96ff54664d
commit
96a89df7a3
3 files changed
+33
-3
No files matched your search
+29
@@ -0,0 +1,29 @@
|
||||
use fal::request::FalRequest;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||
pub struct RembgRemoveBackgroundInput {
|
||||
pub image_url: String,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub crop_to_bbox: Option<bool>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub sync_mode: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct RembgRemoveBackgroundFile {
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct RembgRemoveBackgroundOutput {
|
||||
pub image: RembgRemoveBackgroundFile,
|
||||
}
|
||||
|
||||
pub fn rembg_remove_background(
|
||||
params: RembgRemoveBackgroundInput,
|
||||
) -> FalRequest<RembgRemoveBackgroundInput, RembgRemoveBackgroundOutput> {
|
||||
FalRequest::new("fal-ai/imageutils/rembg", params)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pub mod http_rembg_remove_background;
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
use crate::creds::fal_api_key::FalApiKey;
|
||||
use crate::error::classify_fal_error::classify_fal_error;
|
||||
use crate::error::fal_error_plus::FalErrorPlus;
|
||||
use fal::endpoints::fal_ai::imageutils::rembg::{rembg, RemoveBackgroundInput};
|
||||
use crate::requests::http::image::background::http_rembg_remove_background::{rembg_remove_background, RembgRemoveBackgroundInput};
|
||||
use fal::webhook::WebhookResponse;
|
||||
use reqwest::IntoUrl;
|
||||
|
||||
@@ -17,13 +17,13 @@ pub async fn remove_background_rembg_webhook<U: IntoUrl, V: IntoUrl>(
|
||||
|
||||
let image_url = args.image_url.into_url()?;
|
||||
|
||||
let request = RemoveBackgroundInput {
|
||||
let request = RembgRemoveBackgroundInput {
|
||||
image_url: image_url.to_string(),
|
||||
crop_to_bbox: None,
|
||||
sync_mode: None
|
||||
};
|
||||
|
||||
let result = rembg(request)
|
||||
let result = rembg_remove_background(request)
|
||||
.with_api_key(&args.api_key.0)
|
||||
.queue_webhook(args.webhook_url)
|
||||
.await;
|
||||
|
||||
Reference in new issue
Block a user