ссылка на описание в результатах, небольшие правки в сталях
Gitea Actions Demo / build_and_push (push) Successful in 1m17s
Details
Gitea Actions Demo / build_and_push (push) Successful in 1m17s
Details
This commit is contained in:
parent
f63a2cf81e
commit
9f06b5567a
|
|
@ -40,6 +40,7 @@ class RecognizerService:
|
||||||
predicted_data = self._predict(image, DOG_MODEL)
|
predicted_data = self._predict(image, DOG_MODEL)
|
||||||
results = {}
|
results = {}
|
||||||
images = []
|
images = []
|
||||||
|
description = {}
|
||||||
images_dogs = await self._repository.images_dogs()
|
images_dogs = await self._repository.images_dogs()
|
||||||
for d in predicted_data:
|
for d in predicted_data:
|
||||||
predicted_idx, probabilities = d
|
predicted_idx, probabilities = d
|
||||||
|
|
@ -54,10 +55,12 @@ class RecognizerService:
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
description.setdefault(name, []).append(f"/dogs-characteristics/{name.replace(" ", "_")}")
|
||||||
results[probabilities] = name
|
results[probabilities] = name
|
||||||
return {
|
return {
|
||||||
"results": results,
|
"results": results,
|
||||||
"images": images,
|
"images": images,
|
||||||
|
"description": description,
|
||||||
}
|
}
|
||||||
|
|
||||||
async def predict_cat_image(self, image: bytes) -> dict:
|
async def predict_cat_image(self, image: bytes) -> dict:
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,12 @@ async function SavePhoto(self) {
|
||||||
|
|
||||||
// Обработка основных результатов
|
// Обработка основных результатов
|
||||||
for (let key in json.results) {
|
for (let key in json.results) {
|
||||||
text += `<div class='image-block'><div class='image-text'>${json.results[key]} (вероятность: ${Math.round(parseFloat(key) * 100)}%)</div>`;
|
if (json.description != undefined) {
|
||||||
|
text += `<div class='image-block'><div class='image-text'>${json.results[key]} (вероятность: ${Math.round(parseFloat(key) * 100)}%) <br/><a href="${json.description[json.results[key]]}" target='_blank'>Описание </a></div>`;
|
||||||
|
} else {
|
||||||
|
text += `<div class='image-block'><div class='image-text'>${json.results[key]} (вероятность: ${Math.round(parseFloat(key) * 100)}%)</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Поиск всех изображений для текущего результата
|
// Поиск всех изображений для текущего результата
|
||||||
let allUrls = [];
|
let allUrls = [];
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,10 @@ form {
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#file-input {
|
||||||
|
max-width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
input[type="submit"] {
|
input[type="submit"] {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
|
@ -209,6 +213,7 @@ input[type="text"]:hover {
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
transition: transform 0.2s;
|
transition: transform 0.2s;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Адаптация для мобильных */
|
/* Адаптация для мобильных */
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,6 @@
|
||||||
{% block form %}{% endblock %}
|
{% block form %}{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
</section>
|
</section>
|
||||||
<script src="/static/scripts.js?v=5"></script>
|
<script src="/static/scripts.js?v=6"></script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue