Spaces:
Sleeping
Sleeping
File size: 616 Bytes
b734e06 c9c7e8a b734e06 c9c7e8a b734e06 3e156b5 b734e06 5a38a19 b734e06 c9c7e8a |
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 |
import gradio
from pathlib import Path
from fastai.vision.all import (
load_learner
)
import gradio.interface
CATEGORIES = ('Damaged', 'Whole')
MODEL_PATH = Path('.') / 'models'
TEST_IMAGES_PATH = Path('.') / 'test'
LEARNER = load_learner(MODEL_PATH / 'car-damage-detection_v2.pkl')
def categorize_image(image):
prediction, index, probabilities = LEARNER.predict(image)
return dict(zip(CATEGORIES, map(float, probabilities)))
demo = gradio.Interface(
categorize_image,
inputs='image',
outputs='label',
examples=[str(image) for image in TEST_IMAGES_PATH.iterdir()]
)
demo.launch()
|