Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- Inception_V3.h5 +3 -0
- app.py +4 -25
- requirements.txt +1 -1
Inception_V3.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6470641316e4c8bdd606e155460d443db7330cae05626623183145fd3f28f319
|
3 |
+
size 98695104
|
app.py
CHANGED
@@ -1,32 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
import tensorflow as tf
|
3 |
-
from tensorflow.keras.applications.
|
4 |
from tensorflow.keras.preprocessing import image
|
5 |
import numpy as np
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
def __init__(self, scale=1.0, **kwargs):
|
10 |
-
super(CustomScaleLayer, self).__init__(**kwargs)
|
11 |
-
self.scale = tf.Variable(initial_value=scale, trainable=True)
|
12 |
-
|
13 |
-
def call(self, inputs):
|
14 |
-
return inputs * self.scale
|
15 |
-
|
16 |
-
def get_config(self):
|
17 |
-
config = super(CustomScaleLayer, self).get_config()
|
18 |
-
config.update({'scale': self.scale.numpy()})
|
19 |
-
return config
|
20 |
-
|
21 |
-
@classmethod
|
22 |
-
def from_config(cls, config):
|
23 |
-
return cls(**config)
|
24 |
-
|
25 |
-
# ลงทะเบียนเลเยอร์แบบกำหนดเอง
|
26 |
-
tf.keras.utils.get_custom_objects().update({'CustomScaleLayer': CustomScaleLayer})
|
27 |
-
|
28 |
-
# โหลดโมเดล
|
29 |
-
model = tf.keras.models.load_model("inceptionv3_model_with_custom_layer.h5")
|
30 |
|
31 |
# ฟังก์ชันสำหรับการพยากรณ์
|
32 |
def predict(img):
|
@@ -47,7 +26,7 @@ interface = gr.Interface(
|
|
47 |
fn=predict,
|
48 |
inputs=gr.Image(type="pil", label="Upload an Image"),
|
49 |
outputs=gr.Label(num_top_classes=2, label="Predicted Class"),
|
50 |
-
title="Image Classification with
|
51 |
description="Upload an image to classify it into one of the classes."
|
52 |
)
|
53 |
|
|
|
1 |
import gradio as gr
|
2 |
import tensorflow as tf
|
3 |
+
from tensorflow.keras.applications.inception_v3 import preprocess_input # ใช้ฟังก์ชันที่เหมาะสมกับ InceptionV3
|
4 |
from tensorflow.keras.preprocessing import image
|
5 |
import numpy as np
|
6 |
|
7 |
+
# โหลดโมเดล InceptionV3
|
8 |
+
model = tf.keras.models.load_model("Inception_V3.h5")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# ฟังก์ชันสำหรับการพยากรณ์
|
11 |
def predict(img):
|
|
|
26 |
fn=predict,
|
27 |
inputs=gr.Image(type="pil", label="Upload an Image"),
|
28 |
outputs=gr.Label(num_top_classes=2, label="Predicted Class"),
|
29 |
+
title="Image Classification with InceptionV3",
|
30 |
description="Upload an image to classify it into one of the classes."
|
31 |
)
|
32 |
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
tensorflow==2.
|
2 |
numpy==1.21.6
|
3 |
Pillow==9.2.0
|
4 |
gradio==3.0.7
|
|
|
1 |
+
tensorflow==2.10
|
2 |
numpy==1.21.6
|
3 |
Pillow==9.2.0
|
4 |
gradio==3.0.7
|