image s imsages images model fixes new model see dream
This commit is contained in:
@@ -187,22 +187,42 @@ def process_image_generation_queue(self, image_ids: list, account_id: int = None
|
||||
logger.info("[process_image_generation_queue] Step 1: Loading image generation settings")
|
||||
from igny8_core.modules.system.ai_settings import AISettings
|
||||
from igny8_core.ai.model_registry import ModelRegistry
|
||||
from igny8_core.business.billing.models import AIModelConfig
|
||||
|
||||
# Get effective settings
|
||||
image_type = AISettings.get_effective_image_style(account)
|
||||
image_format = 'webp' # Default format
|
||||
|
||||
# Get default image model from database
|
||||
default_model = ModelRegistry.get_default_model('image')
|
||||
if default_model:
|
||||
model_config = ModelRegistry.get_model(default_model)
|
||||
provider = model_config.provider if model_config else 'openai'
|
||||
model = default_model
|
||||
# Get user's selected quality tier (from account settings)
|
||||
quality_tier = AISettings.get_effective_quality_tier(account)
|
||||
logger.info(f"[process_image_generation_queue] User's quality tier: {quality_tier}")
|
||||
|
||||
# Find image model based on quality tier (DYNAMIC from database)
|
||||
model_config = None
|
||||
if quality_tier:
|
||||
model_config = AIModelConfig.objects.filter(
|
||||
model_type='image',
|
||||
quality_tier=quality_tier,
|
||||
is_active=True
|
||||
).first()
|
||||
|
||||
# Fallback to default image model if no tier match
|
||||
if not model_config:
|
||||
default_model = ModelRegistry.get_default_model('image')
|
||||
if default_model:
|
||||
model_config = ModelRegistry.get_model(default_model)
|
||||
|
||||
# Set provider and model from database config
|
||||
if model_config:
|
||||
provider = model_config.provider or 'openai'
|
||||
model = model_config.model_name
|
||||
else:
|
||||
# Ultimate fallback (should never happen if database is configured)
|
||||
logger.warning("[process_image_generation_queue] No image model found in database, using fallback")
|
||||
provider = 'openai'
|
||||
model = 'dall-e-3'
|
||||
|
||||
logger.info(f"[process_image_generation_queue] Using PROVIDER: {provider}, MODEL: {model} from settings")
|
||||
logger.info(f"[process_image_generation_queue] Using PROVIDER: {provider}, MODEL: {model} from AIModelConfig")
|
||||
|
||||
# Style to prompt enhancement mapping
|
||||
# These style descriptors are added to the image prompt for better results
|
||||
@@ -225,25 +245,23 @@ def process_image_generation_queue(self, image_ids: list, account_id: int = None
|
||||
style_description = STYLE_PROMPT_MAP.get(image_type, STYLE_PROMPT_MAP.get('photorealistic'))
|
||||
logger.info(f"[process_image_generation_queue] Style: {image_type} -> prompt enhancement: {style_description[:50]}...")
|
||||
|
||||
# Model-specific landscape sizes (square is always 1024x1024)
|
||||
# For Runware models - based on Runware documentation for optimal results per model
|
||||
# For OpenAI DALL-E 3 - uses 1792x1024 for landscape
|
||||
MODEL_LANDSCAPE_SIZES = {
|
||||
'runware:97@1': '1280x768', # Hi Dream Full landscape
|
||||
'bria:10@1': '1344x768', # Bria 3.2 landscape (16:9)
|
||||
'google:4@2': '1376x768', # Nano Banana landscape (16:9)
|
||||
'dall-e-3': '1792x1024', # DALL-E 3 landscape
|
||||
'dall-e-2': '1024x1024', # DALL-E 2 only supports square
|
||||
}
|
||||
DEFAULT_SQUARE_SIZE = '1024x1024'
|
||||
|
||||
# Get model-specific landscape size for featured images
|
||||
model_landscape_size = MODEL_LANDSCAPE_SIZES.get(model, '1792x1024' if provider == 'openai' else '1280x768')
|
||||
# Load image sizes from AIModelConfig (DYNAMIC from database)
|
||||
# model_config was loaded above based on quality tier
|
||||
if model_config:
|
||||
# Get sizes from database (single source of truth)
|
||||
model_landscape_size = model_config.landscape_size or '1792x1024'
|
||||
model_square_size = model_config.square_size or '1024x1024'
|
||||
logger.info(f"[process_image_generation_queue] Loaded sizes from AIModelConfig: landscape={model_landscape_size}, square={model_square_size}")
|
||||
else:
|
||||
# Fallback sizes if no model config (should never happen)
|
||||
model_landscape_size = '1792x1024'
|
||||
model_square_size = '1024x1024'
|
||||
logger.warning(f"[process_image_generation_queue] No model config, using fallback sizes")
|
||||
|
||||
# Featured image always uses model-specific landscape size
|
||||
featured_image_size = model_landscape_size
|
||||
# In-article images: alternating square/landscape based on position (handled in image loop)
|
||||
in_article_square_size = DEFAULT_SQUARE_SIZE
|
||||
in_article_square_size = model_square_size
|
||||
in_article_landscape_size = model_landscape_size
|
||||
|
||||
logger.info(f"[process_image_generation_queue] Settings loaded:")
|
||||
|
||||
Reference in New Issue
Block a user