get several results + deploy
Gitea Actions Demo / build_and_push (push) Failing after 47s
Details
Gitea Actions Demo / build_and_push (push) Failing after 47s
Details
This commit is contained in:
parent
bff80715b6
commit
486e5d0d57
|
|
@ -21,4 +21,4 @@ jobs:
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: https://gitea.webart-tech.ru/webart/beerds:${{ gitea.sha }}
|
tags: https://gitea.webart-tech.ru/webart/beerds/backend:${{ gitea.sha }}
|
||||||
|
|
@ -5,4 +5,4 @@ services:
|
||||||
image: ai:latest
|
image: ai:latest
|
||||||
ports:
|
ports:
|
||||||
- 8000:8000
|
- 8000:8000
|
||||||
restart: always
|
restart: 'no'
|
||||||
|
|
@ -12,7 +12,7 @@ ImageFile.LOAD_TRUNCATED_IMAGES = True
|
||||||
print(f"Using device: {DEVICE}")
|
print(f"Using device: {DEVICE}")
|
||||||
IMG_SIZE = (180, 180)
|
IMG_SIZE = (180, 180)
|
||||||
INPUT_DIR = "assets/dog"
|
INPUT_DIR = "assets/dog"
|
||||||
NUM_EPOCHS = 10
|
NUM_EPOCHS = 100
|
||||||
MODEL_NAME = "dogs_model.pth"
|
MODEL_NAME = "dogs_model.pth"
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -61,14 +61,14 @@ def predict_image(image, model, device="cuda") -> list[tuple]:
|
||||||
|
|
||||||
with torch.no_grad():
|
with torch.no_grad():
|
||||||
output = model(input_batch)
|
output = model(input_batch)
|
||||||
data = []
|
|
||||||
for i in range(3):
|
|
||||||
if i >= len(output):
|
|
||||||
break
|
|
||||||
probabilities = F.softmax(output[i], dim=0)
|
|
||||||
|
|
||||||
_, predicted_idx = torch.max(probabilities, 0)
|
probabilities = torch.nn.functional.softmax(output[0], dim=0)
|
||||||
data.append((predicted_idx.item(), probabilities.cpu().numpy()))
|
k = 5
|
||||||
|
topk_probs, predicted_idx = torch.topk(probabilities, k)
|
||||||
|
|
||||||
|
data = []
|
||||||
|
for i in range(k):
|
||||||
|
data.append((predicted_idx[i].item(), float(topk_probs[i].item())))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ class BeerdsController(Controller):
|
||||||
predicted_label = labels_dogs[str(predicted_idx)]
|
predicted_label = labels_dogs[str(predicted_idx)]
|
||||||
name = predicted_label.replace("_", " ")
|
name = predicted_label.replace("_", " ")
|
||||||
images.append({"name": name, "url": IMAGES[name]})
|
images.append({"name": name, "url": IMAGES[name]})
|
||||||
results[float(probabilities[0])] = name
|
results[probabilities] = name
|
||||||
return {
|
return {
|
||||||
"results": results,
|
"results": results,
|
||||||
"images": images,
|
"images": images,
|
||||||
|
|
@ -108,7 +108,7 @@ class BeerdsController(Controller):
|
||||||
for d in predicted_data:
|
for d in predicted_data:
|
||||||
predicted_idx, probabilities = d
|
predicted_idx, probabilities = d
|
||||||
predicted_label = labels_cats[str(predicted_idx)]
|
predicted_label = labels_cats[str(predicted_idx)]
|
||||||
results[float(probabilities[0])] = predicted_label
|
results[probabilities] = predicted_label
|
||||||
return {
|
return {
|
||||||
"results": results,
|
"results": results,
|
||||||
"images": [],
|
"images": [],
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ async function SavePhoto(self) {
|
||||||
let text = "<h3 class='image-results'>Результаты</h3>";
|
let text = "<h3 class='image-results'>Результаты</h3>";
|
||||||
let uniqChecker = {};
|
let uniqChecker = {};
|
||||||
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)*10)/10 + ")</div>";
|
text += "<div class='image-block'><div class='image-text'>" + json.results[key] + " (вероятность: " + Math.round(parseFloat(key)*100) + "%)</div>";
|
||||||
for (let imgKey in json.images) {
|
for (let imgKey in json.images) {
|
||||||
if (json.images[imgKey].name != json.results[key]) {
|
if (json.images[imgKey].name != json.results[key]) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue