Giter Club home page Giter Club logo

Comments (11)

JFMeyer2k avatar JFMeyer2k commented on August 24, 2024 3

After I trained a yolov9-e model, I wanted to run inference using detect.py with

python3 detect.py --weights $EC_MODEL_PATH --conf-thres 0.1 --imgsz 640 --source $EC2_INPUT_PATH --project $EC2_OUTPUT_PATH --device 0 --nosave --save-txt

where $EC_MODEL_PATH is the path to the model, $EC2_INPUT_PATH is the place where the images are I want to run the inference for, and $EC2_OUTPUT_PATH is the path where the output is supposed to be written to.

I run into the error:

[ec2-user@ip-xxx-xxx-xxx-xxx yolov9]$ python3 detect.py --weights $EC_MODEL_PATH --conf-thres 0.1 --imgsz 640 --source $EC2_INPUT_PATH --project $EC2_OUTPUT_PATH --device 0 --nosave --save-txt
detect: weights=['/home/ec2-user/yolo/yolov9//runs/train/yolov9-e4/weights/best.pt'], source=/home/ec2-user/yolo/images/inference/Test/GoPro_Academy_Dubai_vs_Banaat_FC/images_tiled, data=data/coco128.yaml, imgsz=[640, 640], conf_thres=0.1, iou_thres=0.45, max_det=1000, device=0, view_img=False, save_txt=True, save_conf=False, save_crop=False, nosave=True, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=/home/ec2-user/yolo/yolov9/runs/val/, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1
YOLOv5 🚀 v0.1-26-g6d91e97 Python-3.10.9 torch-2.2.1+cu121 CUDA:0 (NVIDIA A10G, 22516MiB)

Fusing layers... 
yolov9-e summary: 839 layers, 68547814 parameters, 0 gradients, 240.7 GFLOPs
Traceback (most recent call last):
  File "/home/ec2-user/yolo/yolov9/detect.py", line 231, in <module>
    main(opt)
  File "/home/ec2-user/yolo/yolov9/detect.py", line 226, in main
    run(**vars(opt))
  File "/opt/conda/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/home/ec2-user/yolo/yolov9/detect.py", line 102, in run
    pred = non_max_suppression(pred, conf_thres, iou_thres, classes, agnostic_nms, max_det=max_det)
  File "/home/ec2-user/yolo/yolov9/utils/general.py", line 905, in non_max_suppression
    device = prediction.device
AttributeError: 'list' object has no attribute 'device'

The error got fixed as per Jaykumaran suggestion by chaging line 903 within /utils/general.py

from:
prediction = prediction[0] # select only inference output

to:
prediction = prediction[0][1]

from yolov9.

Jaykumaran avatar Jaykumaran commented on August 24, 2024 2

For list device not found ,under utils->general.py change line 903 as
prediction = prediction[0][1]
for yolov9-c.pt or yolov9-e.pt.
However for yolov9-c-converted you can run repo without any change

from yolov9.

hhzhao0525 avatar hhzhao0525 commented on August 24, 2024 1

device = prediction[1]

The correct writing should be: "device = prediction.device."

from yolov9.

WongKinYiu avatar WongKinYiu commented on August 24, 2024

I do not know meaning of device = prediction[1].

from yolov9.

zahidzqj avatar zahidzqj commented on August 24, 2024

I do not know meaning of device = prediction[1].

应该是书写错误了吧

我在运行detect.py时,发现prediction是[[[tesnor ... ], [tesnor ...]], [[tesnor ... ], [tesnor ...]]],在nms的时候必须按照下面的方式获取数据才不会报错,不知道为何会这样:
if isinstance(prediction, (list, tuple)): # YOLO model in validation model, output = (inference_out, loss_out)
# prediction = prediction[0] # select only inference output yolov9源代码
prediction = prediction[0][0] # select only inference output zqj20240226
# prediction = prediction[0][1] # select only inference output zqj20240226
device = prediction.device

from yolov9.

ASzhaoqiang avatar ASzhaoqiang commented on August 24, 2024

I do not know meaning of device = prediction[1].

应该是书写错误了吧

我在运行detect.py时,发现prediction是[[[tesnor ... ], [tesnor ...]], [[tesnor ... ], [tesnor ...]]],在nms的时候必须按照下面的方式获取数据才不会报错,不知道为何会这样: if isinstance(prediction, (list, tuple)): # YOLO model in validation model, output = (inference_out, loss_out) # prediction = prediction[0] # select only inference output yolov9源代码 prediction = prediction[0][0] # select only inference output zqj20240226 # prediction = prediction[0][0] # select only inference output zqj20240226 device = prediction.device

although not ERROR , only solves the first pic of folder... if you want to apply NMS to every pic, just iterate

from yolov9.

zahidzqj avatar zahidzqj commented on August 24, 2024

I do not know meaning of device = prediction[1].

应该是书写错误了吧

我在运行detect.py时,发现prediction是[[[tesnor ... ], [tesnor ...]], [[tesnor ... ], [tesnor ...]]],在nms的时候必须按照下面的方式获取数据才不会报错,不知道为何会这样: if isinstance(prediction, (list, tuple)): # YOLO model in validation model, output = (inference_out, loss_out) # prediction = prediction[0] # select only inference output yolov9源代码 prediction = prediction[0][0] # select only inference output zqj20240226 # prediction = prediction[0][0] # select only inference output zqj20240226 device = prediction.device

I do not know meaning of device = prediction[1].

应该是书写错误了吧

我在运行detect.py时,发现prediction是[[[tesnor ... ], [tesnor ...]], [[tesnor ... ], [tesnor ...]]],在nms的时候必须按照下面的方式获取数据才不会报错,不知道为何会这样: if isinstance(prediction, (list, tuple)): # YOLO model in validation model, output = (inference_out, loss_out) # prediction = prediction[0] # select only inference output yolov9源代码 prediction = prediction[0][0] # select only inference output zqj20240226 # prediction = prediction[0][1] # select only inference output zqj20240226 device = prediction.device

Why are there two results and there is a difference between them?

from yolov9.

rkuo2000 avatar rkuo2000 commented on August 24, 2024

For list device not found ,under utils->general.py change line 903 as prediction = prediction[0][1] for yolov9-c.pt or yolov9-e.pt. However for yolov9-c-converted you can run repo without any change

Thanks a lot, it works.

from yolov9.

rkuo2000 avatar rkuo2000 commented on August 24, 2024

detect.py working on Kaggle after using
prediction = prediction[0][1] in /utils/general.py

from yolov9.

WongKinYiu avatar WongKinYiu commented on August 24, 2024

yolo-*.yaml: use detect_dual.py.
gelan-*.yaml: use detect.py.

from yolov9.

wgqhandsome avatar wgqhandsome commented on August 24, 2024

yolo-*.yaml: use detect_dual.py.

gelan-*.yaml: use detect.py.

Mark. Thank you

from yolov9.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.