Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,10 @@
|
|
| 1 |
import tensorflow as tf
|
| 2 |
-
from tensorflow.keras.layers import Layer
|
| 3 |
from tensorflow.keras.models import load_model
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
# Define the
|
| 6 |
-
|
| 7 |
-
def __init__(self, **kwargs):
|
| 8 |
-
super().__init__(**kwargs)
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
an_distance = tf.reduce_sum(tf.square(anchor - negative), -1)
|
| 13 |
-
return (ap_distance, an_distance)
|
| 14 |
-
|
| 15 |
-
# Load the model with the custom layer
|
| 16 |
-
siamese_network = load_model('siamese_network.h5', custom_objects={'DistanceLayer': DistanceLayer})
|
| 17 |
-
|
| 18 |
-
# Now, you can use siamese_network for predictions, evaluation, etc.
|
| 19 |
-
siamese_network.summary()
|
|
|
|
| 1 |
import tensorflow as tf
|
|
|
|
| 2 |
from tensorflow.keras.models import load_model
|
| 3 |
+
import numpy as np
|
| 4 |
+
from PIL import Image
|
| 5 |
|
| 6 |
+
# Define the target shape as previously used
|
| 7 |
+
target_shape = (160, 160)
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
# Load the FaceNet model with custom weights
|
| 10 |
+
facenet_model = load_model('facenet_keras.h5', compile=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|