mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-15 07:35:27 +03:00
Add ability to restrict genai to labels and zones at the camera level
This commit is contained in:
parent
e935db5075
commit
8ed86a907a
@ -128,7 +128,7 @@ genai:
|
||||
car: "Label the primary vehicle in these images with just the name of the company if it is a delivery vehicle, or the color make and model."
|
||||
```
|
||||
|
||||
Prompts can also be overriden at the camera level to provide a more detailed prompt to the model about your specific camera, if you desire.
|
||||
Prompts can also be overriden at the camera level to provide a more detailed prompt to the model about your specific camera, if you desire. You can also optionally specify `labels` and `required_zones` to only generate descriptions for certain labels or zones.
|
||||
|
||||
```yaml
|
||||
cameras:
|
||||
@ -138,6 +138,11 @@ cameras:
|
||||
object_prompts:
|
||||
person: "Describe the main person in these images (gender, age, clothing, activity, etc). Do not include where the activity is occurring (sidewalk, concrete, driveway, etc). If delivering a package, include the company the package is from."
|
||||
cat: "Describe the cat in these images (color, size, tail). Indicate whether or not the cat is by the flower pots. If the cat is chasing a mouse, make up a name for the mouse."
|
||||
labels:
|
||||
- person
|
||||
- cat
|
||||
required_zones:
|
||||
- steps
|
||||
```
|
||||
|
||||
### Experiment with prompts
|
||||
|
||||
@ -723,6 +723,12 @@ cameras:
|
||||
# Format: {label}: {prompt}
|
||||
object_prompts:
|
||||
person: "My special person prompt."
|
||||
# Optional: labels that qualify as an alert (default: all labels that are tracked)
|
||||
labels:
|
||||
- person
|
||||
- cat
|
||||
# Optional: Restrict generation to objects that entered any of the listed zones (default: none, all zones qualify)
|
||||
required_zones: []
|
||||
|
||||
# Optional
|
||||
ui:
|
||||
|
||||
@ -810,6 +810,21 @@ class GenAICameraConfig(BaseModel):
|
||||
title="Default caption prompt.",
|
||||
)
|
||||
object_prompts: Dict[str, str] = Field(default={}, title="Object specific prompts.")
|
||||
labels: Optional[List[str]] = Field(
|
||||
default=None, title="Labels to run generative AI for."
|
||||
)
|
||||
required_zones: Union[str, List[str]] = Field(
|
||||
default_factory=list,
|
||||
title="List of required zones to be entered in order to run generative AI.",
|
||||
)
|
||||
|
||||
@field_validator("required_zones", mode="before")
|
||||
@classmethod
|
||||
def validate_required_zones(cls, v):
|
||||
if isinstance(v, str) and "," not in v:
|
||||
return [v]
|
||||
|
||||
return v
|
||||
|
||||
|
||||
class AudioConfig(FrigateBaseModel):
|
||||
|
||||
@ -127,6 +127,14 @@ class EmbeddingMaintainer(threading.Thread):
|
||||
camera_config.genai.enabled
|
||||
and self.genai_client is not None
|
||||
and event.data.get("description") is None
|
||||
and (
|
||||
camera_config.genai.labels is None
|
||||
or event.label in camera_config.genai.labels
|
||||
)
|
||||
and (
|
||||
camera_config.genai.required_zones is None
|
||||
or set(event.zones) & set(camera_config.genai.zones)
|
||||
)
|
||||
):
|
||||
# Generate the description. Call happens in a thread since it is network bound.
|
||||
threading.Thread(
|
||||
|
||||
@ -306,6 +306,8 @@ export interface FrigateConfig {
|
||||
model: string;
|
||||
prompt: string;
|
||||
object_prompts: { [key: string]: string };
|
||||
required_zones: string[];
|
||||
labels: string[];
|
||||
};
|
||||
|
||||
go2rtc: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user