hasnanmr commited on
Commit
ea79e5c
·
1 Parent(s): 1650481

update model state

Browse files
Files changed (2) hide show
  1. .gitattributes +1 -0
  2. app.py +3 -3
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ faceViT4.pth filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -24,7 +24,7 @@ model_name = "google/vit-base-patch16-224"
24
  processor = ViTImageProcessor.from_pretrained(model_name)
25
  base_model = ViTModel.from_pretrained("WinKawaks/vit-small-patch16-224")
26
  model = ViT(base_model)
27
- model.load_state_dict(torch.load('faceViT6.pth'))
28
 
29
  # Set the model to evaluation mode
30
  model.eval()
@@ -34,7 +34,7 @@ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
34
  model.to(device)
35
 
36
  # Initialize MTCNN for face detection
37
- mtcnn = MTCNN(keep_all=True, min_face_size=20, thresholds=[0.6, 0.7, 0.7], device=device)
38
 
39
  # Define the transformation
40
  transform = transforms.Compose([
@@ -43,7 +43,7 @@ transform = transforms.Compose([
43
  ])
44
 
45
  def cosine_similarity(embedding1, embedding2):
46
- similarity = torch.nn.functional.cosine_similarity(embedding1.flatten().unsqueeze(0), embedding2.flatten().unsqueeze(0))
47
  return similarity.item()
48
 
49
  def align_face(frame):
 
24
  processor = ViTImageProcessor.from_pretrained(model_name)
25
  base_model = ViTModel.from_pretrained("WinKawaks/vit-small-patch16-224")
26
  model = ViT(base_model)
27
+ model.load_state_dict(torch.load('faceViT4.pth'))
28
 
29
  # Set the model to evaluation mode
30
  model.eval()
 
34
  model.to(device)
35
 
36
  # Initialize MTCNN for face detection
37
+ mtcnn = MTCNN(keep_all=True, device=device)
38
 
39
  # Define the transformation
40
  transform = transforms.Compose([
 
43
  ])
44
 
45
  def cosine_similarity(embedding1, embedding2):
46
+ similarity = torch.nn.functional.cosine_similarity(embedding1.unsqueeze(0), embedding2.unsqueeze(0))
47
  return similarity.item()
48
 
49
  def align_face(frame):