geitta commited on
Commit
61f8391
·
verified ·
1 Parent(s): 0434edb
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -19,7 +19,7 @@ vit.load_state_dict(torch.load(f="pretrained_vit_festure_extractor_flower_classi
19
  def predict(img) -> Tuple[Dict, float]:
20
  """transforms and perfroms a prediction on img and returns prediction and time taken"""
21
  #start the time
22
- start_time = time.time()
23
  #transform the target image and add a batch dim
24
  img = vit_transforms(img).unsqueeze(0)
25
  #put the model in eval mode and turn on inference
@@ -30,7 +30,7 @@ def predict(img) -> Tuple[Dict, float]:
30
  # create a prediction label and prediction probability
31
  pred_labels_and_probs = {class_names[i]: float(pred_probs[0][i]) for i in range(len(class_names))}
32
  # calculate prediction time
33
- end_time = time.time()
34
  pred_time = round(end_time - start_time, 5)
35
  # return the prediction dictionary and prediction time
36
  return pred_labels_and_probs, pred_time
 
19
  def predict(img) -> Tuple[Dict, float]:
20
  """transforms and perfroms a prediction on img and returns prediction and time taken"""
21
  #start the time
22
+ start_time = timer()
23
  #transform the target image and add a batch dim
24
  img = vit_transforms(img).unsqueeze(0)
25
  #put the model in eval mode and turn on inference
 
30
  # create a prediction label and prediction probability
31
  pred_labels_and_probs = {class_names[i]: float(pred_probs[0][i]) for i in range(len(class_names))}
32
  # calculate prediction time
33
+ end_time = timer()
34
  pred_time = round(end_time - start_time, 5)
35
  # return the prediction dictionary and prediction time
36
  return pred_labels_and_probs, pred_time