# How to run object detection inference with a YOLOE segmentation model?

**URL:** <https://community.ultralytics.com/t/how-to-run-object-detection-inference-with-a-yoloe-segmentation-model/1436>\
**Category:** Discussion\
**Tags:** code\
**Created:** [September 2, 2025, 6:02pm UTC](https://community.ultralytics.com/t/how-to-run-object-detection-inference-with-a-yoloe-segmentation-model/1436 "2025-09-02T18:02:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kallinteris-Andreas](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/kallinteris-andreas/32/838_2.png) [@Kallinteris-Andreas](https://community.ultralytics.com/u/Kallinteris-Andreas)\
**Post date:** [September 2, 2025, 6:02pm UTC](https://community.ultralytics.com/t/how-to-run-object-detection-inference-with-a-yoloe-segmentation-model/1436/1 "2025-09-02T18:02:22Z")

</div>

How to load YOLOE model without the segmentation head

YOLOE support training for object detection, and I am trying to verify inference of an YOLOE object detection models works and benchmark it

```py
model = YOLO("yoloe-11l.yaml").load('panopticon_models/yoloe-11l-seg.pt')
model.set_classes(["person"]) # this fails 
model.predict()

```

Note: I am not up-to-date with how the latest YOLO architectures do segmentation, the latest paper I have read is `YOLOACT`, and I assume that YOLO{NUMEBER}-seg models work in a similar way (by extending detection head to detect mask)

Thanks!

---

<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:** [September 2, 2025, 11:14pm UTC](https://community.ultralytics.com/t/how-to-run-object-detection-inference-with-a-yoloe-segmentation-model/1436/2 "2025-09-02T23:14:06Z")

</div>

The code you provided works fine for me. What exactly “fails”?

---

<div class="post-metadata">

**Author:** ![Kallinteris-Andreas](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/kallinteris-andreas/32/838_2.png) [@Kallinteris-Andreas](https://community.ultralytics.com/u/Kallinteris-Andreas)\
**Post date:** [September 3, 2025, 7:11am UTC](https://community.ultralytics.com/t/how-to-run-object-detection-inference-with-a-yoloe-segmentation-model/1436/3 "2025-09-03T07:11:06Z")

</div>

```sh
$ py
Python 3.12.11 (main, Jul 23 2025, 11:34:34) [GCC 15.1.1 20250425] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ultralytics import YOLO
>>> model = YOLO("yoloe-11l.yaml").load('panopticon_models/yoloe-11l-seg.pt')
Transferred 1108/1108 items from pretrained weights
>>> model.set_classes(["person"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/master-andreas/panopticon/test_env/lib/python3.12/site-packages/ultralytics/models/yolo/model.py", line 330, in set_classes
    embeddings = self.get_text_pe(classes) # generate text embeddings if not provided
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/master-andreas/panopticon/test_env/lib/python3.12/site-packages/ultralytics/models/yolo/model.py", line 269, in get_text_pe
    return self.model.get_text_pe(texts)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/master-andreas/panopticon/test_env/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 120, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/master-andreas/panopticon/test_env/lib/python3.12/site-packages/ultralytics/nn/tasks.py", line 1038, in get_text_pe
    assert not self.training
           ^^^^^^^^^^^^^^^^^
AssertionError

```

---

<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:** [September 3, 2025, 8:51am UTC](https://community.ultralytics.com/t/how-to-run-object-detection-inference-with-a-yoloe-segmentation-model/1436/4 "2025-09-03T08:51:19Z")

</div>

You’re using `set_classes()` incorrectly.

> **[YOLOE (Real-Time Seeing Anything)](https://docs.ultralytics.com/models/yoloe/#predict-usage)**
>
> YOLOE is a real-time open-vocabulary detection and segmentation model that extends YOLO with text, image, or internal vocabulary prompts, enabling detection of any object class with state-of-the-art zero-shot performance.

---

<div class="post-metadata">

**Author:** ![Kallinteris-Andreas](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/kallinteris-andreas/32/838_2.png) [@Kallinteris-Andreas](https://community.ultralytics.com/u/Kallinteris-Andreas)\
**Post date:** [September 14, 2025, 1:37pm UTC](https://community.ultralytics.com/t/how-to-run-object-detection-inference-with-a-yoloe-segmentation-model/1436/5 "2025-09-14T13:37:15Z")

</div>

that is a perfectly valid way of using `YOLOE.set_classes`, but even if the more verbose way of using the function is used (as shown in the documentation), it fails in the same way

```py
from ultralytics import YOLO

model = YOLO("yoloe-11l.yaml").load('panopticon_models/yoloe-11l-seg.pt')
names = ['person']
model.set_classes(names, model.get_text_pe(names)) # this also fails
model.set_classes(names) # this fails

```

```sh
$ py test.py                                    
Transferred 1108/1108 items from pretrained weights
Traceback (most recent call last):
  File "/home/master-andreas/panopticon/test.py", line 5, in <module>
    model.set_classes(names, model.get_text_pe(names)) # this also fails
                             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/master-andreas/panopticon/test_env/lib/python3.12/site-packages/ultralytics/models/yolo/model.py", line 269, in get_text_pe
    return self.model.get_text_pe(texts)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/master-andreas/panopticon/test_env/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 120, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/master-andreas/panopticon/test_env/lib/python3.12/site-packages/ultralytics/nn/tasks.py", line 1038, in get_text_pe
    assert not self.training
           ^^^^^^^^^^^^^^^^^
AssertionError

```

---

<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:** [September 14, 2025, 2:10pm UTC](https://community.ultralytics.com/t/how-to-run-object-detection-inference-with-a-yoloe-segmentation-model/1436/6 "2025-09-14T14:10:55Z")

</div>

Seems like your transferring of the weights is causing the issue.

You can do `model.eval()` before `set_classes()`

---

<div class="post-metadata">

**Author:** ![Kallinteris-Andreas](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/kallinteris-andreas/32/838_2.png) [@Kallinteris-Andreas](https://community.ultralytics.com/u/Kallinteris-Andreas)\
**Post date:** [September 14, 2025, 2:32pm UTC](https://community.ultralytics.com/t/how-to-run-object-detection-inference-with-a-yoloe-segmentation-model/1436/7 "2025-09-14T14:32:28Z")

</div>

It works thanks

```py
from ultralytics import YOLO

model = YOLO("yoloe-11s.yaml").load('panopticon_models/yoloe-11s-seg.pt')
model.eval()
names = ['person']
model.set_classes(names, model.get_text_pe(names)) # this works 
model.set_classes(names) # this also works

```

What does `YOLOE.eval()` do, I can not seem to find any details on the documentation, (I can only find the `val()` method, which does something different)

---

<div class="post-metadata">

**Author:** ![BurhanQ](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/burhanq/32/7_2.png) [@BurhanQ](https://community.ultralytics.com/u/BurhanQ)\
**Post date:** [September 14, 2025, 2:36pm UTC](https://community.ultralytics.com/t/how-to-run-object-detection-inference-with-a-yoloe-segmentation-model/1436/8 "2025-09-14T14:36:16Z")

</div>

That is because it’s not an Ultralytics specific method, it’s inherited from the PyTorch `Module` class and you can check those docs here

> **[Module — PyTorch 2.8 documentation](https://docs.pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.eval)**
