ultralytics / yolov5

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

How should I get the previous version of weight #11614

Closed gatzf closed 1 year ago

gatzf commented 1 year ago

Search before asking

Question

How should I get the previous version of weight

Additional

No response

github-actions[bot] commented 1 year ago

👋 Hello @gatzf, 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 a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

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.

Introducing YOLOv8 🚀

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics
glenn-jocher commented 1 year ago

@gatzf hello! You can download the previous versions of the YOLOv5 weights from the YOLOv5 releases page on GitHub. Simply navigate to the release you need, and download the corresponding weights file from the assets section. Let me know if you have any further questions!

fasp-2023 commented 1 year ago

Hello Glenn-Jocher,

Can you help me with this issue?

https://github.com/pytorch/hub/issues/331#issue-1729583148

Thanks

Best Regards

Philip

glenn-jocher commented 1 year ago

@fasp-2023 hello Philip,

Thank you for reaching out to us. However, the issue you linked seems to be related to the PyTorch repository, not YOLOv5.

Regardless, can you please provide more specific details about the problem you are facing so that we can try to assist you further?

Looking forward to your response.

Best regards, Glenn Jocher.

fasp-2023 commented 1 year ago

I Glenn Jocher,

Thanks for your response.

First of all, congratulations on creating the yolov5 algorithm, which is very good!

I'm try to improve your yolov5 algorithm.

I have a problem when i try to run in google colab.

Then, when I run it, this error appears:

RuntimeError: Given groups=1, weight of size [768, 768, 3, 3], expected input[1, 384, 4, 4] to have 768 channels, but got 384 channels instead

How can fix this error?

Other question is, when using a C2F function, I wanted to try to understand how to adjust these weights...

backbone:

[from, number, module, args]

[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2 [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 [-1, 3, C3, [128]], [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 [-1, 6, C3, [256]], [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 [-1, 9, C3, [512]], [-1, 1, Conv, [768, 3, 2]], # 7-P5/32 [-1, 3, C3, [768]], [-1, 1, Conv, [768, 3, 2]], # 9-P6/64 [-1, 3, C2F, [768]], [-1, 1, SPPF, [1024, 5]], # 11

Thanks for your help

Best Regards,

Philip

glenn-jocher commented 1 year ago

@fasp-2023 hello Philip,

Thank you for your kind words about YOLOv5.

Regarding the error message you received, it seems that the input tensor shape does not match the expected shape by the weight tensor. Please make sure that the dimensions of your input tensor are [1, 384, 4, 4] so that it matches the expected number of channels.

With regards to the C2F function and its associated weights, adjusting the weights requires a solid understanding of the network architecture and the training process, which may involve modifying the code itself. Our team is always working to improve and update the codebase, but please note that this may not be a trivial task and may require significant effort.

I hope this helps, please let me know if you have any further questions.

Best, Glenn Jocher.

fasp-2023 commented 1 year ago

Hi Glen Jocher,

I resolved the problem.

I have one question. Can you help me please?

How can insert a function MHSA in yolov5s6 adapting the associated parameters? image

Thanks for your help.

Best Regards,

Philip

glenn-jocher commented 1 year ago

@fasp-2023 hi Philip,

I'm glad to hear that you were able to solve the previous issue!

Regarding your question about adding an MHSA function to YOLOv5s6, adding it would require some modifications to the YOLOv5s6 architecture. Specifically, you would need to define the associated block appropriately and ensure that the parameters are set correctly. Depending on your use case, you may also need to modify the training process and loss function to account for the additional block.

If you could provide more information about your specific goal, I may be able to offer some more specific guidance. Please let me know if you have any additional questions or concerns.

Best, Glenn Jocher.

fasp-2023 commented 1 year ago

Hi Glenn Jocher,

Thank you for your help. I already configured it in commom.py and it was ok.

However, I managed to solve the problem.

I'm analyzing defects in textile yarn.

I tried to use this function in the last backbone layer. The results improved a little but not much. In your opinion, where would it be more appropriate to insert the MHSA function? In head or backbone?

Thanks.

Best Regards

glenn-jocher commented 1 year ago

@fasp-2023 hi,

I'm glad to hear you were able to resolve the issue. Regarding the placement of the MHSA function, without further information on the specifics of your use case and the scope of your project, it is hard for me to provide precise guidance. However, you may want to consider experimenting with adding the MHSA block at the beginning of the network in the backbone or in the head to see if it helps in improving the results.

Remember, different use cases may require different modifications to the architecture, and the optimal placement of the MHSA function will depend on your specific use case. Nonetheless, we advise that any modification done should be done carefully and tested thoroughly to ensure model accuracy and reliability.

If you have any further questions or concerns, please let me know.

Best, Glenn Jocher.

fasp-2023 commented 1 year ago

Hi Gleen Jocher,

Ok. Thanks for de advise. I will try and give you a feedback as soon is possible.

I have one question. How can obtain in google colab with yolov5s6 de accuracy? can i run some script to obtain de (TP+TN)/(TP+TN+FP+FN) ?

Thanks for your availability, friendliness and help given.

Best regards

Philip

glenn-jocher commented 1 year ago

@fasp-2023 hi Philip,

Thanks for reaching out, and happy to help!

To obtain the accuracy of YOLOv5 in detecting objects, you can analyze the model's output files which contain predictions and their corresponding annotations. These files can be produced by running the test function in detect.py on a directory of test images or a single test image.

Once you have the output files, you can use external data processing tools to compute the overall accuracy and other metrics that you need, like (TP+TN)/(TP+TN+FP+FN), precision, recall, and F1-score.

I hope this helps. Let me know if you have additional questions or concerns.

Best, Glenn Jocher.

fasp-2023 commented 1 year ago

Hi Gleen Jocher,

Ok. Thanks for the feedback,

How can obtain the accuracy with the confusion matrix? (TP+TN)/(TP+TN+FP+FN) I ignore de background?

What is the arquitecture of yolov5s6 ?

Thanks for your availability, friendliness and help given.

Best regards

Philip

glenn-jocher commented 1 year ago

@fasp-2023 hi Philip,

To calculate the accuracy of YOLOv5 with the confusion matrix, you need to count the number of true positives (TP), true negatives (TN), false positives (FP), and false negatives (FN) for each object class separately. You can then use these values to compute the accuracy using the formula (TP+TN)/(TP+TN+FP+FN). The background should be excluded from the calculation, as it is not a class to be detected.

Regarding the architecture of YOLOv5s6, it is a convolutional neural network (CNN) that consists of a backbone network (backbone), neck network (neck), and head network (head). The backbone is responsible for extracting features from the input image, the neck combines the features, and the head generates predictions based on the features. You can find more details about the architecture in the YOLOv5 repository.

I hope this helps answer your questions. If you have any further questions or concerns, please let us know.

Best, Glenn Jocher.

fasp-2023 commented 1 year ago

Hi Gleen Jocher,

Ok. Thanks for the feedback and precious responses.

What does the scale hyperparameter Augmentation mean? yolov5/data/hyps/hyp.scratch-low.yaml scale: 0.5 # image scale (+/- gain)

Between what values can it vary numerically?

In your opinion, does it make sense to do a new augmentation in training, even after the dataset also has an augmentation?

Thanks for your availability, friendliness and help given.

Best regards

Philip

glenn-jocher commented 1 year ago

@fasp-2023 hello Philip,

The scale hyperparameter in the YAML file you referenced controls the image scale (i.e., size) during training. Specifically, this hyperparameter specifies the relative scaling range of random image augmentation, which randomly scales the input image up or down by a factor of up to +/- the scale gain specified. In the case of the example you provided, the image scale can vary by up to 50% higher or lower than the default image resolution.

In general, adding additional augmentations during training can lead to improved model performance, especially in cases where the available training data is limited. However, the specific effects of additional augmentations will depend on the type of augmentation, the size and diversity of the training data, and the model architecture and hyperparameters being used.

I hope this answers your questions. Please let me know if you have any further concerns or inquiries.

Best regards, Glenn Jocher.

fasp-2023 commented 1 year ago

Hi Gleen Jocher,

Ok. Thanks for the feedback and precious responses.

It's possible to put this value of scale to 2.0 ?

Exist any function can be added to algorithm in backbone or neck that improve the metrics to up resolution of input images?

Thanks for your availability, friendliness and help given.

Best regards

Philip

glenn-jocher commented 1 year ago

@fasp-2023 hi Philip,

Regarding your first question, it is possible to set the value of the scale hyperparameter to 2.0 if your training data supports larger image sizes. However, note that larger scales will result in a proportionally greater computation time and memory usage. I would recommend testing various scaling factors to find the best balance between accuracy and performance.

Regarding your second question, there exist several ways to improve the metrics of a YOLOv5 model, including modifying the architecture by adding or removing blocks in the backbone, neck, or head layers. You may also consider exploring various pre-processing techniques such as image normalization or dimension reduction.

I would recommend reviewing the YOLOv5 documentation and exploring the YOLOv5 repository for additional support and guidance on modifying the YOLOv5 architecture and optimizing its overall performance and accuracy.

If you have any further questions or concerns, please feel free to ask.

Best, Glenn Jocher.

fasp-2023 commented 1 year ago

Hi Gleen Jocher,

Ok. Thanks for the feedback and precious responses.

I change the hyperparameter SCALE in hyp.scratch-high.yaml & hyp.scratch-low.yaml, but only in hyp.scratch-high.yaml i have good results. Why this happen?

Best regards

Philip

glenn-jocher commented 1 year ago

@fasp-2023 hi Philip,

Glad to hear you've been experimenting with the hyperparameters in YOLOv5. It's hard to give a specific answer without knowing more details about your training data and methodology. However, it's important to remember that changing a single hyperparameter, such as the scale, can have a significant effect on the overall performance of the model, especially if the training data is limited or not diverse enough. It's recommended to experiment with various hyperparameters and monitor their effect on model performance across multiple epochs in order to find the optimal values.

Also, keep in mind that a high scale could produce stronger regularization, which can help avoid overfitting, but may also reduce the ability of the model to detect small objects in the image. On the other hand, a lower scale can improve the detection of smaller objects, but could also increase the chance of overfitting.

Hope this helps! If you have any other questions, please don't hesitate to ask.

Best, Glenn Jocher.

fasp-2023 commented 1 year ago

I Glenn Jocher,

Thanks for your response.

what that means the hyperparameter "anchor_t: 4.0" # anchor-multiple threshold ? if you enter a higher value, what does it mean?

Thanks for your help

Best Regards,

Philip

fasp-2023 commented 1 year ago

I Glenn Jocher,

Thanks for your response.

what that means the hyperparameter "anchor_t: 4.0" # anchor-multiple threshold ? if you enter a higher value, what does it mean?

Thanks for your help

Best Regards,

Philip

glenn-jocher commented 1 year ago

@fasp-2023 hello Philip,

The hyperparameter anchor_t: 4.0 in YOLOv5 refers to the anchor-multiple threshold. This threshold is used to determine whether to assign a ground truth bounding box to a specific anchor during training.

If you increase the value of anchor_t, it means that a stricter criterion will be used to match ground truth boxes with anchor boxes. This can result in fewer matches being made, potentially leading to more difficult training scenarios and potentially lower recall (the ability to detect true positive objects). However, it may help to reduce false positive detections if the training data contains a lot of noise or cluttered backgrounds.

It's important to note that adjusting hyperparameters like anchor_t should be done with caution, as it can have a significant impact on the model's performance. I would recommend experimenting with different values and closely monitoring the resulting performance metrics, such as precision, recall, and mean average precision (mAP), to find the optimal balance for your specific use case.

If you have any further questions or need additional assistance, feel free to ask.

Kind regards, Glenn Jocher

github-actions[bot] commented 1 year ago

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐

fasp-2023 commented 1 year ago

Hello glenn-jocher

Thanks for your responses.

In this matrix confusion, to calculate the accuracy, i have to do the following calcs:

[ 0.63 0.02 0.60 ] [ 0.02 0.68 0.40 ] [ 0.35 0.30 0 ]

you need to sum the true positives (TP) and true negatives (TN) and divide by the total number of samples (N). Accuracy is a measure of the overall model performance, representing the proportion of correctly classified samples out of the total number of samples.

scss Copy code Accuracy = (TP_x_TRUE + TP(Y_TRUE) + TP(background)) / N

In your case, the total number of samples (N) is the sum of all values in the confusion matrix, which is: N = 0.63 + 0.02 + 0.60 + 0.02 + 0.68 + 0.40 + 0.35 + 0.30 + 0

Calculating N = 2.60 Now, substituting the values, we can calculate the accuracy: Accuracy = (0.63 + 0.68 + 0) / 2.60 ≈ 0.4962 or 49.62%

Is this correct?

I have another question. In the following confusion matrix, how i can reduce de noise or FN: False Negative image

Exis any function or hyperparameter that i can use to do this?

In dataset this type of class is very dificult. This type of class to detect is very complex because I have images with a resolution of 1280*1280, and I may have a class in the image that occupies a substantial part of that same image.

Thanks for your help.

Best Regards,

Philip

glenn-jocher commented 1 year ago

@fasp-2023 hello Philip,

Thank you for reaching out and providing the confusion matrix. Your calculation for accuracy is correct. To calculate accuracy, you need to sum the true positives (TP) and true negatives (TN) and divide by the total number of samples (N). In your case, N is the sum of all values in the confusion matrix, which is 2.60. Thus, the accuracy is approximately 49.62% or 0.4962.

Regarding your question about reducing false negatives (FN) in the confusion matrix, there are several approaches you can try. One option is to adjust the model's hyperparameters, such as the threshold for object detection or the anchor scales, to make it more sensitive to detecting objects of interest. Another approach is to collect more diverse and representative training data for the class with false negatives, including images with various sizes and poses of the object.

Additionally, you can experiment with data augmentation techniques like scaling, rotation, or flipping to increase the diversity of the training dataset. Fine-tuning the model on specific examples of the class with false negatives may also help improve its performance for detecting these difficult instances.

It's important to note that reducing false negatives may require iterative experimentation and exploration of different strategies. You may also consider consulting the YOLOv5 documentation and the YOLOv5 community for further insights and suggestions specific to your use case.

Best regards, Glenn Jocher

fasp-2023 commented 1 year ago

Hello glenn-jocher

Thanks for your responses.

If i would like to change the threshold for object detection, i can do this in detection, correct? Not in training, correct?

I have in this moment data augmentation techniques like scaling, rotation, and flipping in my dataset, but my values of false negatives (FN) is too high.

CBMA module can be used to reduce this FN? Exist any function that can be used for this application?

Best regards, Philip

glenn-jocher commented 1 year ago

@fasp-2023 hello Philip,

Yes, you can change the threshold for object detection during the inference or detection phase, not during training. In YOLOv5, the detection threshold determines the confidence level at which an object is considered detected. By adjusting the threshold, you can control the trade-off between false positives and false negatives.

Regarding reducing false negatives, the CBMA (Class-Balanced Momentum Accumulation) module in YOLOv5 is designed to address class imbalance and improve object detection performance, particularly for hard-to-detect classes. It accumulates the momentum of gradients for each class during training, helping to prioritize the learning of difficult classes. While this module can improve performance, its effectiveness in reducing false negatives can vary depending on the specific dataset and class characteristics.

Keep in mind that reducing false negatives may require additional steps beyond the CBMA module, such as refining your dataset, adjusting hyperparameters, or experimenting with other techniques specific to your application. I encourage you to explore various strategies and consult the YOLOv5 documentation and community for further guidance.

If you have any further questions or need assistance, please let me know.

Best regards, Glenn Jocher

github-actions[bot] commented 1 year ago

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐