落水人员检测
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
943B

  1. from torchvision import transforms
  2. from utils import custom_transforms as tr
  3. import numpy as np
  4. import pandas as pd
  5. def transform_ts(args,sample):
  6. #将图像从cv读的格式转为归一化,并转为tensor
  7. composed_transforms = transforms.Compose([
  8. tr.FixedResize(size=args['crop_size']),
  9. tr.Normalize(mean=(0.335, 0.358, 0.332), std=(0.141, 0.138, 0.143)),
  10. tr.ToTensor()])
  11. return composed_transforms(sample)
  12. def colour_code_segmentation(image, label_values):
  13. label_values = [label_values[key] for key in label_values]
  14. colour_codes = np.array(label_values)
  15. x = colour_codes[image.astype(int)]
  16. return x
  17. def get_label_info(csv_path):
  18. ann = pd.read_csv(csv_path)
  19. label = {}
  20. for iter, row in ann.iterrows():
  21. label_name = row['name']
  22. r = row['r']
  23. g = row['g']
  24. b = row['b']
  25. label[label_name] = [int(r), int(g), int(b)]
  26. return label