ImanAmran commited on
Commit
82b38f8
·
1 Parent(s): b588521

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -24
app.py CHANGED
@@ -11,27 +11,3 @@ def preprocess_image(filename, target_shape=(160, 160)):
11
 
12
  # Load the base FaceNet model
13
  facenet_model = load_model('facenet_keras.h5', compile=False)
14
-
15
- # Create the embedding model using the FaceNet model
16
- embedding = Model(inputs=facenet_model.input,
17
- outputs=facenet_model.layers[-2].output,
18
- name="Embedding")
19
-
20
- # Load the weights for your siamese or modified FaceNet model
21
- embedding.load_weights('base.h5')
22
-
23
- # Set all layers to non-trainable
24
- for layer in embedding.layers:
25
- layer.trainable = False
26
-
27
- # Function to generate embedding
28
- def generate_embedding(image_path, model):
29
- preprocessed_image = preprocess_image(image_path)
30
- preprocessed_image = tf.expand_dims(preprocessed_image, axis=0) # Add batch dimension
31
- embedding = model(preprocessed_image)
32
- return embedding
33
-
34
- # Example usage
35
- image_path = 'iman.jpg' # Update with your image's path
36
- image_embedding = generate_embedding(image_path, embedding)
37
- print("Generated Embedding:", image_embedding.numpy())
 
11
 
12
  # Load the base FaceNet model
13
  facenet_model = load_model('facenet_keras.h5', compile=False)