Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include processor capabilities in the config/info endpoint. #159

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,18 @@ class Config:
}


class ConfigMetrics(BaseModel):
social_distancing: bool
facemask: bool
occupancy: bool
in_out: bool


class ConfigInfo(BaseModel):
version: str
device: str
has_been_configured: bool
metrics: ConfigMetrics

class Config:
schema_extra = {
Expand Down
14 changes: 13 additions & 1 deletion api/routers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ def map_config(config, options):
}


def _get_available_metrics(config):
detector_model = config.get_section_dict("Detector")["Name"]
facemask_available_models = ['openpifpaf', 'openpifpaf_tensorrt', 'posenet']
return {
"social_distancing": True,
"facemask": detector_model in facemask_available_models and "Classifier" in config.get_sections(),
"occupancy": True,
"in_out": True,
}


def processor_info(config):
has_been_configured = config.get_boolean("App", "HasBeenConfigured")
device = config.get_section_dict("Detector")["Device"]
Expand All @@ -71,7 +82,8 @@ def processor_info(config):
return {
"version": PROCESSOR_VERSION,
"device": device,
"has_been_configured": has_been_configured
"has_been_configured": has_been_configured,
"metrics": _get_available_metrics(config),
}


Expand Down