docs: def obj_from_file(filename='annotation.yaml', filetype='auto'):
      ''' Read object from file '''
  
      if filetype == 'auto':
          _, ext = os.path.splitext(filename)
          filetype = ext[1:]
  
      if filetype in ('yaml', 'yml'):
          from ruamel.yaml import YAML
          yaml = YAML(typ="unsafe")
          with open(filename, encoding="utf-8") as f:
              obj = yaml.load(f)
          if obj is None:
              obj = {}
          # import yaml
          # with open(filename, encoding="utf-8") as f:
          #     intext = f.read()
          #     obj = yaml.load(intext)
      elif filetype in ('pickle', 'pkl', 'pklz', 'picklezip'):
          fcontent = read_pkl_and_pklz(filename)
          # import pickle
          if sys.version_info[0] < 3:
              import cPickle as pickle
          else:
              import _pickle as pickle
          # import sPickle as pickle
          if sys.version_info.major == 2:
              obj = pickle.loads(fcontent)
          else:
              obj = pickle.loads(fcontent, encoding="latin1")
      else:
          logger.error('Unknown filetype ' + filetype)
      return obj