ultralytics / yolov5

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

AttributeError: Can't get attribute 'Hardswish' on <module 'torch.nn.modules.activation' from '/usr/local/lib/python3.6/dist-packages/torch/nn/modules/activation.py'> #773

Closed lucasjinreal closed 4 years ago

lucasjinreal commented 4 years ago

AttributeError: Can't get attribute 'Hardswish' on <module 'torch.nn.modules.activation' from '/usr/local/lib/python3.6/dist-packages/torch/nn/modules/activation.py'>

glenn-jocher commented 4 years ago

@jinfagang thanks for the bug report! Hardswish() will be supported in ONNX 1.8, which is supposed to be officially released in the next few months. See https://github.com/onnx/onnx/issues/2728

In the meantime I believe your best option may be to export v2.0 LeakyReLU(0.1) models with pytorch 1.5.1 and onnx 1.7.

Frank1126lin commented 4 years ago

I alse got this issue when I use the model (pt file, trained on my cloud machine ) to detect on my desktop.

glenn-jocher commented 4 years ago

@jinfagang @Frank1126lin after reading the error again, I think you simply need to update your pytorch to 1.6 or higher. nn.Hardswish was introduced in 1.6.

Frank1126lin commented 4 years ago

@jinfagang @Frank1126lin after reading the error again, I think you simply need to update your pytorch to 1.6 or higher. nn.Hardswish was introduced in 1.6.

Yeah, after update torch and torchvison to 1.6, It works. And @glenn-jocher thank you so much.

Yoshitsugi commented 3 years ago

I can not still clear the AttributeError MSG by python:3.8.5 pytorch:1.7.0

AttributeError: Can't get attribute 'Hardswish' on <module 'torch.nn.modules.activation' from 'C:\Users\user\anaconda3\envs\yolov5\lib\site-packages\torch\nn\modules\activation.py'>

glenn-jocher commented 3 years ago

@Yoshitsugi , thank you for your interest in YOLOv5! This issue seems to lack the minimum requirements for a proper response, or is insufficiently detailed for us to help you. Please note that most technical problems are due to:

CODE TO REPRODUCE YOUR ISSUE HERE


- **Your custom data.** If your issue is not reproducible in one of our 3 common datasets ([COCO](https://github.com/ultralytics/yolov5/blob/master/data/coco.yaml), [COCO128](https://github.com/ultralytics/yolov5/blob/master/data/coco128.yaml), or [VOC](https://github.com/ultralytics/yolov5/blob/master/data/voc.yaml)) we can not debug it. Visit our [Custom Training Tutorial](https://docs.ultralytics.com/yolov5/tutorials/train_custom_data) for guidelines on training your custom data. Examine `train_batch0.jpg` and `test_batch0.jpg` for a sanity check of your labels and images.

- **Your environment.** If your issue is not reproducible in one of the verified environments below we can not debug it. If you are running YOLOv5 locally, verify your environment meets all of the [requirements.txt](https://github.com/ultralytics/yolov5/blob/master/requirements.txt) dependencies specified below. If in doubt, download Python 3.8.0 from https://www.python.org/, create a new [venv](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/), and then install requirements.

If none of these apply to you, we suggest you close this issue and raise a new one using the **Bug Report template**, providing screenshots and **minimum viable code to reproduce your issue**. Thank you!

## Requirements

Python 3.8 or later with all [requirements.txt](https://github.com/ultralytics/yolov5/blob/master/requirements.txt) dependencies installed, including `torch>=1.6`. To install run:
```bash
$ pip install -r requirements.txt

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

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are passing. These tests evaluate proper operation of basic YOLOv5 functionality, including training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu.

Yoshitsugi commented 3 years ago

Hi Glenn I have traced your instruction, but failed. yolov5new.txt yolov5new.txt

glenn-jocher commented 3 years ago

@Yoshitsugi use a verified environment, that's why we created them.

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):

Yoshitsugi commented 3 years ago

Hi Glenn I have changed from Windows 10 Python, torch environment to Google Colab, resulted great success!! Thanks for your greatest support!!! jidane

glenn-jocher commented 3 years ago

@Yoshitsugi great! Unfortunately windows and conda can both be difficult environments for ML.

Yoshitsugi commented 3 years ago

Hi Glenn your yolov5 is fit to colab, not to windows and conda. I believe some guy will challenge for conda environment for success, since your code is also written for conda environment.

glenn-jocher commented 3 years ago

@Yoshitsugi I can't speak for conda, as we don't use it or test on it, but Windows is fully supported. We run daily tests on all 3 operating systems including Windows of all core YOLOv5 functions, see below.

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are passing. These tests evaluate proper operation of basic YOLOv5 functionality, including training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu.

glenn-jocher commented 3 years ago

@Yoshitsugi the latest windows results are here, from about 9 hours ago: https://github.com/ultralytics/yolov5/runs/1450815198?check_suite_focus=true

Yoshitsugi commented 3 years ago

It is great! Tell me what kind of cpu for your test? Regards

glenn-jocher commented 3 years ago

@Yoshitsugi I'm not sure. This is the windows-latest environment described here: https://github.com/actions/virtual-environments

Yoshitsugi commented 3 years ago

For google Colab, I have checked several code by you. However Test code I have tried and takes time. I understand your program has enormous contents, so I hesitate to proceed by windows. Maybe after I have got more capability for coding, I would like to try. I have tried yolov3 and it was successful. yolov4 was hard to run, since it requires visual studio and cmake. yolov5 looks partly successful supported by you. Thank you for very much! Regards

glenn-jocher commented 3 years ago

Great, I'm glad you find it useful!

Yoshitsugi commented 3 years ago

Hi Glenn By the way, will you tell me how to recognize different photo other than Jidane.jpg by Colab yolov5? Since the Colab yolov5 is highly automated, I can not load different photo. Pls. advise

glenn-jocher commented 3 years ago

python detect.py --source anyphoto.jpg

Yoshitsugi commented 3 years ago

Hi Glenn I have tried 'Kaggle Notebook with free GPU: https://www.kaggle.com/models/ultralytics/yolov5', resulting error MSG. Pls. advise. Kaggle_yolov5.txt

glenn-jocher commented 3 years ago

@Yoshitsugi thanks for spotting this. I will update the kaggle notebook.

In the meantime the image is in exp/, not exp0.

Yoshitsugi commented 3 years ago

Hi Glenn I am trying to upload a new photo in exp/, but I can not find the folder in the google drive. Tell me how to upload a photo? Regards

pderrenger commented 2 weeks ago

Please ensure you're using the latest version of the YOLOv5 repository and check the error message for specific details. If the issue persists, try running the code in a fresh Kaggle environment.