opencv - 如果 Python 的百分比低于 50,如何将图像放入相关文件夹
问题描述
# 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 总线 ID:0000:01:00.0,计算能力:6.1)警告:tensorflow:加载保存的优化器状态时出错。因此,您的模型从一个新初始化的优化器开始。[INFO] 图像分类...示例 data_248000_249000.h5_922.png D:/Icorve Project/Learn Neural Networks/Categorical/Looking Straight/data_248000_249000.h5_922.png (531, 413) (531, 413, 3) (180, 140 , 1)
解决方案
我想第一个 if 在 for 循环内。
然后,您可以使用:
proba[j] >= 0.5
代替
label2 >= str(50)
推荐阅读
- javascript - Cannot read property 'online' of undefined
- python - FastAPI:如何通过 API 下载字节
- java - @PutMapping 的 JUnit RestControllerTest 抛出 InvocationTargetException
- java - 调用存储过程时返回相同的记录
- javascript - Chrome Mobile 中的隐藏 URL 栏调整大小问题是否有最新修复?
- django - 如何在自定义分页django rest框架中为每页添加多个项目
- python - 是否可以使用 discord.py 将自定义反应图像文件从您的计算机添加到您的消息中?
- bash - 循环遍历日期 Mac OSX Terminal Bash
- jquery - 从nodejs发送数据到html页面
- sql - 具有两列的 T-SQL 顺序更新