swarecito's picture
Commented out unused imports and removed unnecessary code
ec3461c
raw
history blame contribute delete
919 Bytes
# import gradio as gr
from fastai.vision.all import *
import os
categories = ("Cristiano Ronaldo", "Lionel Messi")
#model = load_learner('model.pkl')
def classify_image(img):
pred, idx, probs = model.predict(img)
return dict(zip(categories, map(float, probs)))
# image = gr.Image(shape=(192, 192))
# label = gr.outputs.Label()
examples = ['cristiano.jpg', 'messi.jpg', './images/cristiano.jpg', './images/messi.jpg']
# A function to display photos from the root images folder
# def get_image(path):
# with open(path, 'rb') as f:
# return f.read()
# def get_image_path(path):
# return path
# print(get_image("images/cristiano.jpg"))
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
image = mpimg.imread('images/cristiano.jpg')
plt.imshow(image)
plt.show()
intf = gr.Interface(
classify_image, gr.Image(type="pil"),
"image",
)
intf.launch(inline=False)