|
|
|
|
|
import numpy as np |
|
import pandas as pd |
|
import os |
|
import fastbook |
|
fastbook.setup_book() |
|
|
|
from fastbook import * |
|
|
|
learner = load_learner('jianyang.pkl') |
|
|
|
categories = ('Not a Hotdog', 'Hotdog') |
|
|
|
def is_hotdog(img): |
|
|
|
prediction, prediction_index, probabilities = learner.predict(img) |
|
dictionary = dict(zip(categories, map(float, probabilities))) |
|
|
|
if dictionary['Hotdog'] < 0.3: |
|
dictionary['Not a Hotdog'] = 1 |
|
dictionary['Hotdog'] = 0 |
|
|
|
return dictionary |
|
|
|
import gradio as gr |
|
|
|
image = gr.inputs.Image(shape = (192, 192)) |
|
label = gr.outputs.Label() |
|
examples = ['pizza.jpg', 'hotdog.jpg'] |
|
intf = gr.Interface(fn=is_hotdog, inputs=image, outputs=label, examples=examples) |
|
intf.launch(inline=False) |