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