Isaacgonzales commited on
Commit
da65082
1 Parent(s): 8e12dfe

update model

Browse files
Files changed (1) hide show
  1. model.py +5 -5
model.py CHANGED
@@ -21,23 +21,23 @@ SHAPE_X = 384
21
  SHAPE_Y = 384
22
  preprocessing_fn = smp.encoders.get_preprocessing_fn('resnet50')
23
 
24
- transform = albu.Compose([
25
  albu.Lambda(image=preprocessing_fn), albu.Resize(SHAPE_X, SHAPE_Y)
26
  ])
27
 
 
28
 
29
  def prediction(image_path):
30
  t_start = process_time()
31
  image = cv2.imread(image_path)
32
  image_original = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
33
 
34
- image_result = transform(image=image_original)["image"]
35
- transform = transforms.ToTensor()
36
- tensor = transform(image_result)
37
  tensor = torch.unsqueeze(tensor, 0)
38
  output = model.predict(tensor.float())
39
 
40
- result, img_vis = filter_mask(output, image_original )
41
 
42
  image = cv2.cvtColor(result, cv2.COLOR_BGR2RGB)
43
  im_pil = Image.fromarray(image)
 
21
  SHAPE_Y = 384
22
  preprocessing_fn = smp.encoders.get_preprocessing_fn('resnet50')
23
 
24
+ transform_compose = albu.Compose([
25
  albu.Lambda(image=preprocessing_fn), albu.Resize(SHAPE_X, SHAPE_Y)
26
  ])
27
 
28
+ transform_tensor = transforms.ToTensor()
29
 
30
  def prediction(image_path):
31
  t_start = process_time()
32
  image = cv2.imread(image_path)
33
  image_original = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
34
 
35
+ image_result = transform_compose(image=image_original)["image"]
36
+ tensor = transform_tensor(image_result)
 
37
  tensor = torch.unsqueeze(tensor, 0)
38
  output = model.predict(tensor.float())
39
 
40
+ result, img_vis = filter_mask(output, image_original)
41
 
42
  image = cv2.cvtColor(result, cv2.COLOR_BGR2RGB)
43
  im_pil = Image.fromarray(image)