> For the complete documentation index, see [llms.txt](https://docs.degirum.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.degirum.com/vehicle-analytics/guides/overview/configuration.md).

# Configuration

## LicensePlateRecognizerConfig Anatomy

`LicensePlateRecognizer` is configured entirely through a `LicensePlateRecognizerConfig` object with these components:

```python
import degirum_vehicle

config = degirum_vehicle.LicensePlateRecognizerConfig(
    license_plate_detection_model_spec=detection_spec,  # 1. Detection model
    license_plate_ocr_model_spec=ocr_spec,             # 2. OCR model
)
```

### 1. License Plate Detection Model Spec

Specifies which model detects license plate regions and their bounding boxes.

**Default:** TFLITE/CPU model on @cloud inference host

```python
detection_spec = degirum_vehicle.get_license_plate_detection_model_spec(
    device_type="HAILORT/HAILO8",
    inference_host_address="@cloud"
)
```

### 2. License Plate OCR Model Spec

Specifies which model extracts text from detected license plate regions.

**Default:** TFLITE/CPU model on @cloud inference host

```python
ocr_spec = degirum_vehicle.get_license_plate_ocr_model_spec(
    device_type="HAILORT/HAILO8",
    inference_host_address="@cloud"
)
```

## Model Specs Explained

A `ModelSpec` tells `degirum-vehicle` which model to load and where to run it.

**Configuration Philosophy:** You can configure models by explicitly specifying model specs (Options 2 & 3) or use the convenience method (Option 1) that automatically selects the right models for your hardware. Additionally, you can initialize from YAML files (Option 4) for production deployments.

You have four options to initialize the configuration:

### Option 1: Use from\_hardware() Convenience Method (Recommended)

The easiest approach - just specify your hardware and inference location. The model registry automatically selects the best detection and OCR models for you:

```python
import degirum_vehicle

# Run on cloud CPU
config = degirum_vehicle.LicensePlateRecognizerConfig.from_hardware(
    "TFLITE/CPU",
    inference_host_address="@cloud"
)

# Create recognizer
lpr = degirum_vehicle.LicensePlateRecognizer(config)
```

**Other examples:**

```python
# Run on local Hailo device
config = degirum_vehicle.LicensePlateRecognizerConfig.from_hardware(
    "HAILORT/HAILO8",
    inference_host_address="@local"
)

# Run on specific GPU
config = degirum_vehicle.LicensePlateRecognizerConfig.from_hardware(
    "TENSORRT/GPU",
    inference_host_address="localhost"
)
```

**When to use:** Most use cases - fastest way to get started without worrying about individual model selection.

### Option 2: Use Model Registry Helper Functions

For more control, specify models individually using the registry helper functions:

```python
import degirum_vehicle

# Get detection model spec
detection_spec = degirum_vehicle.get_license_plate_detection_model_spec(
    device_type="HAILORT/HAILO8",
    inference_host_address="@cloud"
)

# Get OCR model spec
ocr_spec = degirum_vehicle.get_license_plate_ocr_model_spec(
    device_type="HAILORT/HAILO8",
    inference_host_address="@cloud"
)

# Create config with explicit model specs
config = degirum_vehicle.LicensePlateRecognizerConfig(
    license_plate_detection_model_spec=detection_spec,
    license_plate_ocr_model_spec=ocr_spec
)

# Create recognizer
lpr = degirum_vehicle.LicensePlateRecognizer(config)
```

**Parameters:**

* `device_type` - Hardware accelerator (see supported hardware below)
* `inference_host_address` - Inference location: `@cloud`, `@local`, or AI server address

**Supported Hardware:**

See the complete list of [supported hardware platforms](/vehicle-analytics/getting-started/basic-concepts.md#what-hardware-is-supported).

**When to use:** When you need different hardware/hosts for detection vs OCR models, or want explicit control over model selection.

### Option 3: Bring Your Own Models

For complete customization (using models outside the registry), create custom `ModelSpec` objects directly. See [ModelSpec Documentation](https://docs.degirum.com/degirum-tools/model_registry#modelspec) for details.

**When to use:** Custom-trained models, private model zoos, or models not in the official degirum-vehicle registry.

***

## YAML Configuration (Option 4)

For production deployments and version-controlled configurations, initialize from YAML files:

```yaml
license_plate_detection_model:
  hardware: "TFLITE/CPU"
  inference_host_address: "@cloud"

license_plate_ocr_model:
  hardware: "TFLITE/CPU"
  inference_host_address: "@cloud"
```

**Load from YAML:**

```python
import degirum_vehicle

# Load from file
config, settings = degirum_vehicle.LicensePlateRecognizerConfig.from_yaml(
    yaml_file="lpr_config.yaml"
)

# Or from string
config, settings = degirum_vehicle.LicensePlateRecognizerConfig.from_yaml(
    yaml_str=yaml_content
)

# Create recognizer
lpr = degirum_vehicle.LicensePlateRecognizer(config)
```

**When to use:** Production environments, CI/CD pipelines, or when you need to version-control and share configurations across teams.

**Example YAML:** See [lpr\_recognition.yaml](https://github.com/DeGirum/vehicle_analytics/tree/main/examples/lpr_recognition.yaml) for a complete configuration.

***

## Configuration Examples

### Basic - Default Configuration

```python
import degirum_vehicle

# Uses defaults: TFLITE/CPU running on cloud
lpr = degirum_vehicle.LicensePlateRecognizer()
```

Equivalent to:

```python
config = degirum_vehicle.LicensePlateRecognizerConfig()
lpr = degirum_vehicle.LicensePlateRecognizer(config)
```

**Defaults:**

* Hardware: `TFLITE/CPU`
* Inference: `@cloud`

### Cloud Experimentation

Try different hardware without local setup:

```python
import degirum_vehicle

# Test Hailo-8 on cloud
config = degirum_vehicle.LicensePlateRecognizerConfig.from_hardware(
    "HAILORT/HAILO8",
    inference_host_address="@cloud"
)

lpr = degirum_vehicle.LicensePlateRecognizer(config)
```

### Local Edge Deployment

Run on local Hailo-8 accelerator:

```python
import degirum_vehicle

# Local Hailo-8
config = degirum_vehicle.LicensePlateRecognizerConfig.from_hardware(
    "HAILORT/HAILO8",
    inference_host_address="@local"
)

lpr = degirum_vehicle.LicensePlateRecognizer(config)
```

### Remote Inference Server

Connect to dedicated AI server:

```python
import degirum_vehicle

# Remote NVIDIA GPU server
config = degirum_vehicle.LicensePlateRecognizerConfig.from_hardware(
    "TENSORRT/GPU",
    inference_host_address="192.168.1.100:8778"
)

lpr = degirum_vehicle.LicensePlateRecognizer(config)
```

### Mixed Hardware Setup

Use different hardware for detection and OCR:

```python
import degirum_vehicle

# Detection on Hailo-8, OCR on GPU
detection_spec = degirum_vehicle.get_license_plate_detection_model_spec(
    device_type="HAILORT/HAILO8",
    inference_host_address="@local"
)

ocr_spec = degirum_vehicle.get_license_plate_ocr_model_spec(
    device_type="TENSORRT/GPU",
    inference_host_address="localhost"
)

config = degirum_vehicle.LicensePlateRecognizerConfig(
    license_plate_detection_model_spec=detection_spec,
    license_plate_ocr_model_spec=ocr_spec
)

lpr = degirum_vehicle.LicensePlateRecognizer(config)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.degirum.com/vehicle-analytics/guides/overview/configuration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
