@@ -593,6 +593,10 @@ msgstr "Модель" msgid "Settings" msgstr "Настройки" +#: ml_model/exceptions.py:20 +msgid "The model is not responding" +msgstr "Модель не отвечает" + #: ml_model/models.py:172 #, python-format msgid "Settings of %(model_title)s" @@ -11,7 +11,7 @@ from django.core.files import File from messages.models import Message -from ml_model.models import ModelInput +from ml_model.exceptions import ModelTimeoutError from ml_model.services.base import SimpleService @@ -70,6 +70,7 @@ class Fluxlorafast(SimpleService): 'path': 'https://huggingface.co/Shakker-Labs/FLUX.1-dev-LoRA-Logo-Design/resolve/main/FLUX-dev-lora-Logo-Design.safetensors' }, } + requests_number = 0 start_time = time.time() version = input_message.info.get('version') translated_prompt = self.translate_prompt(input_message.content) @@ -77,9 +78,8 @@ class Fluxlorafast(SimpleService): { 'prompt': translated_prompt, 'model_version': 'fb90c17a-d410-41e7-9961-dc7c687bc627', - 'image_size': sizes.get(input_message.info.pop('image_size', None), '4:3'), - 'loras': [loras.get(input_message.info.pop('loras', None), 'Realistic')], - **input_message.info, + 'image_size': sizes.get(input_message.info.get('image_size', '1:1')), + 'loras': [loras.get(input_message.info.get('lora', 'Realistic'))], } ) client = httpx.Client( @@ -95,6 +95,9 @@ class Fluxlorafast(SimpleService): status = client.get(result['status_url']).json() if status.get('status') == 'COMPLETED': break + requests_number += 1 + if requests_number == 271: + raise ModelTimeoutError time.sleep(1/3) process_time = timedelta(seconds=(time.time() - start_time)) final_result = client.get(result['response_url']).json() @@ -15,3 +15,8 @@ class LargeResourceConsumptionException(Exception): ... class DeploymentDisabled(Exception): def __str__(self): return _('The model is currently disabled. Please try again later.') + + +class ModelTimeoutError(Exception): + def __str__(self): + return _('The model is not responding')