|
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() |