mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 09:28:11 +00:00
seedream 4 / 4.5
This commit is contained in:
1 parent
729d0d154b
commit
116a4887b2
8 files changed
+159
-30
No files matched your search
@@ -32,9 +32,11 @@ pub enum CommonAspectRatio {
|
||||
Tall,
|
||||
|
||||
// Auto values that bake in resolution
|
||||
// These are from the Seedream models
|
||||
Auto2k,
|
||||
Auto4k,
|
||||
|
||||
// Defined aspect ratios that bake in resolution
|
||||
// These are from the Seedream models
|
||||
SquareHd,
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio;
|
||||
use artcraft_api_defs::generate::image::multi_function::bytedance_seedream_v4_multi_function_image_gen::BytedanceSeedreamV4MultiFunctionImageGenImageSize;
|
||||
|
||||
pub fn aspect_ratio_to_artcraft_seedream_4(aspect_ratio: CommonAspectRatio) -> BytedanceSeedreamV4MultiFunctionImageGenImageSize {
|
||||
match aspect_ratio {
|
||||
// Exact
|
||||
CommonAspectRatio::Auto => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Auto,
|
||||
CommonAspectRatio::Auto2k => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Auto2k,
|
||||
CommonAspectRatio::Auto4k => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Auto4k,
|
||||
CommonAspectRatio::Square => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Square,
|
||||
CommonAspectRatio::SquareHd => BytedanceSeedreamV4MultiFunctionImageGenImageSize::SquareHd,
|
||||
CommonAspectRatio::WideFourByThree => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeFourThree,
|
||||
CommonAspectRatio::WideSixteenByNine => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
CommonAspectRatio::TallThreeByFour => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitFourThree,
|
||||
CommonAspectRatio::TallNineBySixteen => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
|
||||
// Non-matching aspect ratios, use closest neighbor
|
||||
CommonAspectRatio::WideFiveByFour => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeFourThree,
|
||||
CommonAspectRatio::WideThreeByTwo => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeFourThree,
|
||||
CommonAspectRatio::WideTwentyOneByNine => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
CommonAspectRatio::TallFourByFive => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitFourThree,
|
||||
CommonAspectRatio::TallTwoByThree => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitFourThree,
|
||||
CommonAspectRatio::TallNineByTwentyOne => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
|
||||
// Semantic values
|
||||
CommonAspectRatio::Wide => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
CommonAspectRatio::Tall => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio;
|
||||
use artcraft_api_defs::generate::image::multi_function::bytedance_seedream_v4p5_multi_function_image_gen::BytedanceSeedreamV4p5MultiFunctionImageGenImageSize;
|
||||
|
||||
pub fn aspect_ratio_to_artcraft_seedream_4p5(aspect_ratio: CommonAspectRatio) -> BytedanceSeedreamV4p5MultiFunctionImageGenImageSize {
|
||||
match aspect_ratio {
|
||||
// Exact
|
||||
CommonAspectRatio::Auto2k => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Auto2k,
|
||||
CommonAspectRatio::Auto4k => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Auto4k,
|
||||
CommonAspectRatio::Square => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Square,
|
||||
CommonAspectRatio::SquareHd => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::SquareHd,
|
||||
CommonAspectRatio::WideFourByThree => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeFourThree,
|
||||
CommonAspectRatio::WideSixteenByNine => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
CommonAspectRatio::TallThreeByFour => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitFourThree,
|
||||
CommonAspectRatio::TallNineBySixteen => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
|
||||
// Non-matching aspect ratios, use closest neighbor
|
||||
CommonAspectRatio::Auto => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Auto4k,
|
||||
CommonAspectRatio::WideFiveByFour => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeFourThree,
|
||||
CommonAspectRatio::WideThreeByTwo => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeFourThree,
|
||||
CommonAspectRatio::WideTwentyOneByNine => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
CommonAspectRatio::TallFourByFive => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitFourThree,
|
||||
CommonAspectRatio::TallTwoByThree => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitFourThree,
|
||||
CommonAspectRatio::TallNineByTwentyOne => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
|
||||
// Semantic values
|
||||
CommonAspectRatio::Wide => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
CommonAspectRatio::Tall => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,7 @@ pub mod aspect_ratio_to_artcraft_gpt_image_1;
|
||||
pub mod aspect_ratio_to_artcraft_gpt_image_1p5;
|
||||
pub mod aspect_ratio_to_artcraft_nano_banana;
|
||||
pub mod aspect_ratio_to_artcraft_nano_banana_pro;
|
||||
pub mod aspect_ratio_to_artcraft_seedream_4;
|
||||
pub mod aspect_ratio_to_artcraft_seedream_4p5;
|
||||
pub mod aspect_ratio_to_grok_image;
|
||||
pub mod aspect_ratio_to_sora_native_gpt_image_1;
|
||||
+25
-7
@@ -1,3 +1,5 @@
|
||||
use crate::core::api_adapters::aspect_ratio::convert::aspect_ratio_to_artcraft_nano_banana_pro::aspect_ratio_to_artcraft_nano_banana_pro;
|
||||
use crate::core::api_adapters::aspect_ratio::convert::aspect_ratio_to_artcraft_seedream_4::aspect_ratio_to_artcraft_seedream_4;
|
||||
use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError};
|
||||
use crate::core::commands::enqueue::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize, EnqueueEditImageCommand};
|
||||
use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess;
|
||||
@@ -12,6 +14,7 @@ use crate::services::sora::state::sora_task_queue::SoraTaskQueue;
|
||||
use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager;
|
||||
use anyhow::anyhow;
|
||||
use artcraft_api_defs::generate::image::multi_function::bytedance_seedream_v4_multi_function_image_gen::{BytedanceSeedreamV4MultiFunctionImageGenImageSize, BytedanceSeedreamV4MultiFunctionImageGenNumImages, BytedanceSeedreamV4MultiFunctionImageGenRequest};
|
||||
use artcraft_api_defs::generate::image::multi_function::nano_banana_pro_multi_function_image_gen::NanoBananaProMultiFunctionImageGenAspectRatio;
|
||||
use enums::common::generation_provider::GenerationProvider;
|
||||
use enums::tauri::tasks::task_type::TaskType;
|
||||
use idempotency::uuid::generate_random_uuid;
|
||||
@@ -40,13 +43,7 @@ pub async fn handle_artcraft_seedream_4_edit(
|
||||
|
||||
let uuid_idempotency_token = generate_random_uuid();
|
||||
|
||||
let image_size = request.aspect_ratio
|
||||
.map(|size| match size {
|
||||
EditImageSize::Auto => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Square,
|
||||
EditImageSize::Square => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Square,
|
||||
EditImageSize::Tall => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
EditImageSize::Wide => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
});
|
||||
let image_size = get_aspect_ratio(request);
|
||||
|
||||
let num_images = match request.image_count {
|
||||
None => None,
|
||||
@@ -117,3 +114,24 @@ pub async fn handle_artcraft_seedream_4_edit(
|
||||
task_type: TaskType::ImageGeneration,
|
||||
})
|
||||
}
|
||||
|
||||
fn get_aspect_ratio(request: &EnqueueEditImageCommand) -> Option<BytedanceSeedreamV4MultiFunctionImageGenImageSize> {
|
||||
if let Some(common_aspect_ratio) = request.common_aspect_ratio {
|
||||
// Handle modern aspect ratio
|
||||
let aspect = aspect_ratio_to_artcraft_seedream_4(common_aspect_ratio);
|
||||
return Some(aspect);
|
||||
}
|
||||
|
||||
if let Some(aspect_ratio) = request.aspect_ratio {
|
||||
// Handle deprecated aspect ratio
|
||||
let aspect_ratio = match aspect_ratio {
|
||||
EditImageSize::Auto => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Square,
|
||||
EditImageSize::Square => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Square,
|
||||
EditImageSize::Tall => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
EditImageSize::Wide => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
};
|
||||
return Some(aspect_ratio);
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
+24
-7
@@ -1,3 +1,5 @@
|
||||
use crate::core::api_adapters::aspect_ratio::convert::aspect_ratio_to_artcraft_seedream_4::aspect_ratio_to_artcraft_seedream_4;
|
||||
use crate::core::api_adapters::aspect_ratio::convert::aspect_ratio_to_artcraft_seedream_4p5::aspect_ratio_to_artcraft_seedream_4p5;
|
||||
use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError};
|
||||
use crate::core::commands::enqueue::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize, EnqueueEditImageCommand};
|
||||
use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess;
|
||||
@@ -40,13 +42,7 @@ pub async fn handle_artcraft_seedream_4p5_edit(
|
||||
|
||||
let uuid_idempotency_token = generate_random_uuid();
|
||||
|
||||
let image_size = request.aspect_ratio
|
||||
.map(|size| match size {
|
||||
EditImageSize::Auto => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Square,
|
||||
EditImageSize::Square => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Square,
|
||||
EditImageSize::Tall => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
EditImageSize::Wide => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
});
|
||||
let image_size = get_aspect_ratio(request);
|
||||
|
||||
let num_images = match request.image_count {
|
||||
None => None,
|
||||
@@ -117,3 +113,24 @@ pub async fn handle_artcraft_seedream_4p5_edit(
|
||||
task_type: TaskType::ImageGeneration,
|
||||
})
|
||||
}
|
||||
|
||||
fn get_aspect_ratio(request: &EnqueueEditImageCommand) -> Option<BytedanceSeedreamV4p5MultiFunctionImageGenImageSize> {
|
||||
if let Some(common_aspect_ratio) = request.common_aspect_ratio {
|
||||
// Handle modern aspect ratio
|
||||
let aspect = aspect_ratio_to_artcraft_seedream_4p5(common_aspect_ratio);
|
||||
return Some(aspect);
|
||||
}
|
||||
|
||||
if let Some(aspect_ratio) = request.aspect_ratio {
|
||||
// Handle deprecated aspect ratio
|
||||
let aspect_ratio = match aspect_ratio {
|
||||
EditImageSize::Auto => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Square,
|
||||
EditImageSize::Square => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Square,
|
||||
EditImageSize::Tall => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
EditImageSize::Wide => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
};
|
||||
return Some(aspect_ratio);
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
+24
-8
@@ -1,5 +1,6 @@
|
||||
use crate::core::api_adapters::aspect_ratio::convert::aspect_ratio_to_artcraft_seedream_4::aspect_ratio_to_artcraft_seedream_4;
|
||||
use crate::core::commands::enqueue::generate_error::GenerateError;
|
||||
use crate::core::commands::enqueue::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize};
|
||||
use crate::core::commands::enqueue::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize, EnqueueEditImageCommand};
|
||||
use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess;
|
||||
use crate::core::commands::enqueue::text_to_image::enqueue_text_to_image_command::{EnqueueTextToImageRequest, TextToImageSize};
|
||||
use crate::core::events::basic_sendable_event_trait::BasicSendableEvent;
|
||||
@@ -37,13 +38,7 @@ pub async fn handle_artcraft_seedream_4_text_to_image(
|
||||
|
||||
let uuid_idempotency_token = generate_random_uuid();
|
||||
|
||||
let image_size = request.aspect_ratio
|
||||
.map(|size| match size {
|
||||
TextToImageSize::Auto => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Square,
|
||||
TextToImageSize::Square => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Square,
|
||||
TextToImageSize::Tall => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
TextToImageSize::Wide => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
});
|
||||
let image_size = get_aspect_ratio(request);
|
||||
|
||||
let num_images = match request.number_images {
|
||||
None => None,
|
||||
@@ -98,3 +93,24 @@ pub async fn handle_artcraft_seedream_4_text_to_image(
|
||||
task_type: TaskType::ImageGeneration,
|
||||
})
|
||||
}
|
||||
|
||||
fn get_aspect_ratio(request: &EnqueueTextToImageRequest) -> Option<BytedanceSeedreamV4MultiFunctionImageGenImageSize> {
|
||||
if let Some(common_aspect_ratio) = request.common_aspect_ratio {
|
||||
// Handle modern aspect ratio
|
||||
let aspect = aspect_ratio_to_artcraft_seedream_4(common_aspect_ratio);
|
||||
return Some(aspect);
|
||||
}
|
||||
|
||||
if let Some(aspect_ratio) = request.aspect_ratio {
|
||||
// Handle deprecated aspect ratio
|
||||
let aspect_ratio = match aspect_ratio {
|
||||
TextToImageSize::Auto => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Square,
|
||||
TextToImageSize::Square => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Square,
|
||||
TextToImageSize::Tall => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
TextToImageSize::Wide => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
};
|
||||
return Some(aspect_ratio);
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
+24
-8
@@ -1,5 +1,6 @@
|
||||
use crate::core::api_adapters::aspect_ratio::convert::aspect_ratio_to_artcraft_seedream_4p5::aspect_ratio_to_artcraft_seedream_4p5;
|
||||
use crate::core::commands::enqueue::generate_error::GenerateError;
|
||||
use crate::core::commands::enqueue::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize};
|
||||
use crate::core::commands::enqueue::image_edit::enqueue_edit_image_command::{EditImageQuality, EnqueueEditImageCommand};
|
||||
use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess;
|
||||
use crate::core::commands::enqueue::text_to_image::enqueue_text_to_image_command::{EnqueueTextToImageRequest, TextToImageSize};
|
||||
use crate::core::events::basic_sendable_event_trait::BasicSendableEvent;
|
||||
@@ -37,13 +38,7 @@ pub async fn handle_artcraft_seedream_4p5_text_to_image(
|
||||
|
||||
let uuid_idempotency_token = generate_random_uuid();
|
||||
|
||||
let image_size = request.aspect_ratio
|
||||
.map(|size| match size {
|
||||
TextToImageSize::Auto => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Square,
|
||||
TextToImageSize::Square => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Square,
|
||||
TextToImageSize::Tall => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
TextToImageSize::Wide => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
});
|
||||
let image_size = get_aspect_ratio(request);
|
||||
|
||||
let num_images = match request.number_images {
|
||||
None => None,
|
||||
@@ -98,3 +93,24 @@ pub async fn handle_artcraft_seedream_4p5_text_to_image(
|
||||
task_type: TaskType::ImageGeneration,
|
||||
})
|
||||
}
|
||||
|
||||
fn get_aspect_ratio(request: &EnqueueTextToImageRequest) -> Option<BytedanceSeedreamV4p5MultiFunctionImageGenImageSize> {
|
||||
if let Some(common_aspect_ratio) = request.common_aspect_ratio {
|
||||
// Handle modern aspect ratio
|
||||
let aspect = aspect_ratio_to_artcraft_seedream_4p5(common_aspect_ratio);
|
||||
return Some(aspect);
|
||||
}
|
||||
|
||||
if let Some(aspect_ratio) = request.aspect_ratio {
|
||||
// Handle deprecated aspect ratio
|
||||
let aspect_ratio = match aspect_ratio {
|
||||
TextToImageSize::Auto => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Square,
|
||||
TextToImageSize::Square => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Square,
|
||||
TextToImageSize::Tall => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitSixteenNine,
|
||||
TextToImageSize::Wide => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeSixteenNine,
|
||||
};
|
||||
return Some(aspect_ratio);
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
Reference in new issue
Block a user