Skip to content

Reference for ultralytics/solutions/config.py

Improvements

This page is sourced from https://github.com/ultralytics/ultralytics/blob/main/ultralytics/solutions/config.py. Have an improvement or example to add? Open a Pull Request — thank you! 🙏


class ultralytics.solutions.config.SolutionConfig

SolutionConfig()

Manages configuration parameters for Ultralytics Vision AI solutions.

The SolutionConfig class serves as a centralized configuration container for all the Ultralytics solution modules: https://docs.ultralytics.com/solutions/#solutions. It leverages Python dataclass for clear, type-safe, and maintainable parameter definitions.

Attributes

NameTypeDescription
sourcestr, optionalPath to the input source (video, RTSP, etc.). Only usable with Solutions CLI.
modelstr, optionalPath to the Ultralytics YOLO model to be used for inference.
classeslist[int], optionalList of class indices to filter detections.
show_confboolWhether to show confidence scores on the visual output.
show_labelsboolWhether to display class labels on visual output.
regionlist[tuple[int, int]], optionalPolygonal region or line for object counting.
colormapint, optionalOpenCV colormap constant for visual overlays (e.g., cv2.COLORMAP_JET).
show_inboolWhether to display count number for objects entering the region.
show_outboolWhether to display count number for objects leaving the region.
up_anglefloatUpper angle threshold used in pose-based workouts monitoring.
down_angleintLower angle threshold used in pose-based workouts monitoring.
kptslist[int]Keypoint indices to monitor, e.g., for pose analytics.
analytics_typestrType of analytics to perform ("line", "area", "bar", "pie", etc.).
figsizetuple[int, int], optionalSize of the matplotlib figure used for analytical plots (width, height).
blur_ratiofloatRatio used to blur objects in the video frames (0.0 to 1.0).
vision_pointtuple[int, int]Reference point for directional tracking or perspective drawing.
crop_dirstrDirectory path to save cropped detection images.
json_filestrPath to a JSON file containing data for parking areas.
line_widthintWidth for visual display i.e. bounding boxes, keypoints, counts.
recordsintNumber of detection records to send email alerts.
fpsfloatFrame rate (Frames Per Second) for speed estimation calculation.
max_histintMaximum number of historical points or states stored per tracked object for speed estimation.
meter_per_pixelfloatScale for real-world measurement, used in speed or distance calculations.
max_speedintMaximum speed limit (e.g., km/h or mph) used in visual alerts or constraints.
showboolWhether to display the visual output on screen.
ioufloatIntersection-over-Union threshold for detection filtering.
conffloatConfidence threshold for keeping predictions.
devicestr, optionalDevice to run inference on (e.g., 'cpu', '0' for CUDA GPU).
max_detintMaximum number of detections allowed per video frame.
halfboolWhether to use FP16 precision (requires a supported CUDA device).
trackerstrPath to tracking configuration YAML file (e.g., 'botsort.yaml').
verboseboolEnable verbose logging output for debugging or diagnostics.
datastrPath to image directory used for similarity search.

Methods

NameDescription
updateUpdate configuration parameters with new values provided as keyword arguments.

Examples

>>> from ultralytics.solutions.config import SolutionConfig
>>> cfg = SolutionConfig(model="yolo11n.pt", region=[(0, 0), (100, 0), (100, 100), (0, 100)])
>>> cfg.update(show=False, conf=0.3)
>>> print(cfg.model)
Source code in ultralytics/solutions/config.pyView on GitHub
@dataclass
class SolutionConfig:


method ultralytics.solutions.config.SolutionConfig.update

def update(self, **kwargs: Any)

Update configuration parameters with new values provided as keyword arguments.

Args

NameTypeDescriptionDefault
**kwargsAnyrequired
Source code in ultralytics/solutions/config.pyView on GitHub
def update(self, **kwargs: Any):
    """Update configuration parameters with new values provided as keyword arguments."""
    for key, value in kwargs.items():
        if hasattr(self, key):
            setattr(self, key, value)
        else:
            url = "https://docs.ultralytics.com/solutions/#solutions-arguments"
            raise ValueError(f"{key} is not a valid solution argument, see {url}")

    return self





📅 Created 7 months ago ✏️ Updated 18 days ago
glenn-jocherRizwanMunawar