Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from keras.applications.vgg16 import VGG16
|
3 |
+
from keras.preprocessing import image
|
4 |
+
from keras.applications.vgg16 import preprocess_input
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
def predict_image(img):
|
8 |
+
img_4d = img.reshape(-1,224,224,3)
|
9 |
+
prediction = model.predict(img_4d)[0]
|
10 |
+
return {class_names[i]: float(prediction[i]) for i in range(5)}
|
11 |
+
|
12 |
+
model = VGG16()
|
13 |
+
model.summary()
|
14 |
+
image = gr.inputs.Image(shape=(224,224))
|
15 |
+
label = gr.outputs.Label(num_top_classes=5)
|
16 |
+
|
17 |
+
gr.Interface(fn=predict_image,
|
18 |
+
title="VGG16 Classification",
|
19 |
+
description="VGG16 CNN",
|
20 |
+
inputs = image,
|
21 |
+
outputs = label,
|
22 |
+
live=True,
|
23 |
+
interpretation='default',
|
24 |
+
allow_flagging="never").launch()
|