Spaces:
Runtime error
Runtime error
zeepheru
commited on
Commit
•
7940283
1
Parent(s):
9dde94e
asdfsdffvd
Browse files- app.py +39 -0
- export.pkl +3 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
|
5 |
+
training_set = "mane6-8000"
|
6 |
+
|
7 |
+
|
8 |
+
# this is here, because it needs to be, otherwise I have no friggin clue
|
9 |
+
def get_x(r): return os.path.join(training_set, r['fname'].replace('png', 'jpg').replace('gif', 'jpg').replace('svg', 'jpg')) # the replacing part is an interim solution lol (bug on a different end)
|
10 |
+
def get_y(r): return r['tag']
|
11 |
+
|
12 |
+
learn = load_learner('export.pkl') # pls rename
|
13 |
+
|
14 |
+
labels = learn.dls.vocab
|
15 |
+
def predict(img):
|
16 |
+
img = PILImage.create(img)
|
17 |
+
pred,pred_idx,probs = learn.predict(img)
|
18 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
19 |
+
|
20 |
+
title = "Ember"
|
21 |
+
description = ""
|
22 |
+
examples = ["examples/1.jpg", "examples/2.jpg", "examples/3.jpg", "examples/4.jpg"]
|
23 |
+
interpretation='default'
|
24 |
+
enable_queue=True
|
25 |
+
|
26 |
+
gr.Interface(
|
27 |
+
fn=predict,
|
28 |
+
inputs=gr.inputs.Image(shape=(400, 400)),
|
29 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
30 |
+
title=title,
|
31 |
+
description=description,
|
32 |
+
examples=examples,
|
33 |
+
interpretation=interpretation,
|
34 |
+
enable_queue=enable_queue).launch()
|
35 |
+
|
36 |
+
"""
|
37 |
+
LINKS
|
38 |
+
https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial
|
39 |
+
"""
|
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1e1445a693e8d0f1a0b277dc27d187c2839e3991c849c9d27512a9db3750ac30
|
3 |
+
size 87514917
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|