Giter VIP home page Giter VIP logo

Comments (6)

github-actions avatar github-actions commented on June 16, 2024

👋 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):

Status

Ultralytics CI

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.

Kayzwer avatar Kayzwer commented on June 16, 2024

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.

iyzyi avatar iyzyi commented on June 16, 2024

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.

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.

Kayzwer avatar Kayzwer commented on June 16, 2024

@iyzyi this should not happen, probably a bug, are you using the latest version of ultralytics?

from ultralytics.

iyzyi avatar iyzyi commented on June 16, 2024

@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.

iyzyi avatar iyzyi commented on June 16, 2024

I am sure my dataset is right because I can use bset.pt to do my custom predict.

from ultralytics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.