Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
import numpy as np
|
4 |
+
from PIL import Image
|
5 |
+
import tensorflow.keras as keras
|
6 |
+
from tensorflow.keras.models import load_model
|
7 |
+
|
8 |
+
model = load_model('Fusen_dataset.h5')
|
9 |
+
classnames = ['Normal', 'Kizu', 'Yogore']
|
10 |
+
|
11 |
+
def predict_image(img):
|
12 |
+
img_4d=img.reshape(-1,224, 224,3)
|
13 |
+
prediction=model.predict(img_4d)[0]
|
14 |
+
return {classnames[i]: float(prediction[i]) for i in range(3)}
|
15 |
+
|
16 |
+
image = gr.inputs.Image(shape=(224, 224))
|
17 |
+
label = gr.outputs.Label(num_top_classes=3)
|
18 |
+
|
19 |
+
gr.Interface(fn=predict_image, inputs=image, title="ふせん外観検査",
|
20 |
+
description="ふせんの写真を撮って「送信」ボタンを押して下さい!汚れや破れを検出します。",outputs=label,enable_queue=True,interpretation='default').launch()
|