Spaces:
Runtime error
Runtime error
Jesse Alter
commited on
Commit
·
daf599a
1
Parent(s):
edc45f3
initial commit
Browse files- app.py +37 -0
- os_model.pkl +3 -0
- requirements.txt +1 -0
- win95.jpg +0 -0
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: os_identify.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['btn_upload', 'btn_run', 'path', 'learn_inf', 'out_pl', 'lbl_pred', 'on_click_classify']
|
5 |
+
|
6 |
+
# %% os_identify.ipynb 4
|
7 |
+
from fastai.vision.all import *
|
8 |
+
from fastai.vision.widgets import *
|
9 |
+
import gradio as gr
|
10 |
+
|
11 |
+
# %% os_identify.ipynb 5
|
12 |
+
def on_click_classify(change):
|
13 |
+
img = PILImage.create(btn_upload.data[-1])
|
14 |
+
out_pl.clear_output()
|
15 |
+
with out_pl: display(img.to_thumb(128,128))
|
16 |
+
pred,pred_idx,probs = learn_inf.predict(btn_upload.data[-1])
|
17 |
+
lbl_pred.value = f'Prediction: {pred}; Probability: {probs[pred_idx]:.04f}'
|
18 |
+
|
19 |
+
# %% os_identify.ipynb 6
|
20 |
+
btn_upload = widgets.FileUpload()
|
21 |
+
btn_run = widgets.Button(description='Classify')
|
22 |
+
btn_run.on_click(on_click_classify)
|
23 |
+
|
24 |
+
# %% os_identify.ipynb 7
|
25 |
+
# load the model
|
26 |
+
path = Path()
|
27 |
+
learn_inf = load_learner(path/'os_model.pkl')
|
28 |
+
|
29 |
+
# %% os_identify.ipynb 8
|
30 |
+
out_pl = widgets.Output()
|
31 |
+
out_pl.clear_output()
|
32 |
+
lbl_pred = widgets.Label()
|
33 |
+
|
34 |
+
|
35 |
+
# %% os_identify.ipynb 9
|
36 |
+
VBox([widgets.Label('Select your screencap!'),
|
37 |
+
btn_upload, btn_run, out_pl, lbl_pred])
|
os_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:11ec903a63620db0c2e0024e81eeef0cb50fe2cf8cc3fcb31fa8263b987a8d8d
|
3 |
+
size 47074145
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai
|
win95.jpg
ADDED