Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- Dockerfile +29 -0
- face_recognition_model.py +31 -0
- requirements.txt +19 -0
Dockerfile
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-bookworm
|
| 2 |
+
|
| 3 |
+
COPY requirements.txt requirements.txt
|
| 4 |
+
|
| 5 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
+
bzip2 \
|
| 7 |
+
g++ \
|
| 8 |
+
git \
|
| 9 |
+
graphviz \
|
| 10 |
+
libgl1-mesa-glx \
|
| 11 |
+
libhdf5-dev \
|
| 12 |
+
openmpi-bin \
|
| 13 |
+
wget \
|
| 14 |
+
python3-tk && \
|
| 15 |
+
rm -rf /var/lib/apt/lists/*
|
| 16 |
+
|
| 17 |
+
RUN pip install --upgrade pip
|
| 18 |
+
|
| 19 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
+
|
| 21 |
+
RUN useradd -m -u 1000 myuser
|
| 22 |
+
|
| 23 |
+
USER myuser
|
| 24 |
+
|
| 25 |
+
COPY --chown=myuser app app
|
| 26 |
+
|
| 27 |
+
EXPOSE 8001
|
| 28 |
+
|
| 29 |
+
CMD ["python", "app/main.py"]
|
face_recognition_model.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
import torch
|
| 3 |
+
import torchvision
|
| 4 |
+
import torch.nn as nn
|
| 5 |
+
import torch.nn.functional as F
|
| 6 |
+
from torchvision import transforms
|
| 7 |
+
# Add more imports if required
|
| 8 |
+
|
| 9 |
+
# Sample Transformation function
|
| 10 |
+
# YOUR CODE HERE for changing the Transformation values.
|
| 11 |
+
trnscm = transforms.Compose([transforms.Resize((100,100)), transforms.ToTensor()])
|
| 12 |
+
|
| 13 |
+
##Example Network
|
| 14 |
+
class Siamese(torch.nn.Module):
|
| 15 |
+
def __init__(self):
|
| 16 |
+
super(Siamese, self).__init__()
|
| 17 |
+
#YOUR CODE HERE
|
| 18 |
+
|
| 19 |
+
def forward(self, x):
|
| 20 |
+
pass # remove 'pass' once you have written your code
|
| 21 |
+
#YOUR CODE HERE
|
| 22 |
+
|
| 23 |
+
##########################################################################################################
|
| 24 |
+
## Sample classification network (Specify if you are using a pytorch classifier during the training) ##
|
| 25 |
+
## classifier = nn.Sequential(nn.Linear(64, 64), nn.BatchNorm1d(64), nn.ReLU(), nn.Linear...) ##
|
| 26 |
+
##########################################################################################################
|
| 27 |
+
|
| 28 |
+
# YOUR CODE HERE for pytorch classifier
|
| 29 |
+
|
| 30 |
+
# Definition of classes as dictionary
|
| 31 |
+
classes = ['person1','person2','person3','person4','person5','person6','person7']
|
requirements.txt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
uvicorn==0.17.6
|
| 2 |
+
fastapi==0.99.1
|
| 3 |
+
pydantic==1.10.10
|
| 4 |
+
requests==2.23.0
|
| 5 |
+
jinja2==3.1.2
|
| 6 |
+
python-multipart==0.0.6
|
| 7 |
+
|
| 8 |
+
scikit-learn==1.2.2
|
| 9 |
+
joblib==1.3.2
|
| 10 |
+
Pillow==9.4.0
|
| 11 |
+
torch==2.1.0
|
| 12 |
+
torchvision==0.16.0
|
| 13 |
+
matplotlib==3.7.1
|
| 14 |
+
|
| 15 |
+
#opencv-python==4.5.5.64
|
| 16 |
+
numpy==1.26.4
|
| 17 |
+
pandas==2.2.2
|
| 18 |
+
# Prefer headless on servers (no GUI deps); 4.9 works well with numpy 1.26.x
|
| 19 |
+
opencv-python-headless==4.9.0.80
|