mirror of
https://github.com/home-assistant/core.git
synced 2026-05-04 11:54:35 +02:00
Remove dlib face integrations (#155450)
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
"""The dlib_face_detect component."""
|
||||
|
||||
DOMAIN = "dlib_face_detect"
|
||||
@@ -1,82 +0,0 @@
|
||||
"""Component that will help set the Dlib face detect processing."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
|
||||
import face_recognition
|
||||
|
||||
from homeassistant.components.image_processing import (
|
||||
PLATFORM_SCHEMA as IMAGE_PROCESSING_PLATFORM_SCHEMA,
|
||||
ImageProcessingFaceEntity,
|
||||
)
|
||||
from homeassistant.const import ATTR_LOCATION, CONF_ENTITY_ID, CONF_NAME, CONF_SOURCE
|
||||
from homeassistant.core import (
|
||||
DOMAIN as HOMEASSISTANT_DOMAIN,
|
||||
HomeAssistant,
|
||||
split_entity_id,
|
||||
)
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, create_issue
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from . import DOMAIN
|
||||
|
||||
PLATFORM_SCHEMA = IMAGE_PROCESSING_PLATFORM_SCHEMA
|
||||
|
||||
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the Dlib Face detection platform."""
|
||||
create_issue(
|
||||
hass,
|
||||
HOMEASSISTANT_DOMAIN,
|
||||
f"deprecated_system_packages_yaml_integration_{DOMAIN}",
|
||||
breaks_in_ha_version="2025.12.0",
|
||||
is_fixable=False,
|
||||
issue_domain=DOMAIN,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="deprecated_system_packages_yaml_integration",
|
||||
translation_placeholders={
|
||||
"domain": DOMAIN,
|
||||
"integration_title": "Dlib Face Detect",
|
||||
},
|
||||
)
|
||||
source: list[dict[str, str]] = config[CONF_SOURCE]
|
||||
add_entities(
|
||||
DlibFaceDetectEntity(camera[CONF_ENTITY_ID], camera.get(CONF_NAME))
|
||||
for camera in source
|
||||
)
|
||||
|
||||
|
||||
class DlibFaceDetectEntity(ImageProcessingFaceEntity):
|
||||
"""Dlib Face API entity for identify."""
|
||||
|
||||
def __init__(self, camera_entity: str, name: str | None) -> None:
|
||||
"""Initialize Dlib face entity."""
|
||||
super().__init__()
|
||||
|
||||
self._attr_camera_entity = camera_entity
|
||||
|
||||
if name:
|
||||
self._attr_name = name
|
||||
else:
|
||||
self._attr_name = f"Dlib Face {split_entity_id(camera_entity)[1]}"
|
||||
|
||||
def process_image(self, image: bytes) -> None:
|
||||
"""Process image."""
|
||||
|
||||
fak_file = io.BytesIO(image)
|
||||
fak_file.name = "snapshot.jpg"
|
||||
fak_file.seek(0)
|
||||
|
||||
image = face_recognition.load_image_file(fak_file)
|
||||
face_locations = face_recognition.face_locations(image)
|
||||
|
||||
face_locations = [{ATTR_LOCATION: location} for location in face_locations]
|
||||
|
||||
self.process_faces(face_locations, len(face_locations))
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"domain": "dlib_face_detect",
|
||||
"name": "Dlib Face Detect",
|
||||
"codeowners": [],
|
||||
"documentation": "https://www.home-assistant.io/integrations/dlib_face_detect",
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["face_recognition"],
|
||||
"quality_scale": "legacy",
|
||||
"requirements": ["face-recognition==1.2.3"]
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
"""The dlib_face_identify component."""
|
||||
|
||||
CONF_FACES = "faces"
|
||||
DOMAIN = "dlib_face_identify"
|
||||
@@ -1,127 +0,0 @@
|
||||
"""Component that will help set the Dlib face detect processing."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import logging
|
||||
|
||||
import face_recognition
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.image_processing import (
|
||||
CONF_CONFIDENCE,
|
||||
PLATFORM_SCHEMA as IMAGE_PROCESSING_PLATFORM_SCHEMA,
|
||||
FaceInformation,
|
||||
ImageProcessingFaceEntity,
|
||||
)
|
||||
from homeassistant.const import ATTR_NAME, CONF_ENTITY_ID, CONF_NAME, CONF_SOURCE
|
||||
from homeassistant.core import (
|
||||
DOMAIN as HOMEASSISTANT_DOMAIN,
|
||||
HomeAssistant,
|
||||
split_entity_id,
|
||||
)
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, create_issue
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from . import CONF_FACES, DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
PLATFORM_SCHEMA = IMAGE_PROCESSING_PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_FACES): {cv.string: cv.isfile},
|
||||
vol.Optional(CONF_CONFIDENCE, default=0.6): vol.Coerce(float),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the Dlib Face detection platform."""
|
||||
create_issue(
|
||||
hass,
|
||||
HOMEASSISTANT_DOMAIN,
|
||||
f"deprecated_system_packages_yaml_integration_{DOMAIN}",
|
||||
breaks_in_ha_version="2025.12.0",
|
||||
is_fixable=False,
|
||||
issue_domain=DOMAIN,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="deprecated_system_packages_yaml_integration",
|
||||
translation_placeholders={
|
||||
"domain": DOMAIN,
|
||||
"integration_title": "Dlib Face Identify",
|
||||
},
|
||||
)
|
||||
|
||||
confidence: float = config[CONF_CONFIDENCE]
|
||||
faces: dict[str, str] = config[CONF_FACES]
|
||||
source: list[dict[str, str]] = config[CONF_SOURCE]
|
||||
add_entities(
|
||||
DlibFaceIdentifyEntity(
|
||||
camera[CONF_ENTITY_ID],
|
||||
faces,
|
||||
camera.get(CONF_NAME),
|
||||
confidence,
|
||||
)
|
||||
for camera in source
|
||||
)
|
||||
|
||||
|
||||
class DlibFaceIdentifyEntity(ImageProcessingFaceEntity):
|
||||
"""Dlib Face API entity for identify."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
camera_entity: str,
|
||||
faces: dict[str, str],
|
||||
name: str | None,
|
||||
tolerance: float,
|
||||
) -> None:
|
||||
"""Initialize Dlib face identify entry."""
|
||||
|
||||
super().__init__()
|
||||
|
||||
self._attr_camera_entity = camera_entity
|
||||
|
||||
if name:
|
||||
self._attr_name = name
|
||||
else:
|
||||
self._attr_name = f"Dlib Face {split_entity_id(camera_entity)[1]}"
|
||||
|
||||
self._faces = {}
|
||||
for face_name, face_file in faces.items():
|
||||
try:
|
||||
image = face_recognition.load_image_file(face_file)
|
||||
self._faces[face_name] = face_recognition.face_encodings(image)[0]
|
||||
except IndexError as err:
|
||||
_LOGGER.error("Failed to parse %s. Error: %s", face_file, err)
|
||||
|
||||
self._tolerance = tolerance
|
||||
|
||||
def process_image(self, image: bytes) -> None:
|
||||
"""Process image."""
|
||||
|
||||
fak_file = io.BytesIO(image)
|
||||
fak_file.name = "snapshot.jpg"
|
||||
fak_file.seek(0)
|
||||
|
||||
image = face_recognition.load_image_file(fak_file)
|
||||
unknowns = face_recognition.face_encodings(image)
|
||||
|
||||
found: list[FaceInformation] = []
|
||||
for unknown_face in unknowns:
|
||||
for name, face in self._faces.items():
|
||||
result = face_recognition.compare_faces(
|
||||
[face], unknown_face, tolerance=self._tolerance
|
||||
)
|
||||
if result[0]:
|
||||
found.append({ATTR_NAME: name})
|
||||
|
||||
self.process_faces(found, len(unknowns))
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"domain": "dlib_face_identify",
|
||||
"name": "Dlib Face Identify",
|
||||
"codeowners": [],
|
||||
"documentation": "https://www.home-assistant.io/integrations/dlib_face_identify",
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["face_recognition"],
|
||||
"quality_scale": "legacy",
|
||||
"requirements": ["face-recognition==1.2.3"]
|
||||
}
|
||||
@@ -1364,18 +1364,6 @@
|
||||
"config_flow": true,
|
||||
"iot_class": "cloud_polling"
|
||||
},
|
||||
"dlib_face_detect": {
|
||||
"name": "Dlib Face Detect",
|
||||
"integration_type": "hub",
|
||||
"config_flow": false,
|
||||
"iot_class": "local_push"
|
||||
},
|
||||
"dlib_face_identify": {
|
||||
"name": "Dlib Face Identify",
|
||||
"integration_type": "hub",
|
||||
"config_flow": false,
|
||||
"iot_class": "local_push"
|
||||
},
|
||||
"dlink": {
|
||||
"name": "D-Link Wi-Fi Smart Plugs",
|
||||
"integration_type": "device",
|
||||
|
||||
Generated
-4
@@ -941,10 +941,6 @@ evolutionhttp==0.0.18
|
||||
# homeassistant.components.faa_delays
|
||||
faadelays==2023.9.1
|
||||
|
||||
# homeassistant.components.dlib_face_detect
|
||||
# homeassistant.components.dlib_face_identify
|
||||
# face-recognition==1.2.3
|
||||
|
||||
# homeassistant.components.fastdotcom
|
||||
fastdotcom==0.0.6
|
||||
|
||||
|
||||
Generated
-4
@@ -820,10 +820,6 @@ evolutionhttp==0.0.18
|
||||
# homeassistant.components.faa_delays
|
||||
faadelays==2023.9.1
|
||||
|
||||
# homeassistant.components.dlib_face_detect
|
||||
# homeassistant.components.dlib_face_identify
|
||||
# face-recognition==1.2.3
|
||||
|
||||
# homeassistant.components.fastdotcom
|
||||
fastdotcom==0.0.6
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ EXCLUDED_REQUIREMENTS_ALL = {
|
||||
"bluepy",
|
||||
"decora",
|
||||
"evdev",
|
||||
"face-recognition",
|
||||
"pybluez",
|
||||
"pycups",
|
||||
"python-lirc",
|
||||
|
||||
@@ -288,8 +288,6 @@ INTEGRATIONS_WITHOUT_QUALITY_SCALE_FILE = [
|
||||
"directv",
|
||||
"discogs",
|
||||
"discord",
|
||||
"dlib_face_detect",
|
||||
"dlib_face_identify",
|
||||
"dlink",
|
||||
"dlna_dmr",
|
||||
"dlna_dms",
|
||||
@@ -1305,8 +1303,6 @@ INTEGRATIONS_WITHOUT_SCALE = [
|
||||
"directv",
|
||||
"discogs",
|
||||
"discord",
|
||||
"dlib_face_detect",
|
||||
"dlib_face_identify",
|
||||
"dlink",
|
||||
"dlna_dmr",
|
||||
"dlna_dms",
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
"""The dlib_face_detect component."""
|
||||
@@ -1,37 +0,0 @@
|
||||
"""Dlib Face Identity Image Processing Tests."""
|
||||
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from homeassistant.components.dlib_face_detect import DOMAIN
|
||||
from homeassistant.components.image_processing import DOMAIN as IMAGE_PROCESSING_DOMAIN
|
||||
from homeassistant.const import CONF_ENTITY_ID, CONF_PLATFORM, CONF_SOURCE
|
||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
@patch.dict("sys.modules", face_recognition=Mock())
|
||||
async def test_repair_issue_is_created(
|
||||
hass: HomeAssistant,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test repair issue is created."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
IMAGE_PROCESSING_DOMAIN,
|
||||
{
|
||||
IMAGE_PROCESSING_DOMAIN: [
|
||||
{
|
||||
CONF_PLATFORM: DOMAIN,
|
||||
CONF_SOURCE: [
|
||||
{CONF_ENTITY_ID: "camera.test_camera"},
|
||||
],
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
HOMEASSISTANT_DOMAIN,
|
||||
f"deprecated_system_packages_yaml_integration_{DOMAIN}",
|
||||
) in issue_registry.issues
|
||||
@@ -1 +0,0 @@
|
||||
"""The dlib_face_identify component."""
|
||||
@@ -1,38 +0,0 @@
|
||||
"""Dlib Face Identity Image Processing Tests."""
|
||||
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from homeassistant.components.dlib_face_identify import CONF_FACES, DOMAIN
|
||||
from homeassistant.components.image_processing import DOMAIN as IMAGE_PROCESSING_DOMAIN
|
||||
from homeassistant.const import CONF_ENTITY_ID, CONF_PLATFORM, CONF_SOURCE
|
||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
@patch.dict("sys.modules", face_recognition=Mock())
|
||||
async def test_repair_issue_is_created(
|
||||
hass: HomeAssistant,
|
||||
issue_registry: ir.IssueRegistry,
|
||||
) -> None:
|
||||
"""Test repair issue is created."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
IMAGE_PROCESSING_DOMAIN,
|
||||
{
|
||||
IMAGE_PROCESSING_DOMAIN: [
|
||||
{
|
||||
CONF_PLATFORM: DOMAIN,
|
||||
CONF_SOURCE: [
|
||||
{CONF_ENTITY_ID: "camera.test_camera"},
|
||||
],
|
||||
CONF_FACES: {"person1": __file__},
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
HOMEASSISTANT_DOMAIN,
|
||||
f"deprecated_system_packages_yaml_integration_{DOMAIN}",
|
||||
) in issue_registry.issues
|
||||
Reference in New Issue
Block a user