BenjiELCA commited on
Commit
33c579f
·
1 Parent(s): 00888d3

change of the model object

Browse files
Files changed (2) hide show
  1. modules/streamlit_utils.py +1 -1
  2. modules/utils.py +4 -7
modules/streamlit_utils.py CHANGED
@@ -53,7 +53,7 @@ def load_models():
53
  model_arrow = get_arrow_model(len(arrow_dict),2)
54
 
55
  url_arrow = 'https://drive.google.com/uc?id=1vv1X_r_lZ8gnzMAIKxcVEb_T_Qb-NkyA'
56
- url_object = 'https://drive.google.com/uc?id=1b1bqogxqdPS-SnvaOfWJGV1I1qOrTKh5'
57
 
58
  # Define paths to save models
59
  output_arrow = 'model_arrow.pth'
 
53
  model_arrow = get_arrow_model(len(arrow_dict),2)
54
 
55
  url_arrow = 'https://drive.google.com/uc?id=1vv1X_r_lZ8gnzMAIKxcVEb_T_Qb-NkyA'
56
+ url_object = 'https://drive.google.com/uc?id=1ciSS7H5baqXf8sRilcAjWBM9jZ0DQhsP'
57
 
58
  # Define paths to save models
59
  output_arrow = 'model_arrow.pth'
modules/utils.py CHANGED
@@ -411,7 +411,7 @@ def rotate_vertical(image, target):
411
  return image, target
412
 
413
  class BPMN_Dataset(Dataset):
414
- def __init__(self, annotations, transform=None, crop_transform=None, crop_prob=0.3, rotate_90_proba=0.2, flip_transform=None, rotate_transform=None, new_size=(1333,800),keep_ratio=False,resize=True, model_type='object', rotate_vertical=False):
415
  self.annotations = annotations
416
  print(f"Loaded {len(self.annotations)} annotations.")
417
  self.transform = transform
@@ -420,7 +420,6 @@ class BPMN_Dataset(Dataset):
420
  self.flip_transform = flip_transform
421
  self.rotate_transform = rotate_transform
422
  self.resize = resize
423
- self.rotate_vertical = rotate_vertical
424
  self.new_size = new_size
425
  self.keep_ratio = keep_ratio
426
  self.model_type = model_type
@@ -494,11 +493,11 @@ class BPMN_Dataset(Dataset):
494
  image, target = self.crop_transform(image, target)
495
 
496
  # Rotate vertical image
497
- if self.rotate_vertical and random.random() < self.rotate_90_proba:
498
  image, target = rotate_vertical(image, target)
499
 
500
  if self.resize:
501
- if self.keep_ratio:
502
  original_size = image.size
503
  # Calculate scale to fit the new size while maintaining aspect ratio
504
  scale = min(self.new_size[0] / original_size[0], self.new_size[1] / original_size[1])
@@ -557,7 +556,7 @@ def collate_fn(batch):
557
  def create_loader(new_size,transformation, annotations1, annotations2=None,
558
  batch_size=4, crop_prob=0.2, crop_fraction=0.7, min_objects=3,
559
  h_flip_prob=0.3, v_flip_prob=0.3, max_rotate_deg=20, rotate_90_proba=0.2, rotate_proba=0.3,
560
- seed=42, resize=True, rotate_vertical=False, keep_ratio=False, model_type = 'object'):
561
  """
562
  Creates a DataLoader for BPMN datasets with optional transformations and concatenation of two datasets.
563
 
@@ -592,7 +591,6 @@ def create_loader(new_size,transformation, annotations1, annotations2=None,
592
  rotate_90_proba=rotate_90_proba,
593
  flip_transform=custom_flip_transform,
594
  rotate_transform=custom_rotate_transform,
595
- rotate_vertical=rotate_vertical,
596
  new_size=new_size,
597
  keep_ratio=keep_ratio,
598
  model_type=model_type,
@@ -608,7 +606,6 @@ def create_loader(new_size,transformation, annotations1, annotations2=None,
608
  crop_prob=crop_prob,
609
  rotate_90_proba=rotate_90_proba,
610
  flip_transform=custom_flip_transform,
611
- rotate_vertical=rotate_vertical,
612
  new_size=new_size,
613
  keep_ratio=keep_ratio,
614
  model_type=model_type,
 
411
  return image, target
412
 
413
  class BPMN_Dataset(Dataset):
414
+ def __init__(self, annotations, transform=None, crop_transform=None, crop_prob=0.3, rotate_90_proba=0.2, flip_transform=None, rotate_transform=None, new_size=(1333,800),keep_ratio=0.1,resize=True, model_type='object'):
415
  self.annotations = annotations
416
  print(f"Loaded {len(self.annotations)} annotations.")
417
  self.transform = transform
 
420
  self.flip_transform = flip_transform
421
  self.rotate_transform = rotate_transform
422
  self.resize = resize
 
423
  self.new_size = new_size
424
  self.keep_ratio = keep_ratio
425
  self.model_type = model_type
 
493
  image, target = self.crop_transform(image, target)
494
 
495
  # Rotate vertical image
496
+ if random.random() < self.rotate_90_proba:
497
  image, target = rotate_vertical(image, target)
498
 
499
  if self.resize:
500
+ if random.random() < self.keep_ratio:
501
  original_size = image.size
502
  # Calculate scale to fit the new size while maintaining aspect ratio
503
  scale = min(self.new_size[0] / original_size[0], self.new_size[1] / original_size[1])
 
556
  def create_loader(new_size,transformation, annotations1, annotations2=None,
557
  batch_size=4, crop_prob=0.2, crop_fraction=0.7, min_objects=3,
558
  h_flip_prob=0.3, v_flip_prob=0.3, max_rotate_deg=20, rotate_90_proba=0.2, rotate_proba=0.3,
559
+ seed=42, resize=True, keep_ratio=0.1, model_type = 'object'):
560
  """
561
  Creates a DataLoader for BPMN datasets with optional transformations and concatenation of two datasets.
562
 
 
591
  rotate_90_proba=rotate_90_proba,
592
  flip_transform=custom_flip_transform,
593
  rotate_transform=custom_rotate_transform,
 
594
  new_size=new_size,
595
  keep_ratio=keep_ratio,
596
  model_type=model_type,
 
606
  crop_prob=crop_prob,
607
  rotate_90_proba=rotate_90_proba,
608
  flip_transform=custom_flip_transform,
 
609
  new_size=new_size,
610
  keep_ratio=keep_ratio,
611
  model_type=model_type,