import gradio as gr from fastai.vision.all import * import skimage learn = load_learner('export-castles.pkl') 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))} title = "Japanese Castle (Tenshu) Classifier" description = '''A castle classifier trained on a small set of Japanese Castles with fastai. Demo for Gradio and HuggingFace Spaces. Based on blog and demo from Tanisq Abraham. Example images below are from jcastle.info.''' # link article='''
There are many hundreds of castle sites scattered across Japan, for this demo we have trained on just 9 Tenshu.
Images sourced from my own collection and Bing Image Search.
Learn more about Japanese Castles and their history at
Jcastle - Guide to Japanese Castles.