How to use the openvino.tools.calibration.CalibratorFactory function in openvino

To help you get started, we’ve selected a few openvino 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 opencv / dldt / tools / calibration / __main__.py View on Github external
def check_accuracy():
    config = calibration.CommandLineReader.read()
    calibrator = calibration.CalibratorFactory.create(config.precision, calibration.CalibratorConfiguration(config))

    print("Collecting accuracy for {}...".format(config.model))
    result = calibrator.infer()
    print("Accuracy: {0:.4f}%".format(100.0 * result.metrics.accuracy))
github opencv / dldt / inference-engine / tools / collect_statistics_tool / collect_statistics.py View on Github external
def collect_statistics():
    with CommandLineProcessor.process() as configuration:
        calibrator = CalibratorFactory.create(configuration.precision, CalibratorConfiguration(configuration))

        print("Collecting FP32 statistics for {}...".format(configuration.model))
        fp32_result = calibrator.infer(add_outputs=True, collect_aggregated_statistics=True)
        print("FP32 accuracy: {0:.4f}{1}".format(fp32_result.metrics.accuracy.value, fp32_result.metrics.accuracy.symbol))

        output_model_file_path = Path.get_model(configuration.output_model, "_statistics")
        output_weights_file_path = Path.get_weights(configuration.output_weights, "_statistics")

        quantization_levels = calibrator.get_quantization_levels(CalibrationConfigurationHelper.read_ignore_layer_names(configuration))
        statistics = fp32_result.aggregated_statistics.get_node_statistics()
        calibrator.save(output_model_file_path, output_weights_file_path, quantization_levels, statistics)
        print("Network with statistics was written to {}.(xml|bin) IR file".format(os.path.splitext(output_model_file_path)[0]))