ganesh1410 commited on
Commit
60b57d9
·
1 Parent(s): 0b4dbd3

change output to text

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -37,8 +37,9 @@ if __name__ == '__main__':
37
 
38
  def predict(image):
39
  img = PILImage.create(image)
40
- pred,pred_idx,probs = model.predict(img)
41
- return {'Cat':probs[1].item(), 'Not Cat':probs[0].item()}
42
 
43
- demo = gr.Interface(fn=model.predict, inputs="image", outputs=['label'],examples=['examples/cat-1.jpg','examples/dog-1.jpg'],allow_flagging='never')
44
- demo.launch()
 
 
37
 
38
  def predict(image):
39
  img = PILImage.create(image)
40
+ _,_,probs = model.predict(img)
41
+ return {'Not Cat':float("{:.2f}".format(probs[0].item())), 'Cat':float("{:.2f}".format(probs[1].item()))}
42
 
43
+ # outputs label is not working, need to investigate further
44
+ demo = gr.Interface(fn=model.predict, inputs=gr.Image(), outputs='text',examples=['examples/cat-1.jpg','examples/dog-1.jpg'],allow_flagging='never')
45
+ demo.launch(show_error=True)