rafaared commited on
Commit
0c5e2cb
·
1 Parent(s): 4c20a43

Fix model path

Browse files
Files changed (3) hide show
  1. app.py +0 -2
  2. fixmodel.py +13 -0
  3. model.pkl +2 -2
app.py CHANGED
@@ -2,12 +2,10 @@ from fastai.vision.all import *
2
  import gradio as gr
3
  def is_cat(x): return x[0].isupper()
4
 
5
-
6
  learn = load_learner('model.pkl')
7
 
8
  categories = ('dog', 'cat')
9
 
10
-
11
  def classify_image(img):
12
  pred, idx, probs = learn.predict(img)
13
  return dict(zip(categories, map(float, probs)))
 
2
  import gradio as gr
3
  def is_cat(x): return x[0].isupper()
4
 
 
5
  learn = load_learner('model.pkl')
6
 
7
  categories = ('dog', 'cat')
8
 
 
9
  def classify_image(img):
10
  pred, idx, probs = learn.predict(img)
11
  return dict(zip(categories, map(float, probs)))
fixmodel.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ from pathlib import Path, WindowsPath
3
+ def is_cat(x): return x[0].isupper()
4
+
5
+ # Load the learner
6
+ learn = load_learner('model.pkl')
7
+
8
+ # Replace the WindowsPath object with the platform-independent Path object
9
+ if isinstance(learn.path, WindowsPath):
10
+ learn.path = Path(learn.path)
11
+
12
+ # Save the learner with the modified path object
13
+ learn.export('model_fixed.pkl')
model.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:8098758c87fcc7df34fa362c2f3181ae364c9de6fd14f95a1fd57dc82e30a3bf
3
- size 47058513
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:775c05ab2d799a7d053752efd8ce5030f0bcaf179565c92ac3d95b9adc01b847
3
+ size 47064927