Toptopito commited on
Commit
fc16651
·
1 Parent(s): 1678137

still the damn paths!

Browse files
Files changed (2) hide show
  1. app.py +9 -6
  2. requirements.txt +2 -1
app.py CHANGED
@@ -2,11 +2,14 @@ import gradio as gr
2
 
3
  from fastai.vision.all import *
4
 
5
- cur_path = Path('.')
 
 
 
6
 
7
 
8
  # load model
9
- learn = load_learner('model.pkl')
10
 
11
  categories = ('CLEAR', 'PNEUMONIA')
12
 
@@ -14,10 +17,10 @@ def classify_image(img):
14
  pred, idx, probs = learn.predict(img)
15
  return dict(zip(categories, map(float, probs)))
16
 
17
- examples = ['unseen_data/NORMAL/NORMAL2-IM-1427-0001.jpeg',
18
- 'unseen_data/PNEUMONIA/person1946_bacteria_4874.jpeg',
19
- 'unseen_data/NORMAL/NORMAL2-IM-1430-0001.jpeg',
20
- 'unseen_data/PNEUMONIA/person1946_bacteria_4875.jpeg']
21
 
22
  intf = gr.Interface(fn=classify_image, inputs=gr.Image(type='pil'), outputs=gr.Label(), examples=examples)
23
 
 
2
 
3
  from fastai.vision.all import *
4
 
5
+ #fix path issues
6
+ import pathlib
7
+ temp = pathlib.PosixPath
8
+ pathlib.PosixPath = pathlib.WindowsPath
9
 
10
 
11
  # load model
12
+ learn = load_learner('./model.pkl')
13
 
14
  categories = ('CLEAR', 'PNEUMONIA')
15
 
 
17
  pred, idx, probs = learn.predict(img)
18
  return dict(zip(categories, map(float, probs)))
19
 
20
+ examples = ['./unseen_data/NORMAL/NORMAL2-IM-1427-0001.jpeg',
21
+ './unseen_data/PNEUMONIA/person1946_bacteria_4874.jpeg',
22
+ './unseen_data/NORMAL/NORMAL2-IM-1430-0001.jpeg',
23
+ './unseen_data/PNEUMONIA/person1946_bacteria_4875.jpeg']
24
 
25
  intf = gr.Interface(fn=classify_image, inputs=gr.Image(type='pil'), outputs=gr.Label(), examples=examples)
26
 
requirements.txt CHANGED
@@ -2,4 +2,5 @@ fastai
2
  torch
3
  gradio
4
  numpy
5
- pandas <2.0.0
 
 
2
  torch
3
  gradio
4
  numpy
5
+ pandas <2.0.0
6
+ pathlib