pranavbapte commited on
Commit
5321346
·
1 Parent(s): e4afbcc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -15,9 +15,9 @@ transformer = transforms.Compose([
15
  #transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225
16
  #])
17
  ])
18
- model=torch.jit.load('model1.pt',map_location=torch.device('cpu'))
19
  #model=torch.jit.load('model1.pt')
20
- classes=['Minivan Images', 'Muscle Car Images', 'Sedan Images', 'Sports car Images']
21
 
22
  def predict(inp):
23
  inp=transformer(inp).unsqueeze(0)
@@ -26,9 +26,9 @@ def predict(inp):
26
  with torch.no_grad():
27
 
28
  prediction =F.softmax(model(inp)[0], dim=0)
29
- confidences = {classes[i]: float(prediction[i]) for i in range(4)}
30
  return confidences
31
 
32
 
33
  # gr.Interface(fn=predict, inputs=gr.Image(type="pil"),outputs=gr.Label(num_top_classes=4),title='Image classification',interpretation='default').launch(debug='True')
34
- gr.Interface(predict, gr.inputs.Image(type="pil"),outputs='label').launch(debug='True')
 
15
  #transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225
16
  #])
17
  ])
18
+ model=torch.jit.load('model.pt',map_location=torch.device('cpu'))
19
  #model=torch.jit.load('model1.pt')
20
+ classes=['Minivan Car', 'Muscle Car ', 'Sedan Car', 'Sports Car', 'None of the Above class']
21
 
22
  def predict(inp):
23
  inp=transformer(inp).unsqueeze(0)
 
26
  with torch.no_grad():
27
 
28
  prediction =F.softmax(model(inp)[0], dim=0)
29
+ confidences = {classes[i]: float(prediction[i]) for i in range(5)}
30
  return confidences
31
 
32
 
33
  # gr.Interface(fn=predict, inputs=gr.Image(type="pil"),outputs=gr.Label(num_top_classes=4),title='Image classification',interpretation='default').launch(debug='True')
34
+ gr.Interface(predict, gr.inputs.Image(type="pil"),outputs='label',title='Image classification').launch(debug='True')