ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.93k stars 16.4k forks source link

#10244 'Tensor' object has no attribute 'pandas' #10257

Closed breaveSun closed 1 year ago

breaveSun commented 1 year ago

Search before asking

Question

code : yolo_model = torch.hub.load(repo_or_dir='/yolov5', model='yolov5s',pretrained=True,source='local') img = Image.open('/yolov5/data/images/zidane.jpg').resize((640,480),Image.Resampling.LANCZOS) img = torch.tensor(np.array(img)).permute((2,0,1)).unsqueeze(0) img = img.float()/255 img = img.cuda() result = model(img) print(result.pandas()) print result: tensor([[[3.86082e+00, 3.59408e+00, 8.77209e+00, ..., 1.26700e-03, 6.60222e-04, 2.63195e-03], [1.33856e+01, 4.16720e+00, 2.75875e+01, ..., 1.48501e-03, 1.06083e-03, 2.77131e-03], [1.82907e+01, 4.55514e+00, 3.32699e+01, ..., 1.20625e-03, 7.86196e-04, 2.23856e-03], ..., [5.69853e+02, 4.47487e+02, 1.29333e+02, ..., 1.77663e-03, 1.07624e-03, 6.96758e-04], [5.93650e+02, 4.41728e+02, 9.77063e+01, ..., 1.53087e-03, 8.04971e-04, 6.77827e-04], [6.14671e+02, 4.49220e+02, 1.13250e+02, ..., 1.52358e-03, 7.78174e-04, 7.11288e-04]]], device='cuda:0'), [tensor([[[[[-3.47987e-02, -1.01568e-01, -1.26982e-01, ..., -6.66984e+00, -7.32227e+00, -5.93739e+00], [ 3.49940e-01, 4.18052e-02, 1.58899e+00, ..., -6.51085e+00, -6.84764e+00, -5.88566e+00], [-4.34023e-01, 1.39009e-01, 2.33833e+00, ..., -6.71903e+00, -7.14752e+00, -6.09968e+00], ..., [ 1.16358e+00, 8.81170e-02, 1.41824e+00, ..., -6.71834e+00, -7.38348e+00, -5.88806e+00], [ 3.59448e-01, 1.38850e-01, 1.19550e+00, ..., -6.52709e+00, -7.24878e+00, -6.24815e+00], [-3.26910e-02, 1.57553e-01, -1.50827e-02, ..., -6.67337e+00, -7.35457e+00, -6.04706e+00]],

      [[ 1.37894e-01, -2.10982e-01, -8.40271e-02,  ..., -6.36400e+00, -6.98056e+00, -5.86192e+00],
       [ 4.87386e-01,  8.22146e-02,  1.71928e+00,  ..., -5.95706e+00, -6.48687e+00, -5.83755e+00],
       [-2.31260e-01,  5.52574e-01,  2.73248e+00,  ..., -6.18929e+00, -6.73345e+00, -6.06802e+00],
       ...,
       [ 1.43465e+00, -3.57181e-02,  1.56824e+00,  ..., -6.50030e+00, -7.19598e+00, -6.02788e+00],
       [ 2.10367e-02, -4.41792e-02,  1.28583e+00,  ..., -6.40045e+00, -6.99221e+00, -6.35566e+00],
       [-4.64081e-02, -2.44891e-01, -2.71335e-02,  ..., -6.44232e+00, -7.05963e+00, -6.00501e+00]],

……………………

      [[ 2.30540e+00, -5.62382e-01, -1.08178e+00,  ..., -7.00679e+00, -7.67982e+00, -7.73072e+00],
       [ 2.08678e-01, -7.54450e-01, -1.03373e+00,  ..., -7.39813e+00, -7.92476e+00, -7.98614e+00],
       [-2.43680e+00, -6.49377e-01, -1.01546e+00,  ..., -7.04536e+00, -7.12933e+00, -7.66890e+00],
       ...,
       [ 1.67003e+00, -6.70835e-01, -9.62933e-01,  ..., -7.19961e+00, -7.13754e+00, -7.16907e+00],
       [-5.80533e-02, -1.97500e+00, -1.05654e+00,  ..., -7.62597e+00, -8.19621e+00, -8.23490e+00],
       [-2.68525e+00, -5.80157e-01, -1.08498e+00,  ..., -7.61615e+00, -8.18054e+00, -8.17653e+00]],

      [[ 1.68515e+00, -2.06620e-01, -1.07232e+00,  ..., -6.31920e+00, -7.01831e+00, -7.29419e+00],
       [ 1.20343e-01, -7.64228e-01, -1.05718e+00,  ..., -6.64125e+00, -6.94611e+00, -7.51884e+00],
       [-9.70882e-01, -5.40509e-01, -1.01695e+00,  ..., -6.96098e+00, -6.48369e+00, -7.79033e+00],
       ...,
       [ 8.71389e-01, -1.87159e+00, -9.20802e-01,  ..., -6.32444e+00, -6.68240e+00, -6.59768e+00],
       [-1.25046e-01, -1.96978e+00, -1.05331e+00,  ..., -7.03432e+00, -7.76616e+00, -7.89993e+00],
       [-1.38845e+00, -1.35504e+00, -1.03599e+00,  ..., -6.90443e+00, -7.58017e+00, -7.61079e+00]],

      [[ 3.30403e-01, -8.92273e-01, -9.88314e-01,  ..., -6.30656e+00, -6.83515e+00, -7.07605e+00],
       [ 1.86465e-03, -2.11982e+00, -1.04310e+00,  ..., -6.22876e+00, -6.04187e+00, -6.89699e+00],
       [-2.45565e-01, -1.41037e+00, -9.29027e-01,  ..., -6.37291e+00, -5.81867e+00, -7.21110e+00],
       ...,
       [ 6.36436e-01, -1.14183e+00, -8.74001e-01,  ..., -6.33126e+00, -6.83321e+00, -7.26837e+00],
       [ 1.03191e-01, -1.71900e+00, -1.06737e+00,  ..., -6.48039e+00, -7.12390e+00, -7.29594e+00],
       [-6.00500e-01, -9.99384e-01, -9.66854e-01,  ..., -6.48517e+00, -7.15778e+00, -7.24772e+00]]]]], device='cuda:0')])

errmsg: Traceback (most recent call last): File "/home/huhu/catkin_ws/devel/lib/guge_test/multi_mediapipe3d.py", line 15, in exec(compile(fh.read(), python_script, 'exec'), context) File "/home/huhu/catkin_ws/src/guge_test/scripts/multi_mediapipe3d.py", line 60, in print(result.pandas()) AttributeError: 'tuple' object has no attribute 'pandas'

Additional

No response

github-actions[bot] commented 1 year ago

👋 Hello @breaveSun, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

ExtReMLapin commented 1 year ago

Tensor has no pandas in it, it's not a (model) zoo

glenn-jocher commented 1 year ago

@breaveSun tensor inputs are currently handled differently, but there is a PR to change that in https://github.com/ultralytics/yolov5/pull/10139

Quick fix is to pass your image path directly rather than doing all the preprocessing you have:

results = model('/yolov5/data/images/zidane.jpg')
breaveSun commented 1 year ago

code: yolo_model = torch.hub.load(repo_or_dir='/yolov5', model='yolov5s',pretrained=True,source='local',device='cpu') results = model('/yolov5/data/images/zidane.jpg')

The problem has been solved. thank you~

glenn-jocher commented 1 year ago

@breaveSun you're welcome! If you have any more questions or need further assistance, feel free to ask. Good luck with your YOLOv5 project!