New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation Fault (Core Dumped) Bug in Fine-Tuned YOLOv8 Model with Low Confidence Inference #11881
Comments
Hello! Thank you for the detailed report and for conducting such thorough investigations into this issue. 🙌 The Segmentation Fault you're experiencing when setting a low confidence threshold is indeed intriguing. It sounds like an issue related to memory handling or buffer overflow that's specific to the configurations in a Linux environment, as you suggested. Given that you've already tried multiple environments and configurations without success, here is a potential workaround:
Additionally, considering this seems related to how Linux handles memory versus Windows, examining the system calls and memory management differences in your Docker or Linux environment could provide more insights. Using tools like Could you please check if limiting the number of detections resolves the issue? Meanwhile, I'll further investigate potential fixes from our side as well. Thank you for offering to help with a PR! We appreciate your contribution. Let's aim to isolate this behavior further and work on a solid patch. 🚀 |
I conducted experiments to limit the number of detections as you suggested. with torch.inference_mode():
segment_results = self.model.predict(
source=image,
save=False,
save_txt=False,
imgsz=(640, 640),
max_det={max_detection},
conf=0.01,
stream=True,
) Experiment Results
Environment
Please let me know if there is anything else you need. |
I've discovered an interesting point that if I do not use the with torch.inference_mode():
segment_results = self.model.predict(
source=image,
save=False,
save_txt=False,
imgsz=(640, 640),
max_det=100,
# conf=0.01,
stream=True,
) My fine-tuned model performs exceptionally well when the conf is low. Is there another method to achieve the same effect without using the conf option? |
@takhyun12 hello! Thanks for the interesting find! 😊 It's quite insightful that omitting the Regarding achieving effective low confidence operation without explicitly setting a very low results = model.predict(source=image, imgsz=(640, 640), max_det=100, stream=True)
filtered_results = [r for r in results if r.confidence >= 0.01] This method allows you to handle an arbitrary number of detections more safely and gives you the flexibility to adjust your confidence threshold dynamically after observing model output. Let me know if this works for you or if further adjustments are needed! |
@glenn-jocher Hello, I have an additional question regarding this issue. The code you suggested did not solve the problem: results = model.predict(source=image, imgsz=(640, 640), max_det=100, stream=True)
filtered_results = [r for r in results if r.confidence >= 0.01] The results of the above code are completely different from the following code: results = model.predict(source=image, imgsz=(640, 640), conf=0.01, max_det=100, stream=True) Output:
I think there might be a difference in how confidence is handled during prediction and post-processing. Do you have any suggestions for this case? Or is there any progress in fixing this Segmentation Fault bug? Thank you for your help. |
Hello @takhyun12, Thank you for your follow-up and for testing out the code snippet. You're correct in observing that filtering post-prediction can yield different results compared to setting the As for the segmentation fault issue, it's still under investigation. A potential workaround could be to adjust the Here's a slight modification to try: results = model.predict(source=image, imgsz=(640, 640), conf=0.05, max_det=100, stream=True)
filtered_results = [r for r in results if r.confidence >= 0.01] This approach uses a slightly higher internal confidence while still allowing you to capture lower confidence detections for further analysis. Let's stay in touch as we work through these issues. Your feedback is invaluable! 🌟 |
Search before asking
YOLOv8 Component
Predict
Bug
I would like to share a significant bug related to confidence inferences identified in the fine-tuned YOLOv8 model.
I built a custom dataset through Roboflow and fine-tuned it using YOLOv8x.
I discovered that the fine-tuned model only triggers a Segmentation Fault (core dumped) when inferring specific images in a Linux environment. I analyzed this issue using various profiling tools.
As a result, I found a close relationship between the conf parameter and this issue, as detailed below:
First, I am sharing the fine-tuned model and test image I used in my experiments:
model : download
image : download
My findings are as follows:
I tried various experiments to resolve this issue, but none were effective:
This issue is consistently reproducible in all Linux environments, but it does not occur in Windows. I believe that when the conf - value is low, there might be an explosive increase in memory usage during the model inference.
I wrote test code to infer around 1,000 images and have been running it. If the problem does not reproduce with the images I have attached, it could be due to subtle changes in dependencies such as torch.
Please run about 100 images through my fine-tuned model with a low conf value, and you'll quickly find the problematic images.
I created a model that performs best with a low conf value of 0.01 or 0.001, but I'm unable to use it due to this issue.
I would greatly appreciate your assistance.
Environment
Minimal Reproducible Example
Additional
I think the following PRs are closely related to the issue I'm reporting:
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: