MCPcopy
hub / github.com/serengil/deepface / search

Function search

deepface/api/src/modules/core/service.py:143–187  ·  view source on GitHub ↗
(
    img: Union[str, NDArray[Any]],
    model_name: str,
    detector_backend: str,
    distance_metric: str,
    enforce_detection: bool,
    align: bool,
    l2_normalize: bool,
    expand_percentage: int,
    normalization: str,
    anti_spoofing: bool,
    similarity_search: bool,
    k: Optional[int],
    database_type: str,
    connection_details: str,
    search_method: str,
)

Source from the content-addressed store, hash-verified

141
142
143def search(
144 img: Union[str, NDArray[Any]],
145 model_name: str,
146 detector_backend: str,
147 distance_metric: str,
148 enforce_detection: bool,
149 align: bool,
150 l2_normalize: bool,
151 expand_percentage: int,
152 normalization: str,
153 anti_spoofing: bool,
154 similarity_search: bool,
155 k: Optional[int],
156 database_type: str,
157 connection_details: str,
158 search_method: str,
159) -> Tuple[Dict[str, Any], int]:
160 try:
161 result = {}
162 dfs = DeepFace.search(
163 img=img,
164 model_name=model_name,
165 detector_backend=detector_backend,
166 distance_metric=distance_metric,
167 enforce_detection=enforce_detection,
168 align=align,
169 l2_normalize=l2_normalize,
170 expand_percentage=expand_percentage,
171 normalization=normalization,
172 anti_spoofing=anti_spoofing,
173 similarity_search=similarity_search,
174 k=k,
175 database_type=database_type,
176 connection_details=connection_details,
177 search_method=search_method,
178 )
179
180 result["results"] = [df.to_dict(orient="records") for df in dfs]
181 return result, 200
182
183 except Exception as err:
184 tb_str = traceback.format_exc()
185 logger.error(str(err))
186 logger.error(tb_str)
187 return {"error": f"Exception while searching: {str(err)} - {tb_str}"}, 400
188
189
190def build_index(

Callers

nothing calls this directly

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected