Jamshaid89 commited on
Commit
f347761
1 Parent(s): 95ea752

v1 of save_identitiy

Browse files
Files changed (2) hide show
  1. app.py +16 -2
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,12 +1,26 @@
 
 
1
  import numpy as np
2
  from deepface import DeepFace
3
- import gradio as gr
 
 
4
 
 
 
 
 
5
 
6
  def save_identity(image , name):
7
  try:
8
  embeddings = DeepFace.represent(image , model_name="Facenet")
9
- return str(embeddings)
 
 
 
 
 
 
10
  except Exception as error:
11
  return str(error)
12
 
 
1
+ import gradio as gr
2
+
3
  import numpy as np
4
  from deepface import DeepFace
5
+ from pymongo.mongo_client import MongoClient
6
+
7
+ credentials = "jamshaid:jamshaid19gh"
8
 
9
+ uri = f"mongodb+srv://{credentials}@cluster0.uimyui3.mongodb.net/?retryWrites=true&w=majority"
10
+ client = MongoClient(uri)
11
+ db = client["Face_identification"]
12
+ identities_collection = db["face_identities"]
13
 
14
  def save_identity(image , name):
15
  try:
16
  embeddings = DeepFace.represent(image , model_name="Facenet")
17
+ embeddings = embeddings[0]
18
+
19
+ identity = {"embeddings":embeddings["embedding"] , "name" : name }
20
+
21
+ result = identities_collection.insert_one(identity)
22
+
23
+ return str(result)
24
  except Exception as error:
25
  return str(error)
26
 
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  numpy
2
- deepface
 
 
1
  numpy
2
+ deepface
3
+ pymongo