tasmay commited on
Commit
e00b9d5
1 Parent(s): bbb44f6

modified model

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -6,13 +6,22 @@ import pickle
6
  st.title("Piano or Keyboard?")
7
  file_name = st.file_uploader("Upload a piano or a keyboard image")
8
 
9
- model = pickle.load(open('export.pkl','rb'))
 
 
 
 
 
 
 
 
10
 
11
  if file_name is not None:
12
  col1, col2 = st.columns(2)
13
  image = Image.open(file_name)
14
  col1.image(image, use_column_width=True)
15
- pred,pred_idx,probs = model.predict(PILImage.create(file_name))
 
16
  col2.header("Prediction:")
17
  st.write('This is a ', pred, '!')
18
  else:
 
6
  st.title("Piano or Keyboard?")
7
  file_name = st.file_uploader("Upload a piano or a keyboard image")
8
 
9
+ # model = pickle.load(open('export.pkl','rb'))
10
+
11
+ model = load_learner('export.pkl')
12
+
13
+ labels = model.dls.vocab
14
+ def predict(img):
15
+ img = PILImage.create(img)
16
+ pred,pred_idx,probs = model.predict(img)
17
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
18
 
19
  if file_name is not None:
20
  col1, col2 = st.columns(2)
21
  image = Image.open(file_name)
22
  col1.image(image, use_column_width=True)
23
+ # pred,pred_idx,probs = model.predict(PILImage.create(file_name))
24
+ pred = predict(file_name)
25
  col2.header("Prediction:")
26
  st.write('This is a ', pred, '!')
27
  else: