Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +26 -0
- one_piece.pkl +3 -0
- requirements.txt +0 -0
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
|
| 4 |
+
# Loading the model we trained
|
| 5 |
+
learn = load_learner('one_piece.pkl')
|
| 6 |
+
|
| 7 |
+
# Prediction function
|
| 8 |
+
def predict_character(img):
|
| 9 |
+
pred_class, pred_idx, probs = learn.predict(img)
|
| 10 |
+
|
| 11 |
+
return {learn.dls.vocab[i]: float(probs[i])
|
| 12 |
+
for i in range(len(learn.dls.vocab))}
|
| 13 |
+
|
| 14 |
+
# Gradio app interface
|
| 15 |
+
demo = gr.Interface(
|
| 16 |
+
fn = predict_character,
|
| 17 |
+
inputs = gr.Image(type = 'pil', label = 'Upload Character Image'),
|
| 18 |
+
outputs = gr.Label(num_top_classes = 10, label = 'Predictions'),
|
| 19 |
+
title = 'One Piece Straw Hat Recognition',
|
| 20 |
+
description = 'Upload any straw hats members image except franky and jinbe',
|
| 21 |
+
examples = None,
|
| 22 |
+
theme = gr.themes.Soft()
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
# Launch our app
|
| 26 |
+
demo.launch()
|
one_piece.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f99afaf77f3905528fec7bec3f8989bcfe6823188f7cd934fedd4c7884204a3e
|
| 3 |
+
size 87495179
|
requirements.txt
ADDED
|
File without changes
|