# Human or Animal application in gradio.

import gradio as gr
from fastai.vision.all import *
import skimage

loaded_generic_model = load_learner('model_generic.pkl')
#loaded_special_model = load_learner('model_special.pkl')


def predict_human_or_animal(img):
    im = PILImage.create(img)
    generic_class, generic_class_id, generic_probs = loaded_generic_model.predict(img)
    #special_class, special_class_id, special_probs = loaded_special_model.predict(img)
    
    return {generic_class: float(generic_probs[generic_class_id])}
    
intf = gr.Interface(fn=predict_human_or_animal, inputs="image", outputs="label").launch(share=True)