Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +1 -15
- inceptionv3_model_with_custom_layer.h5 +3 -0
app.py
CHANGED
@@ -4,21 +4,7 @@ from tensorflow.keras.applications.inception_resnet_v2 import preprocess_input
|
|
4 |
from tensorflow.keras.preprocessing import image
|
5 |
import numpy as np
|
6 |
|
7 |
-
|
8 |
-
class CustomScaleLayer(tf.keras.layers.Layer):
|
9 |
-
def __init__(self, scale=1.0, **kwargs):
|
10 |
-
super(CustomScaleLayer, self).__init__(**kwargs)
|
11 |
-
self.scale = scale
|
12 |
-
|
13 |
-
def call(self, inputs, *args, **kwargs):
|
14 |
-
if isinstance(inputs, list):
|
15 |
-
return [input_tensor * self.scale for input_tensor in inputs]
|
16 |
-
else:
|
17 |
-
return inputs * self.scale
|
18 |
-
|
19 |
-
# ใช้ custom_object_scope เพื่อทำให้เลเยอร์ที่กำหนดเองสามารถใช้งานได้
|
20 |
-
with tf.keras.utils.custom_object_scope({'CustomScaleLayer': CustomScaleLayer}):
|
21 |
-
model = tf.keras.models.load_model("jo33_model_v222.h5")
|
22 |
|
23 |
# Function for prediction
|
24 |
def predict(img):
|
|
|
4 |
from tensorflow.keras.preprocessing import image
|
5 |
import numpy as np
|
6 |
|
7 |
+
model = tf.keras.models.load_model("inceptionv3_model_with_custom_layer.h5")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Function for prediction
|
10 |
def predict(img):
|
inceptionv3_model_with_custom_layer.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:55130ca25bee2dfd11cab398cebb171e6f17aeee4ddad600b8437a47a4febca0
|
3 |
+
size 287728912
|