How to use the saliency.xrai.XRAIOutput function in saliency

To help you get started, we’ve selected a few saliency examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PAIR-code / saliency / saliency / xrai.py View on Github external
area_perc_th=extra_parameters.area_threshold,
          min_pixel_diff=extra_parameters.experimental_params['min_pixel_diff'],
          gain_fun=_gain_density,
          integer_segments=extra_parameters.flatten_xrai_segments)
    elif extra_parameters.algorithm == 'fast':
      attr_map, attr_data = self._xrai_fast(
          attr=attr,
          segs=segs,
          min_pixel_diff=extra_parameters.experimental_params['min_pixel_diff'],
          gain_fun=_gain_density,
          integer_segments=extra_parameters.flatten_xrai_segments)
    else:
      raise ValueError('Unknown algorithm type: {}'.format(
          extra_parameters.algorithm))

    results = XRAIOutput(attr_map)
    results.baselines = x_baselines
    if extra_parameters.return_xrai_segments:
      results.segments = attr_data
    # TODO(tolgab) Enable return_baseline_predictions
    # if extra_parameters.return_baseline_predictions:
    #   baseline_predictions = []
    #   for baseline in x_baselines:
    #     baseline_predictions.append(self._predict(baseline))
    #   results.baseline_predictions = baseline_predictions
    if extra_parameters.return_ig_attributions:
      results.ig_attribution = attrs
    return results