FlagItem
Mark a label(s) with a flag(s).
This module provides a pipeline element to mark a label(s) with a flag(s). The intent is to give an easy method to mark particular detections with additional information for later processing. The user can specify any number of flags to mark any number of labels.
Examples:
REST API:
WIP
Configuration File:
Mark bus as large-vehicle:
```yaml
elements:
- name: infer
args:
model: coco-nano
score_threshold: 0.3
iou_threshold: 0.3
- name: flag-item
args:
labels: [bus]
flags: [large-vehicle]
source:
- address: videos/sd_london_station_sd.mp4
type: file
```
Mark cars, buses and motorcycle as vehicles:
```yaml
elements:
- name: infer
args:
model: coco-nano
score_threshold: 0.3
iou_threshold: 0.3
- name: flag-item
args:
labels: [car,bus,motorcycle]
flags: [vehicle]
source:
- address: videos/sd_london_station_sd.mp4
type: file
```
Mark cars, buses and motorcycle as vehicles and ground-transport:
```yaml
elements:
- name: infer
args:
model: coco-nano
score_threshold: 0.3
iou_threshold: 0.3
- name: flag-item
args:
labels: [car,bus,motorcycle]
flags: [vehicle,ground-transport]
source:
- address: videos/sd_london_station_sd.mp4
type: file
```
FlagItem Objects
class FlagItem(Element)
Mark a label(s) with a flag(s).
Attributes:
name
str - The name of the element.labels
list[str] - The labels of the item(s) of interest.flags
list[str] - The flags to mark the item(s) with.
Examples:
Flag car as a vehicle:
```python
ele = FlagItem(labels=["car"], flags=["vehicle"])
```
Flag bus as a vehicle and ground-transport:
```python
ele = FlagItem(labels=["bus"], flags=["vehicle", "ground-transport"])
```
process
def process(meta: PipelineMetadata)
Process the metadata by applying the flag(s) to the item(s).
Arguments:
meta
PipelineMetadata - The metadata to process.
Returns:
meta
PipelineMetadata - The processed metadata.
Examples:
```python
meta = FlagItem(labels=["car", "bus"], flags=["motorcycle"]).process(meta)
```