Spaces:
Sleeping
Sleeping
File size: 1,488 Bytes
fda413d a78d459 fda413d 06786ae fda413d 3616865 16cbcd3 18ab206 0e76efe f51c30d 0367a0a 82f64fb e4f97e6 0f9740f 1d106a2 f4f218a fda413d a0d07e0 |
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 40 41 42 43 44 45 46 47 48 49 50 |
from fastai.vision.all import *
import gradio as gr
# import pathlib
# temp = pathlib.PosixPath
# pathlib.PosixPath = pathlib.WindowsPath
# Provide the full path to the model file
model_path = 'models/vehicle-recognizer-v2.pkl'
model = load_learner(model_path)
cap_labels = model.dls.vocab
def recognize_image(image):
pred, idx, probs = model.predict(image)
return dict(zip(cap_labels, map(float, probs)))
image_input = gr.inputs.Image(shape=(224,224))
label_output = gr.outputs.Label()
examples = [
'test_images/bus.jpg',
'test_images/car.jpg',
'test_images/helicopter.jpg',
'test_images/plane.jpg',
'test_images/Norton_Motorcycle.jpg',
'test_images/pexels-pixabay-163236.jpg',
'test_images/imgpr405.jpg',
'test_images/tractor-385681_1280.jpg',
'test_images/pexels-donald-tong-50911.jpg',
'test_images/360_F_99053872_JO23heKr9O5tmtgICEmEHKcp8N1Orog1.jpg',
'test_images/EMS_Kayaking.jpg',
'test_images/istockphoto-157186300-612x612.jpg',
'test_images/GUEST_93eeb16a-ea58-46bf-bb46-092947a4dc1a.jpg',
'test_images/istockphoto-104300620-612x612.jpg',
'test_images/Watsonville_74595-2104F-Large.jpg'
# 'test_images/skateboard.jpg',
# 'test_images/scooter.jpg',
# 'test_images/tractor.jpg',
# 'test_images/van.jpg',
# 'test_images/unicycle.jpeg'
]
iface = gr.Interface(fn=recognize_image, inputs=image_input, outputs=label_output, examples=examples)
iface.launch(inline =False, share = False)
|