# Making predictions with custom model

**URL:** <https://community.ultralytics.com/t/making-predictions-with-custom-model/1532>\
**Category:** Support\
**Tags:** question\
**Created:** [October 5, 2025, 11:43am UTC](https://community.ultralytics.com/t/making-predictions-with-custom-model/1532 "2025-10-05T11:43:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Baker](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/john_baker/32/1044_2.png) [@John\_Baker](https://community.ultralytics.com/u/John_Baker)\
**Post date:** [October 5, 2025, 11:43am UTC](https://community.ultralytics.com/t/making-predictions-with-custom-model/1532/1 "2025-10-05T11:43:42Z")

</div>

Would like to check if I understood correctly about the need to load a new custom model before making predictions…

Following the video tutorial here [Accelerating YOLO11 Projects with Google Colab](https://docs.ultralytics.com/integrations/google-colab/) I see that, after running `model.train()` we need to load the new custom model before we can start using it to make predictions, for example `model_custom = YOLO("/path/to/custom/model.pt")` to load the custom model, then you can do `model_custom.predict()`.

However, the sample code at [https://github.com/ultralytics/ultralytics](https://github.com/ultralytics/ultralytics) suggests you can directly do:

```python
# Load a pretrained YOLO11n model
model = YOLO("yolo11n.pt")

# Train the model on the COCO8 dataset for 100 epochs
train_results = model.train(
    data="coco8.yaml", # Path to dataset configuration file
    epochs=100, # Number of training epochs
    imgsz=640, # Image size for training
    device="cpu", # Device to run on (e.g., 'cpu', 0, [0,1,2,3])
)

# Evaluate the model's performance on the validation set
metrics = model.val()

# Perform object detection on an image
results = model("path/to/image.jpg") # Predict on an image
results[0].show() # Display results

```

In this sample code I think the predictions will be using the pretrained model `yolo11n.pt` and _not_ the new custom model that was just trained. Did I understand that correctly?

---

<div class="post-metadata">

**Author:** ![Toxite](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/toxite/32/123_2.png) [@Toxite](https://community.ultralytics.com/u/Toxite)\
**Post date:** [October 5, 2025, 1:19pm UTC](https://community.ultralytics.com/t/making-predictions-with-custom-model/1532/2 "2025-10-05T13:19:51Z")

</div>

Both would work. Loading the new model is recommended to clear the model object from training data. But it’s not required.

---

<div class="post-metadata">

**Author:** ![John\_Baker](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/john_baker/32/1044_2.png) [@John\_Baker](https://community.ultralytics.com/u/John_Baker)\
**Post date:** [October 6, 2025, 10:52am UTC](https://community.ultralytics.com/t/making-predictions-with-custom-model/1532/3 "2025-10-06T10:52:03Z")

</div>

That’s a bit different to what I’m seeing. I’m seeing prediction classes that are different to those returned by `model.names`. Is that expected?

If I call `model.train()` then `model.predict()` the prediction classes are those of the original (pretrained) model. I expected that the prediction classes would be from the classes defined in the training data. If I check `model.names` I see the classes from the training dataset, but the prediction classes are from the original model’s dataset.

So, I know we can just run one more line of code and load the newly-trained model, but I find it a bit confusing when the model object’s class predictions are not taken from `model.names`.

This is the code I’m running in Google Colab:

```python
!pip install ultralytics
!pip install roboflow

from roboflow import Roboflow
rf = Roboflow(api_key=[api_key_goes_here])
project = rf.workspace("conveyor-550m0").project("conveyor-hhrzw")
version = project.version(3)
dataset = version.download("yolov11")

from ultralytics import YOLO
model = YOLO("yolo11n.pt")

model.names # Classes are from pretrained model {0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', ...

results = model.predict("/content/conveyor-3/valid/images/box_0878_png.rf.873c452bc17b385b0380a9bc4316d38f.jpg")
results[0].show() # Prediction classes are "chair" and "suitcase"

train_results = model.train(data="/content/conveyor-3/data.yaml", epochs=10)

model.names # Classes are from training data {0: 'cardboard box', 1: 'conveyor', 2: 'kartonbox'}

results = model.predict("/content/conveyor-3/valid/images/box_0878_png.rf.873c452bc17b385b0380a9bc4316d38f.jpg")
results[0].show() # Prediction classes are still "chair" and "suitcase", so not from model.names

# Now load the new model we just trained
model_best = YOLO("/content/runs/detect/train/weights/best.pt")

results = model_best.predict("/content/conveyor-3/valid/images/box_0878_png.rf.873c452bc17b385b0380a9bc4316d38f.jpg")
results[0].show() # Prediction class is "cardboard box"

```

---

<div class="post-metadata">

**Author:** ![Toxite](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/toxite/32/123_2.png) [@Toxite](https://community.ultralytics.com/u/Toxite)\
**Post date:** [October 6, 2025, 3:49pm UTC](https://community.ultralytics.com/t/making-predictions-with-custom-model/1532/4 "2025-10-06T15:49:50Z")

</div>

That’s because you ran prediction before training which creates a predictor using the old model that is still retained in the subsequent prediction because we don’t want to create predictor every time.

You can run `model.predictor = None` if you want to reset the predictor.
