generated from aniketmaurya/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ef62d5
commit 6ae1559
Showing
4 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from fastserve.models.face_reco import FaceDetection as FaceDetection | ||
from fastserve.models.llama_cpp import ServeLlamaCpp as ServeLlamaCpp | ||
from fastserve.models.sdxl_turbo import ServeSDXLTurbo as ServeSDXLTurbo | ||
from fastserve.models.ssd import ServeSSD1B as ServeSSD1B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import logging | ||
from typing import List | ||
|
||
from fastapi import UploadFile | ||
|
||
from fastserve import FastServe | ||
|
||
logging.getLogger(__name__) | ||
|
||
try: | ||
import face_recognition | ||
except ModuleNotFoundError: | ||
face_recognition = None | ||
|
||
|
||
class FaceDetection(FastServe): | ||
def __init__(self, batch_size=1, timeout=0): | ||
super().__init__( | ||
batch_size=batch_size, timeout=timeout, input_schema=UploadFile | ||
) | ||
if not face_recognition: | ||
raise ModuleNotFoundError( | ||
"face_recognition is not installed. " | ||
"Please run 'pip install face-recognition' first." | ||
) | ||
|
||
def handle(self, batch: List[UploadFile]) -> List[List[float]]: | ||
results = [] | ||
for file in batch: | ||
image = face_recognition.load_image_file(file.file) | ||
face_locations = face_recognition.face_locations(image) | ||
results.append(face_locations) | ||
return results |