python - detectObjectsFromImage 方法的问题
问题描述
我正在尝试执行对象检测操作,向程序发送图像,它会将新图像返回到指定位置,其中包含在原始图像中检测到的对象。我正在关注一些现有代码并尝试运行它,但它不会让我这样做,因为该detectObjectsFromImage
方法存在错误。具体来说,它的参数被标记为红色,即 input_image 和 output_image_path。他们需要一个字符串,我确实给了他们(我的图像的路径),但它仍然给我这个错误。我还imageAI
使用pip
. 我不确定问题出在哪里,所以如果有人可以提供帮助,我将不胜感激。代码附在下面。
from imageai.Detection import ObjectDetection
detector = ObjectDetection()
model_path = "yolo-tiny.h5"
input_path = "./input/sampleimage.jpg"
output_path = "./output/newimage.jpg"
detector.setModelTypeAsTinyYOLOv3()
detector.setModelPath(model_path)
detector.loadModel()
detection = detector.detectObjectsFromImage(input_image=input_path, output_image_path=output_path, input_type="file", output_type="file")
for eachItem in detection:
print(eachItem["name"] , " : ", eachItem["percentage_probability"])
解决方案
推荐阅读
- ruby-on-rails - 如何在 If else 语句检查中分配变量
- python-3.x - cv2.error: (-215) size.width>0 && size.height>0 in function cv::imshow
- python - 无法跨多个模块导入 re
- flutter - 如何在 Column 中对齐 Widget?
- elixir - 在 Elixir 宏中获取当前范围的文档
- java - findViewById 在 Fragment 中找不到 ImageButton
- spring - Spring Data MongoDB XML 配置无法针对 Mongo 数据库进行身份验证
- shell - 在 Windows 上更改 Git Bash 的默认驱动器
- node.js - Sequelize, Typescript - typescript 对模型的 getter 方法出错
- c# - 在 Task 中将当前模型转换为 JSON
MVC.NET Core 应用程序中的 OnPostAsync 方法