Closed ZhouBay-TF closed 1 year ago
👋 Hello @xinkangzhou, 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.
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
YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
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.
@xinkangzhou see classify/predict.py Usage examples:
Thank you very much for your timely reply. It's really no problem for me to use your official model, but my model can be used in detect, and cannot run here. I'm studying it.
Could you solve this?
👋 hi, thanks for letting us know about this possible problem with YOLOv5 🚀. We've created a few short guidelines below to help users provide what we need in order to start investigating a possible problem.
When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimum reproducible example. Your code that reproduces the problem should be:
For Ultralytics to provide assistance your code should also be:
git pull
or git clone
a new copy to ensure your problem has not already been solved in master.If you believe your problem meets all the above criteria, please close this issue and raise a new one using the 🐛 Bug Report template with a minimum reproducible example to help us better understand and diagnose your problem.
Thank you! 😃
hey i tried everything still getting the same error
@sanya123tech hi there,
I'm sorry to hear that you're still encountering the same error. In order to assist you more effectively, could you please provide us with more information about the specific error you're experiencing?
Include any relevant code snippets, error messages, and an explanation of the steps you've taken so far. This will help us better understand the issue and provide you with a solution.
Thank you!
the first pic is training the dataset which was successfull, the next i was trying to predict using an image i was getting that error i am using yolo for the first time so i don't know why i am facing this issues
@sanya123tech hi there!
Thanks for reaching out and sharing the issue you encountered. I understand that you were able to successfully train your dataset using YOLOv5, but when you tried to use an image for prediction, you encountered an error regarding the softmax attribute. As a first-time user of YOLO, you're not sure why this issue is occurring.
The error message suggests that the softmax
attribute is not found, indicating there might be an issue with the format of the results you're passing into F.softmax()
. It's worth noting that F.softmax()
expects a tensor as input, but in your case, it seems that the results
variable is a list.
To resolve this issue, ensure that the results
variable is converted into a tensor before passing it to F.softmax()
. You mentioned that you tried different conversions such as torch.Tensor(results)
and torch.tensor(results)
, but none of them worked.
Here's an example of how you can convert a list to a tensor:
results = torch.tensor(results)
Make sure to place this conversion before the F.softmax()
function is called.
If you're still experiencing the same issue after making this change, please provide more details about your dataset, the code snippet you're using for prediction, and any other relevant information. This will help us in further investigating the issue and providing you with a more specific solution.
Please let me know if you have any further questions. We're here to help you out!
'list' object has no attribute 'softmax'
@jahanvikotwal this error is likely occurring because you are trying to access the softmax
attribute on a list object, which does not have this attribute by default.
To resolve this issue, you need to ensure that you are passing a tensor object to F.softmax()
instead of a list. You can convert the list to a tensor using the torch.tensor()
function.
For example:
results = torch.tensor(results)
Please make sure that this conversion is done before calling F.softmax()
.
If you are still encountering the same error after making this change, please provide more details about your dataset, the code you are using, and any other relevant information. This will help us further investigate the issue and provide you with a more specific solution.
Let me know if you need any further assistance.
@sanya123tech hi there!
Thanks for reaching out and sharing the issue you encountered. I understand that you were able to successfully train your dataset using YOLOv5, but when you tried to use an image for prediction, you encountered an error regarding the softmax attribute. As a first-time user of YOLO, you're not sure why this issue is occurring.
The error message suggests that the
softmax
attribute is not found, indicating there might be an issue with the format of the results you're passing intoF.softmax()
. It's worth noting thatF.softmax()
expects a tensor as input, but in your case, it seems that theresults
variable is a list.To resolve this issue, ensure that the
results
variable is converted into a tensor before passing it toF.softmax()
. You mentioned that you tried different conversions such astorch.Tensor(results)
andtorch.tensor(results)
, but none of them worked.Here's an example of how you can convert a list to a tensor:
results = torch.tensor(results)
Make sure to place this conversion before the
F.softmax()
function is called.If you're still experiencing the same issue after making this change, please provide more details about your dataset, the code snippet you're using for prediction, and any other relevant information. This will help us in further investigating the issue and providing you with a more specific solution.
Please let me know if you have any further questions. We're here to help you out!
I used the same thing, But I got this error:
File "/content/drive/MyDrive/yolov5/classify/predict.py", line 132, in run
results = torch.tensor(results)
ValueError: only one element tensors can be converted to Python scalars
@sanya123tech hi there! 你好! Thanks for reaching out and sharing the issue you encountered. I understand that you were able to successfully train your dataset using YOLOv5, but when you tried to use an image for prediction, you encountered an error regarding the softmax attribute. As a first-time user of YOLO, you're not sure why this issue is occurring.感谢您联系并分享您遇到的问题。我知道你能够成功地使用YOLOv5训练你的数据集,但是当你试图使用图像进行预测时,你遇到了关于softmax属性的错误。作为第一次使用YOLO的用户,您不确定为什么会出现此问题。 The error message suggests that the
softmax
attribute is not found, indicating there might be an issue with the format of the results you're passing intoF.softmax()
. It's worth noting thatF.softmax()
expects a tensor as input, but in your case, it seems that theresults
variable is a list.错误消息表明未找到softmax
属性,表明您传递到F.softmax()
的结果格式可能存在问题。值得注意的是,F.softmax()
需要一个张量作为输入,但在您的示例中,结果
变量似乎是一个列表。 To resolve this issue, ensure that theresults
variable is converted into a tensor before passing it toF.softmax()
. You mentioned that you tried different conversions such astorch.Tensor(results)
andtorch.tensor(results)
, but none of them worked.要解决此问题,请确保在将结果
变量传递给F.softmax()
之前将其转换为张量。你提到你尝试了不同的转换,如torch.Tensor(results)
和torch.tensor(results)
,但它们都不起作用。 Here's an example of how you can convert a list to a tensor:下面是一个如何将列表转换为张量的示例:results = torch.tensor(results)
Make sure to place this conversion before the
F.softmax()
function is called.请确保在调用F.softmax()
函数之前进行此转换。 If you're still experiencing the same issue after making this change, please provide more details about your dataset, the code snippet you're using for prediction, and any other relevant information. This will help us in further investigating the issue and providing you with a more specific solution.如果您在进行此更改后仍然遇到相同的问题,请提供有关数据集的更多详细信息,用于预测的代码片段以及任何其他相关信息。这将有助于我们进一步调查问题,并为您提供更具体的解决方案。 Please let me know if you have any further questions. We're here to help you out!如果你还有什么问题,请告诉我。我们是来帮你的!I used the same thing, But I got this error:我用了同样的东西,但我得到了这个错误: File "/content/drive/MyDrive/yolov5/classify/predict.py", line 132, in run文件“/content/drive/MyDrive/yolov 5/classify/predict.py“,第132行,运行中 results = torch.tensor(results)results = torch.tensor(results) ValueError: only one element tensors can be converted to Python scalarsValueError:只有一个元素张量可以转换为Python标量
hi,Have you solved this problem
Search before asking
Question
My own data training model can run normally in detect, but an error is reported “classify/predict.py”. I think what F.softmax(results, dim=1) needs is tensor, but when print("result:", type(results))->>result: <class 'list'> I try, results = torch.Tensor(results);results = torch.tensor(results);results = torch.FloatTensor(results),None of them are right.
Additional
No response