File size: 919 Bytes
ec3461c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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)