emadahmed97 commited on
Commit
5ff50b3
·
1 Parent(s): bc236ae

fix app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -1,21 +1,21 @@
1
  from fastai.vision.all import *
2
- path = untar_data(URLs.PETS)
3
- def is_cat(x): return x[0].isupper()
 
 
 
4
  dls = ImageDataLoaders.from_name_func('.',
5
  get_image_files(path), valid_pct=0.2, seed=42,
6
  label_func=is_cat,
7
  item_tfms=Resize(192))
8
 
9
- dls.show_batch()
10
-
11
  learn = vision_learner(dls, resnet18, metrics=error_rate)
12
- learn.fine_tune(1)
13
- learn.path = Path('.')
14
- learn.export()
15
 
16
- learn=load_learner('export.pkl')
17
  labels = learn.dls.vocab
18
- print(labels)
19
  def predict(img):
20
  img = PILImage.create(img)
21
  pred,pred_idx,probs = learn.predict(img)
 
1
  from fastai.vision.all import *
2
+
3
+ def is_cat(x): return x[0].isupper()
4
+
5
+ path = untar_data(URLs.PETS)/'images'
6
+
7
  dls = ImageDataLoaders.from_name_func('.',
8
  get_image_files(path), valid_pct=0.2, seed=42,
9
  label_func=is_cat,
10
  item_tfms=Resize(192))
11
 
 
 
12
  learn = vision_learner(dls, resnet18, metrics=error_rate)
13
+ learn.fine_tune(3)
14
+
15
+ learn.export('model.pkl')
16
 
17
+ learn=load_learner('model.pkl')
18
  labels = learn.dls.vocab
 
19
  def predict(img):
20
  img = PILImage.create(img)
21
  pred,pred_idx,probs = learn.predict(img)