sagivp commited on
Commit
5ee729f
·
1 Parent(s): 47e970d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -1,7 +1,13 @@
1
  import gradio as gr
2
  from fastai.vision.all import *
3
 
4
- learn = load_learner('model.pkl', cpu=True)
 
 
 
 
 
 
5
 
6
  labels = learn.dls.vocab
7
  def predict(img):
 
1
  import gradio as gr
2
  from fastai.vision.all import *
3
 
4
+ class CPU_Unpickler(pickle.Unpickler):
5
+ def find_class(self, module, name):
6
+ if module == 'torch.storage' and name == '_load_from_bytes':
7
+ return lambda b: torch.load(io.BytesIO(b), map_location='cpu')
8
+ else: return super().find_class(module, name)
9
+
10
+ learn = CPU_Unpickler('model.pkl').load()
11
 
12
  labels = learn.dls.vocab
13
  def predict(img):