TheOneReborn's picture
fix: open file not directory
9ab897d
raw
history blame
592 Bytes
import gradio
import numpy
from pathlib import Path
from fastai.vision.all import load_learner, PILImage
MODEL_PATH = Path('.') / 'models'
TEST_IMAGES_PATH = Path('.') / 'test'
LEARNER = load_learner(MODEL_PATH / 'car-segmentation_v1.pkl')
def segment_image(image):
image = PILImage.create(image)
prediction, _, _ = LEARNER.predict(image)
return numpy.array(prediction)
demo = gradio.Interface(
segment_image,
inputs=gradio.Image(type='pil'),
outputs=gradio.Image(type='numpy'),
examples=[str(image) for image in TEST_IMAGES_PATH.iterdir()]
)
demo.launch()