File size: 747 Bytes
372c8a8
 
 
 
 
 
c12b10e
fc4e01b
 
372c8a8
 
 
21535de
 
 
 
 
 
372c8a8
 
 
 
 
 
 
 
 
 
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
# AUTOGENERATED! DO NOT EDIT! File to edit: ../canals_classification.ipynb.

# %% auto 0
__all__ = ['learn', 'labels', 'demo', 'predict']

# %% ../canals_classification.ipynb 1

import gradio as gr
from fastai.vision.all import *
# %% ../canals_classification.ipynb 2
learn = load_learner("canals.pkl")

import fastbook
fastbook.setup_book()

from fastbook import * 
from fastai.vision.widgets import *

# %% ../canals_classification.ipynb 6
labels = learn.dls.vocab
def predict(img):
    img = PILImage.create(img)
    pred,pred_idx,probs = learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

# %% ../canals_classification.ipynb 8
demo = gr.Interface(fn=predict, inputs="image", outputs="label")
demo.launch()