Closed Codefreediver closed 5 months ago
π Hello @Codefreediver, 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.
Python>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. 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.
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
Hello! Thanks for reaching out. π It seems the issue you're encountering is related to the path handling on different operating systems, specifically when loading your model weights. This is a common snag when paths formatted for Windows systems (using WindowsPath
) are used in environments that do not support this path type, such as Linux-based systems often used in Kaggle notebooks.
The error message NotImplementedError: cannot instantiate 'WindowsPath' on your system
suggests that the path object specific to Windows is not recognized on the Kaggle platform. As a solution, make sure your paths are defined in a way that's compatible with Unix-like systems, which typically use forward slashes (/
) for paths. Also, ensure that your file paths are correctly pointing to the location where your weights are stored on Kaggle.
Here's a slight adjustment to your code where you load the model:
import torch
# Ensure the path is correctly specified for Unix-like systems
CKPT_PATH = '/kaggle/input/tfeqimg-2400/Final.pt'
# Loading the model
model = torch.hub.load('kaggle/input/yolov7-0/yolov5-7.0', 'custom', source='local', path=CKPT_PATH, force_reload=True)
Please double-check that the path '/kaggle/input/tfeqimg-2400/Final.pt'
actually leads to your weights file in the Kaggle environment.
If you continue to have issues or face any other questions, feel free to ask. The YOLO community and the Ultralytics team are always here to help. Happy coding! π
I encountered the error cannot instantiate 'WindowsPath' on your system
, and none of the suggested solutions helped.
To provide some context, I was trying to run a custom YOLOv5 model on CVAT or simply on my WSL, but every time I attempted it, I got the same error.
I tried various solutions, but none worked. Eventually, I realized that I had trained my model on a Windows system using Windows CMD. This caused the error to persist when I tried to run the model on Linux, Ubuntu, or WSL on Windows.
What I ended up doing was retraining the model, this time using an Ubuntu system. I used Google Colab for training, then tested the model on Ubuntu and CVAT, and it worked fine.
I created a repository with the Jupyter notebook and the data that I used to train the model on Colab.
I hope this helps anyone encountering a similar problem, or perhaps it could fix the 'PosixPath' error to.
Hi there! π Thank you for sharing your solution with the community. It's insightful and helpful!
Your observation correctly highlights a common issue when switching between Windows and Linux-based environments, like WSL or Ubuntu. The path handling between these systems can indeed cause the cannot instantiate 'WindowsPath' on your system
error due to differences in their file system path formats.
For those encountering similar issues, it's a good practice to ensure compatibility by using platform-agnostic paths within your code. Python's Pathlib
library can be particularly useful for this, as it automatically adapts paths according to the operating system. Here's a quick example:
from pathlib import Path
# Create a path that's compatible with your OS
model_path = Path("/path/to/your/model")
# Now you can use model_path in a way that's OS-independent
This approach can help avoid such errors without needing to switch your development environment or retrain your models on a different OS.
Again, thanks for sharing your workaround. Happy coding, and keep contributing to the community! π
π 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 β
This can run successfully!!
plt = platform.system()
if plt == 'Windows':
pathlib.PosixPath = pathlib.WindowsPath
else:
pathlib.WindowsPath = pathlib.PosixPath
model = DetectMultiBackend("xxx.pt")
Hello! π
Thank you for sharing your solution. It's great to hear that you found a workaround to handle the path compatibility issue between Windows and Linux systems. Your approach of conditionally setting the pathlib
path types based on the operating system is clever and can indeed help in many scenarios.
For others who might encounter similar issues, here's a slightly refined version of your code snippet that ensures compatibility across different platforms:
import platform
import pathlib
# Check the operating system and set the appropriate path type
if platform.system() == 'Windows':
pathlib.PosixPath = pathlib.WindowsPath
else:
pathlib.WindowsPath = pathlib.PosixPath
# Load the model
model = DetectMultiBackend("xxx.pt")
This snippet dynamically adjusts the path handling based on the detected operating system, which can be very useful when working in cross-platform environments.
If you encounter any further issues or have additional questions, please ensure you are using the latest version of YOLOv5 and its dependencies. The community and the Ultralytics team are always here to help. Keep up the great work, and happy coding! π
Search before asking
Question
Hello friends,
I'm having problem for the inference stage of this Kaggle competition: https://www.kaggle.com/competitions/tensorflow-great-barrier-reef
I trained my model using the following code:
I download the pretrain weights "best.pt" from Wandb, than I uploaded it to my Kaggle notebook dataset. I tried to load the pretrain model for inference, but I'm really having a hard time:
And the error is:
As a newbie to both Kaggle and Yolo, I tried many solutions but failed. Please help me, thank you.
Additional
No response