diff --git a/server/services/recognizer/service.py b/server/services/recognizer/service.py index 870082a..59d6737 100644 --- a/server/services/recognizer/service.py +++ b/server/services/recognizer/service.py @@ -40,6 +40,7 @@ class RecognizerService: predicted_data = self._predict(image, DOG_MODEL) results = {} images = [] + description = {} images_dogs = await self._repository.images_dogs() for d in predicted_data: predicted_idx, probabilities = d @@ -54,10 +55,12 @@ class RecognizerService: ], } ) + description.setdefault(name, []).append(f"/dogs-characteristics/{name.replace(" ", "_")}") results[probabilities] = name return { "results": results, "images": images, + "description": description, } async def predict_cat_image(self, image: bytes) -> dict: diff --git a/server/static/scripts.js b/server/static/scripts.js index 75f1824..c923fcc 100644 --- a/server/static/scripts.js +++ b/server/static/scripts.js @@ -32,7 +32,12 @@ async function SavePhoto(self) { // Обработка основных результатов for (let key in json.results) { - text += `
${json.results[key]} (вероятность: ${Math.round(parseFloat(key) * 100)}%)
`; + if (json.description != undefined) { + text += `
${json.results[key]} (вероятность: ${Math.round(parseFloat(key) * 100)}%)
Описание
`; + } else { + text += `
${json.results[key]} (вероятность: ${Math.round(parseFloat(key) * 100)}%)
`; + } + // Поиск всех изображений для текущего результата let allUrls = []; diff --git a/server/static/styles.css b/server/static/styles.css index 74f0562..cd7c519 100644 --- a/server/static/styles.css +++ b/server/static/styles.css @@ -129,6 +129,10 @@ form { left: 0; } +#file-input { + max-width: 80%; +} + input[type="submit"] { padding: 10px; color: #fff; @@ -209,6 +213,7 @@ input[type="text"]:hover { border-radius: 6px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); transition: transform 0.2s; + cursor: pointer; } /* Адаптация для мобильных */ diff --git a/server/templates/base.html b/server/templates/base.html index f5d58b2..7ecd5af 100644 --- a/server/templates/base.html +++ b/server/templates/base.html @@ -45,6 +45,6 @@ {% block form %}{% endblock %} - +