I want to visualize the validation and training images without filename over the image. I tried many things but did not output anything. please help me to do that
Thanks for the question! Quick ways to visualize without the filename overlay:
If you want prediction visuals
Use the Results API; it doesn’t draw file names on the image.
from ultralytics import YOLO
import cv2
model = YOLO("yolo11n.pt")
results = model("path/to/image.jpg")
im = results[0].plot(labels=True, conf=True) # no filename overlay
cv2.imwrite("pred.jpg", im)
You can tweak what’s drawn (labels, boxes, masks, etc.) via the results.plot() parameters as shown in the docs under the results.plot() parameters.
If you want ground-truth (train/val) visuals without titles
The train/val “batch” JPGs include filenames because the internal plot_images() sets subplot titles. Easiest is to disable those and render your own clean visuals:
- Disable internal plots during train/val:
model.train(..., plots=False) - Then draw your ground-truth boxes without any filename using:
from ultralytics.data.utils import visualize_image_annotations
label_map = {0: "class0", 1: "class1"} # your classes
visualize_image_annotations("path/to/img.jpg", "path/to/labels.txt", label_map)
This helper draws only boxes/labels, no filenames. See the reference for visualize_image_annotations.
If you must keep the built-in train/val plots but hide filenames
A quick workaround is to monkey‑patch plot_images to ignore the paths (so no titles). Do this once before training:
import ultralytics.utils.plotting as P
_orig = P.plot_images
def plot_images_no_titles(*args, **kwargs):
kwargs["paths"] = None
return _orig(*args, **kwargs)
P.plot_images = plot_images_no_titles
If you share a small snippet of what you tried, I can suggest the minimal change.