Isaacgonzales commited on
Commit
659a0c6
1 Parent(s): 463c439

update parameters

Browse files
Files changed (1) hide show
  1. model.py +4 -3
model.py CHANGED
@@ -9,7 +9,7 @@ from PIL import Image
9
  import torch
10
  import cv2
11
  from time import process_time
12
-
13
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
14
 
15
  model_recog = load_from_checkpoint("weights/parseq/last.ckpt").eval().to(device).float()
@@ -29,6 +29,7 @@ def prediction(image_path):
29
  t_start = process_time()
30
  image = cv2.imread(image_path)
31
  image_original = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
 
32
  transform_compose = albu.Compose([
33
  albu.Lambda(image=preprocessing_fn), albu.Resize(SHAPE_X, SHAPE_Y)
34
  ])
@@ -47,10 +48,10 @@ def prediction(image_path):
47
  p = model_recog(image).softmax(-1)
48
  pred, p = model_recog.tokenizer.decode(p)
49
  t_stop = process_time()
50
- t_process = t_stop - t_start
51
  print(f'{image_path}: {pred[0]}, {t_process} seconds')
52
 
53
- return img_vis, pred[0], t_process/2
54
 
55
 
56
 
 
9
  import torch
10
  import cv2
11
  from time import process_time
12
+ import imutils
13
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
14
 
15
  model_recog = load_from_checkpoint("weights/parseq/last.ckpt").eval().to(device).float()
 
29
  t_start = process_time()
30
  image = cv2.imread(image_path)
31
  image_original = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
32
+ image_original = imutils.resize(image_original, width=image_original.shape[1]//5)
33
  transform_compose = albu.Compose([
34
  albu.Lambda(image=preprocessing_fn), albu.Resize(SHAPE_X, SHAPE_Y)
35
  ])
 
48
  p = model_recog(image).softmax(-1)
49
  pred, p = model_recog.tokenizer.decode(p)
50
  t_stop = process_time()
51
+ t_process = (t_stop - t_start)/2
52
  print(f'{image_path}: {pred[0]}, {t_process} seconds')
53
 
54
+ return img_vis, pred[0], t_process
55
 
56
 
57