Как поместить изображение в соответствующую папку, если процент ниже 50 от Python - PullRequest
0 голосов
/ 14 февраля 2020
 # loop over the indexes of the high confidence class labels
                for (i, j) in enumerate(idxs):
                    label1 = mlb.classes_[j]  # Label
                    label2 = "{:.2f}%".format(proba[j] * 100)  # Percentage
                    label3 = "{}: {:.2f}%".format(mlb.classes_[j], proba[j] * 100)  # Label and Percentage

                    # accuracy = label2[0][i] * 100
                    text = cv2.putText(output, label3, (10, (i * 30) + 25),
                                       cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 100, 0), 

                    pat = os.path.split(imagePath)
                    print(pat[0])
                    print(pat[1])

                if label1 == "Looking Straight" and label2 >= str(50):
                    path = "D:/Icorve Project/Learn Neural Networks/Categorical/Looking Straight/{}"
                    print(path.format(pat[1]))
                    cv2.imwrite(path.format(pat[1]), output)

                else:
                    path = "D:/Icorve Project/Learn Neural Networks/Categorical/Looking Away/{}"

Здесь есть три класса. Например: 1. Прямой взгляд

for an example if i take Looking straight one the label is printing on on the image saying "Looking straight" : 98.25%  its working perfectly. But i want to put below 50 percentage images to another folder. How to do it ???
Label1 = Class name
label2 = Percentage 
label 3 = Class name + percentage       

: GeForce GTX 1050 Ti, идентификатор шины pci: 0000: 01: 00.0, вычислительные возможности: 6.1) ПРЕДУПРЕЖДЕНИЕ: тензор потока: ошибка загрузки сохраненного состояния оптимизатора. В результате ваша модель запускается с недавно инициализированным оптимизатором. [INFO] классифицирующее изображение ... examples data_248000_249000.h5_922.png D: / Icorve Project / Изучение нейронных сетей / Категориальное / Прямой взгляд / data_248000_249000.h5_922.png (531, 413) (531, 413, 3) (180, 140 , 1)

1 Ответ

0 голосов
/ 14 февраля 2020

Полагаю, что первое if находится внутри для l oop.

Тогда вы можете использовать:

proba[j] >= 0.5

Вместо

label2 >= str(50)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...