rohithk-03 commited on
Commit
a3f3a1f
·
1 Parent(s): ad9f29a

update model code

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. model.py +3 -4
app.py CHANGED
@@ -232,8 +232,8 @@ def predict():
232
  image_save_path = os.path.join(
233
  tempfile.gettempdir(), file.filename.lower())
234
  image.save(image_save_path)
235
-
236
- return jsonify({"message": model.check_file(temp_path), "saved_path": image_save_path})
237
 
238
 
239
  if __name__ == "__main__":
 
232
  image_save_path = os.path.join(
233
  tempfile.gettempdir(), file.filename.lower())
234
  image.save(image_save_path)
235
+ a, b = model.check_file(temp_path)[0]
236
+ return jsonify({"message": a, confidence: b, "saved_path": image_save_path})
237
 
238
 
239
  if __name__ == "__main__":
model.py CHANGED
@@ -142,7 +142,7 @@ def check_file(image_path):
142
  # Get confidence score and prediction
143
  confidence, d = torch.max(probabilities, 1)
144
  print(confidence)
145
- return predicted
146
 
147
  def remove_module_from_checkpoint(checkpoint):
148
  new_state_dict = {}
@@ -160,6 +160,5 @@ def check_file(image_path):
160
  model.eval()
161
  model.to(device)
162
  model = nn.DataParallel(model)
163
- output = test_model(model, test_loader, device)
164
- print(output)
165
- return "control" if output.item() == 0 else "ms"
 
142
  # Get confidence score and prediction
143
  confidence, d = torch.max(probabilities, 1)
144
  print(confidence)
145
+ return predicted, confidence
146
 
147
  def remove_module_from_checkpoint(checkpoint):
148
  new_state_dict = {}
 
160
  model.eval()
161
  model.to(device)
162
  model = nn.DataParallel(model)
163
+ output, confidence = test_model(model, test_loader, device)
164
+ return "control" if output.item() == 0 else "ms", confidence.item()