mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-24 17:18:23 +03:00
Cleanups and fixes
This commit is contained in:
parent
5841d1f573
commit
885eef6026
@ -772,28 +772,19 @@ def delete_classification_train_images(request: Request, name: str, body: dict =
|
|||||||
)
|
)
|
||||||
async def generate_state_examples(request: Request, body: GenerateStateExamplesBody):
|
async def generate_state_examples(request: Request, body: GenerateStateExamplesBody):
|
||||||
"""Generate examples for state classification."""
|
"""Generate examples for state classification."""
|
||||||
try:
|
model_name = sanitize_filename(body.model_name)
|
||||||
cameras_normalized = {
|
cameras_normalized = {
|
||||||
camera_name: tuple(crop)
|
camera_name: tuple(crop)
|
||||||
for camera_name, crop in body.cameras.items()
|
for camera_name, crop in body.cameras.items()
|
||||||
if camera_name in request.app.frigate_config.cameras
|
if camera_name in request.app.frigate_config.cameras
|
||||||
}
|
}
|
||||||
|
|
||||||
collect_state_classification_examples(body.model_name, cameras_normalized)
|
collect_state_classification_examples(model_name, cameras_normalized)
|
||||||
|
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content={"success": True, "message": "Example generation completed"},
|
content={"success": True, "message": "Example generation completed"},
|
||||||
status_code=200,
|
status_code=200,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Failed to generate state examples: {e}")
|
|
||||||
return JSONResponse(
|
|
||||||
content={
|
|
||||||
"success": False,
|
|
||||||
"message": f"Failed to generate examples: {str(e)}",
|
|
||||||
},
|
|
||||||
status_code=500,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@router.post(
|
@router.post(
|
||||||
@ -804,19 +795,10 @@ async def generate_state_examples(request: Request, body: GenerateStateExamplesB
|
|||||||
)
|
)
|
||||||
async def generate_object_examples(request: Request, body: GenerateObjectExamplesBody):
|
async def generate_object_examples(request: Request, body: GenerateObjectExamplesBody):
|
||||||
"""Generate examples for object classification."""
|
"""Generate examples for object classification."""
|
||||||
try:
|
model_name = sanitize_filename(body.model_name)
|
||||||
collect_object_classification_examples(body.model_name, body.label)
|
collect_object_classification_examples(model_name, body.label)
|
||||||
|
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content={"success": True, "message": "Example generation completed"},
|
content={"success": True, "message": "Example generation completed"},
|
||||||
status_code=200,
|
status_code=200,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Failed to generate object examples: {e}")
|
|
||||||
return JSONResponse(
|
|
||||||
content={
|
|
||||||
"success": False,
|
|
||||||
"message": f"Failed to generate examples: {str(e)}",
|
|
||||||
},
|
|
||||||
status_code=500,
|
|
||||||
)
|
|
||||||
|
|||||||
@ -4,11 +4,11 @@ from pydantic import BaseModel, Field
|
|||||||
|
|
||||||
|
|
||||||
class RenameFaceBody(BaseModel):
|
class RenameFaceBody(BaseModel):
|
||||||
new_name: str
|
new_name: str = Field(description="New name for the face")
|
||||||
|
|
||||||
|
|
||||||
class AudioTranscriptionBody(BaseModel):
|
class AudioTranscriptionBody(BaseModel):
|
||||||
event_id: str
|
event_id: str = Field(description="ID of the event to transcribe audio for")
|
||||||
|
|
||||||
|
|
||||||
class DeleteFaceImagesBody(BaseModel):
|
class DeleteFaceImagesBody(BaseModel):
|
||||||
@ -18,12 +18,14 @@ class DeleteFaceImagesBody(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class GenerateStateExamplesBody(BaseModel):
|
class GenerateStateExamplesBody(BaseModel):
|
||||||
model_name: str
|
model_name: str = Field(description="Name of the classification model")
|
||||||
cameras: Dict[str, Tuple[float, float, float, float]] = Field(
|
cameras: Dict[str, Tuple[float, float, float, float]] = Field(
|
||||||
description="Dictionary mapping camera names to crop coordinates (x, y, width, height) normalized 0-1"
|
description="Dictionary mapping camera names to normalized crop coordinates in [x1, y1, x2, y2] format (values 0-1)"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class GenerateObjectExamplesBody(BaseModel):
|
class GenerateObjectExamplesBody(BaseModel):
|
||||||
model_name: str
|
model_name: str = Field(description="Name of the classification model")
|
||||||
label: str
|
label: str = Field(
|
||||||
|
description="Object label to collect examples for (e.g., 'person', 'car')"
|
||||||
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user