Spaces:
Sleeping
Sleeping
Qile
commited on
Commit
•
6054cbb
1
Parent(s):
bb25891
interface now working after changing fastai ver
Browse filesSigned-off-by: Qile <43093685+GTHB317@users.noreply.github.com>
- app.py +55 -4
- requirements.txt +4 -0
app.py
CHANGED
@@ -1,7 +1,58 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
from fastai import *
|
4 |
+
#import pathlib
|
5 |
|
6 |
+
#temp = pathlib.PosixPath
|
7 |
+
#pathlib.PosixPath = pathlib.WindowsPath
|
8 |
|
9 |
+
learn = load_learner('Bacteria-Classifier.pkl')
|
10 |
+
|
11 |
+
categories = ('Acinetobacter.baumanii',
|
12 |
+
'Actinetobacter.israeli',
|
13 |
+
'Bacteroides.fragilis',
|
14 |
+
'Bifidobacterium.spp',
|
15 |
+
'Candida.albicans',
|
16 |
+
'Clostridium.perfringens',
|
17 |
+
'Enterococcus.faecalis',
|
18 |
+
'Enterococcus.faecium',
|
19 |
+
'Escherichia.coli',
|
20 |
+
'Fusobacterium',
|
21 |
+
'Lactobacillus.casei',
|
22 |
+
'Lactobacillus.crispatus',
|
23 |
+
'Lactobacillus.delbrueckii',
|
24 |
+
'Lactobacillus.gasseri',
|
25 |
+
'Lactobacillus.jehnsenii',
|
26 |
+
'Lactobacillus.johnsonii',
|
27 |
+
'Lactobacillus.paracasei',
|
28 |
+
'Lactobacillus.plantarum',
|
29 |
+
'Lactobacillus.reuteri',
|
30 |
+
'Lactobacillus.rhamnosus',
|
31 |
+
'Lactobacillus.salivarius',
|
32 |
+
'Listeria.monocytogenes',
|
33 |
+
'Micrococcus.spp',
|
34 |
+
'Neisseria.gonorrhoeae',
|
35 |
+
'Porfyromonas.gingivalis',
|
36 |
+
'Propionibacterium.acnes',
|
37 |
+
'Proteus',
|
38 |
+
'Pseudomonas.aeruginosa',
|
39 |
+
'Staphylococcus.aureus',
|
40 |
+
'Staphylococcus.epidermidis',
|
41 |
+
'Staphylococcus.saprophiticus',
|
42 |
+
'Streptococcus.agalactiae',
|
43 |
+
'Veionella')
|
44 |
+
|
45 |
+
def classify_image(img):
|
46 |
+
pred,idx,probs = learn.predict(img)
|
47 |
+
return dict(zip(categories,map(float,probs)))
|
48 |
+
|
49 |
+
image = gr.Image(shape=(244,244))
|
50 |
+
label = gr.Label()
|
51 |
+
examples = ['Fusobacterium_sample.png','Veionella_sample.png','Clostridium.perfringens_sample.png']
|
52 |
+
|
53 |
+
demo = gr.Interface(
|
54 |
+
fn=classify_image,
|
55 |
+
inputs=image,
|
56 |
+
outputs=label,
|
57 |
+
examples=examples)
|
58 |
+
demo.launch(inline=False)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#-f https://download.pytorch.org/whl/cpu/torch_stable.html
|
2 |
+
dvc==2.9.5
|
3 |
+
torch==1.11
|
4 |
+
fastai==2.7.7
|