tasmay commited on
Commit
98195dd
·
1 Parent(s): e00b9d5

modified model

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -14,15 +14,16 @@ 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:
28
  st.write('Please upload a file!')
 
14
  def predict(img):
15
  img = PILImage.create(img)
16
  pred,pred_idx,probs = model.predict(img)
17
+ return dict(zip(labels, map(float, probs)))
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
+ predictions = predict(file_name)
 
24
  col2.header("Prediction:")
25
+ for p in predictions:
26
+ st.write(p)
27
+ #col2.subheader(f"{ p['label'] }: { round(p['probs'] * 100, 1)}%")
28
  else:
29
  st.write('Please upload a file!')