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:
short-from : flag-item:<s/l-item(s)>:<s/l-flag(s)>
Mark bus as large-vehicle:
pipeline:
- coco-nano:a:0.3:0.3
- flag-item:bus:large-vehicle
source:
- address: https://youtu.be/jY86pXeTOLw
- type: youtube
Mark cars, buses and motorcycle as vehicles:
pipeline:
- coco-nano:a:0.3:0.3
- flag-item:[car,bus,motorcycle]:vehicle
source:
- address: https://youtu.be/jY86pXeTOLw
- type: youtube
Mark cars, buses and motorcycle as vehicles and ground-transport:
pipeline:
- coco-nano:a:0.3:0.3
- flag-item:[car,bus,motorcycle]:[vehicle,ground-transport]
source:
- address: https://youtu.be/jY86pXeTOLw
- type: youtube
FlagItem Objects
class FlagItem(Element)
Mark a label(s) with a flag(s).
Attributes:
name
str - The name of the element.item
Union[str, List[str]] - The label of the item(s) if interest.flag
Union[str, List[str]] - The flag(s) to mark the item(s) with.
Examples:
Flag car as a vehicle:
ele = FlagItem("car", vehicle")
Flag bus as a vehicle and ground-transport:
ele = FlagItem("bus", ["vehicle", "ground-transport"])
extract_params
| @staticmethod
| def extract_params(model_params)
Extract the parameters for this element.
Arguments:
model_params
List[str] - The parameters for this element.
Returns:
item
Union[str, List[str]] - The item(s) to flag.flag
Union[str, List[str]] - The flag(s) to mark the item(s) with.
Raises:
ExtractParameterException
- If the parameters are not valid.
Examples:
params = FlagItem.extract_params(["[car, bus]", "motorcycle"])
ele = FlagItem(*params)
process
| def process(meta)
Process the metadata by applying the flag(s) to the item(s).
Arguments:
meta
dict - The metadata to process.
Returns:
meta
dict - The processed metadata.
Examples:
params = FlagItem.extract_params(["[car, bus]", "motorcycle"])
ele = FlagItem(*params)
meta = ele.process(meta)