Comments (6)
👋 Hello @iyzyi, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.
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.
Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.
Install
Pip install the ultralytics
package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.
pip install ultralytics
Environments
YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
- Notebooks with free GPU:
- Google Cloud Deep Learning VM. See GCP Quickstart Guide
- Amazon Deep Learning AMI. See AWS Quickstart Guide
- Docker Image. See Docker Quickstart Guide
Status
If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.
from ultralytics.
model.save("/path")
with doc
Loads parameters from the specified weights file into the model.
This method supports loading weights from a file or directly from a weights object. It matches parameters by
name and shape and transfers them to the model.
Args:
weights (str | Path): Path to the weights file or a weights object. Defaults to 'yolov8n.pt'.
Returns:
self (ultralytics.engine.model.Model): The instance of the class with loaded weights.
Raises:
AssertionError: If the model is not a PyTorch model.
from ultralytics.
model.save("/path")
with docLoads parameters from the specified weights file into the model. This method supports loading weights from a file or directly from a weights object. It matches parameters by name and shape and transfers them to the model. Args: weights (str | Path): Path to the weights file or a weights object. Defaults to 'yolov8n.pt'. Returns: self (ultralytics.engine.model.Model): The instance of the class with loaded weights. Raises: AssertionError: If the model is not a PyTorch model.
Thanks.
But my problem is the same as #10297, and I quote:
I then export this as a PyTorch image using model.save('path/to/somefilename.pt'). So these weights are saved locally then.
I then try to load the model with YOLO('path/to/somefilename.pt') and then I get a YOLO model, but it has all the default YOLO classes and not the custom one I used for training any more.
Any idea how to export the model such that when I reload it, the classes are preserved?
from ultralytics.
@iyzyi this should not happen, probably a bug, are you using the latest version of ultralytics?
from ultralytics.
@Kayzwer I'm using 8.2.18.
However it happen even if i upgrade to 8.2.19.
my code
:
from ultralytics import YOLO
yolo_model = 'model/yolov8n.pt'
custom_yaml = 'dataset/dataset.yaml'
custom_model = 'model/blue_focus.pt'
model = YOLO(yolo_model)
model.train(data=custom_yaml, epochs=3)
model.save(custom_model)
print('**********************saved**********************')
model = YOLO(custom_model)
model.val()
custom yaml
:
path: my_path
train: images/train
val: images/val
test: images/test
names:
0: blue_focus
This code will output:
...... (some output) ......
Results saved to runs\detect\train14
**********************saved**********************
Dataset 'coco.yaml' images not found ⚠️, missing path 'C:\Users\xxxxx\AppData\Roaming\Ultralytics\datasets\coco\val2017.txt'
Downloading https://github.com/ultralytics/yolov5/releases/download/v1.0/coco2017labels-segments.zip to 'C:\Users\xxxxx\AppData\Roaming\Ultralytics\datasets\coco2017labels-segments.zip'...
100%|██████████| 169M/169M [01:46<00:00, 1.66MB/s]
Unzipping C:\Users\xxxxx\AppData\Roaming\Ultralytics\datasets\coco2017labels-segments.zip to C:\Users\xxxxx\AppData\Roaming\Ultralytics\datasets\coco...: 100%|██████████| 122232/122232 [01:10<00:00, 1727.47file/s]
Downloading http://images.cocodataset.org/zips/train2017.zip to 'C:\Users\xxxxx\AppData\Roaming\Ultralytics\datasets\coco\images\train2017.zip'...
Downloading http://images.cocodataset.org/zips/val2017.zip to 'C:\Users\xxxxx\AppData\Roaming\Ultralytics\datasets\coco\images\val2017.zip'...
Downloading http://images.cocodataset.org/zips/test2017.zip to 'C:\Users\xxxxx\AppData\Roaming\Ultralytics\datasets\coco\images\test2017.zip'...
I never use coco.yaml
. It seemed that I get a YOLO model, but it has all the default YOLO classes and not the custom one I used for training any more. Just like #10297
Looking forward to your reply. Thanks!
from ultralytics.
I am sure my dataset is right because I can use bset.pt to do my custom predict.
from ultralytics.
Related Issues (20)
- TensorFlow.js: export failure HOT 4
- TensorFlow SavedModel: export failure ❌ 1.2s: permute(sparse_coo) HOT 5
- [Question] How to do validation with custom dataloader HOT 2
- FPN code HOT 3
- How to run YOLOv8 predict on GPU without CUDA? HOT 2
- Why my result predicted object has no bounding box? HOT 9
- segmentation fault(core dumped) HOT 1
- Parameter fusion HOT 4
- Install ultralytics with pre-installed Pytorch HOT 4
- argument save_dir doesn't work HOT 2
- Inference/postprocessing yolov8n on rockchip 3588 HOT 4
- I am looking for an Assisted Labeling tool where i can use my trained yolo models to assist during labeling process. HOT 1
- Instance segmentation custom model training HOT 2
- Fine-tuning YOLOv8n Model on Two New Classes HOT 2
- Exception with YOLOWorld ONNX export in dynamic mode HOT 3
- How cna I validate my model with no-square 【640*384(w*h)】image size? HOT 3
- RuntimeError:An attempt has been made to start a new process before the current process has finished its bootstrapping phase. HOT 5
- Bug report: FileNotFoundError due to special characters in pathnames at /ultralytics/data/base.py HOT 4
- Yolov9 pytorch model is empty, as in not the folder, the loaded pytorch model. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultralytics.