@@ -27,6 +27,11 @@ class Flux(SimpleService): }, } + OPTIMIZATION_PROMPT = """ + Clean composition with clear subject hierarchy. Soft natural lighting, accurate proportions, and coherent geometry. + Sharp key details with minimal visual noise and artifacts. + """ + def calculate_price(self, input_message: Message, version: str) -> Decimal: price_map = self.TOKENS_COST[version] price = price_map['input_imgs'] @@ -70,17 +75,9 @@ class Flux(SimpleService): start_time = time.time() version = input_message.info.get('version') user_prompt = self.translate_prompt(input_message.content) - prompt = f""" - {user_prompt}. - Clear main subject and coherent scene context. - Balanced composition with readable foreground, midground, and background. - Natural, consistent lighting with clean shadows and good tonal balance. - Accurate proportions, clean geometry, and stable spatial relationships. - Crisp important details, clear textures, and minimal visual artifacts. - """ callback_data = dict( { - 'prompt': prompt, + 'prompt': f"{user_prompt}\n{self.OPTIMIZATION_PROMPT}", 'go_fast': False, 'output_quality': 100, **input_message.info, @@ -19,6 +19,10 @@ from payments.selectors.payment_plan_selector import PaymentPlanSelector class Fluxpulid(SimpleService): TOKEN_COST = Decimal('15.0') ENDPOINT = 'bytedance/flux-pulid:8baa7ef2255075b46f4d91cd238c21d31181b3e6a864463f967960bb0112525b' + OPTIMIZATION_PROMPT = """ + Faithful identity match with stable face anatomy. + Soft contrast, clear expression, and realistic skin detail. Artifact-free render and coherent composition. + """ @classmethod def predict_price(cls, content: str, file_exists: bool, info: dict[str, Any]) -> Decimal | None: @@ -61,7 +65,7 @@ class Fluxpulid(SimpleService): translated_prompt = self.translate_prompt(input_message.content) callback_data = dict( { - 'prompt': translated_prompt, + 'prompt': f"{translated_prompt}\n{self.OPTIMIZATION_PROMPT}", 'main_face_image': BytesIO(input_message.file.read()), 'output_quality': 100, 'output_format': 'png', @@ -52,6 +52,12 @@ class Gptimage(SimpleService): '1024x1536': 1372, }, } + + OPTIMIZATION_PROMPT = """ + Clean composition and consistent perspective. Natural color harmony, realistic texture detail, and sharp subject focus. + Low visual noise with reliable final quality. + """ + def __init__(self, store: BaseStore) -> None: super().__init__(store) self.logger = logging.getLogger(self.__class__.__name__) @@ -106,7 +112,7 @@ class Gptimage(SimpleService): for proxy in Proxy.objects.all(): moderation = 'low' if self.store.user.account_type == 'regular' else 'auto' json_data = { - 'prompt': input_message.content, + 'prompt': f"{input_message.content}\n{self.OPTIMIZATION_PROMPT}", 'model': 'gpt-image-2', 'n': 1, 'quality': quality, @@ -23,6 +23,11 @@ from payments.selectors.payment_plan_selector import PaymentPlanSelector class Grok_Image(SimpleService): TOKENS_COST = Decimal('4') + OPTIMIZATION_PROMPT = """ + Balanced scene layout and clear subject separation. Realistic color balance, soft depth cues, and clean edges. + Consistent details without excessive stylization. + """ + def calculate_price(self) -> Decimal: return self.TOKENS_COST @@ -46,7 +51,7 @@ class Grok_Image(SimpleService): raise InsufficientBalance(balance, self.TOKENS_COST) callback_data = dict( { - 'prompt': self.translate_prompt(input_message.content), + 'prompt': f"{self.translate_prompt(input_message.content)}\n{self.OPTIMIZATION_PROMPT}", **input_message.info, } ) @@ -16,6 +16,12 @@ from ml_model.tasks import replicate_run class Seedream(SimpleService): PRICE = Decimal('10.5') + OPTIMIZATION_PROMPT = """ + Subject: one clear focal subject; same mood as the scene below. + Scene: simple background; avoid crowds, clutter, tiny props, dense patterns. + Light: one coherent light setup. No text, logos, or watermark in the image. + """ + @classmethod def predict_price(cls, content: str, file_exists: bool, info: dict[str, Any]) -> Decimal | None: return cls.PRICE.quantize(Decimal('0.1'), rounding='ROUND_UP') @@ -45,7 +51,7 @@ class Seedream(SimpleService): 'match_input_image' if raw_aspect_ratio == 'Исходное изображение' else raw_aspect_ratio ) callback_data = { - 'prompt': input_message.content, + 'prompt': f"{input_message.content}\n{self.OPTIMIZATION_PROMPT}", 'aspect_ratio': aspect_ratio, **input_message.info, }