首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ImageAI对象检测速度非常慢

ImageAI对象检测速度非常慢
EN

Stack Overflow用户
提问于 2021-07-18 21:09:12
回答 1查看 208关注 0票数 0

我一直试图制作一个程序,它可以使用python识别屏幕上的对象。在本教程:https://stackabuse.com/object-detection-with-imageai-in-python的帮助下,我创建了以下代码。

代码语言:javascript
复制
import pyautogui
import cv2
import time
import os

os.add_dll_directory("C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/bin")

from imageai.Detection import ObjectDetection
import tensorflow as tf

detector = ObjectDetection()

model_path = "./models/yolo-tiny.h5"
input_path = "./input/test45.jpg"
output_path = "./output/newimage.jpg"

detector.setModelTypeAsTinyYOLOv3()
detector.setModelPath(model_path)
detector.loadModel(detection_speed="fastest")
while True:
    start_time = time.time()
    x = np.array(pyautogui.screenshot())
    x = cv2.cvtColor(x, cv2.COLOR_BGR2RGB)
    y, detection = detector.detectObjectsFromImage(input_type="array", input_image=x, output_type="array")
    for eachItem in detection:
        print(eachItem["name"] , " : ", eachItem["percentage_probability"])
    print("FPS: ", 1.0 / (time.time() - start_time))

我希望能够达到20-30 fps,然而,我只能得到大约1 fps,我不知道是什么减慢了它。

我的规格是:

  • 2 x RTX 3060
  • Intel i7 4770
  • 24 i7

我们非常感谢所有的帮助。

EN

回答 1

Stack Overflow用户

发布于 2022-07-19 14:39:21

程序是使用您的CPU还是GPU?如果它使用CPU,您可能需要检查是否安装了tensorflow-gpu的正确版本(如果有的话)。ImageAI会更喜欢你的GPU,如果它有它的访问,但20-30 GPU几乎是不可能的-太低效率。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68433103

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档