Esempio n. 1
0
 def to_libpressio(x):
     op = None
     if isinstance(value, np.ndarray):
         value_lp = pressio.io_data_from_numpy(value)
         op = pressio.option_new_data(value_lp)
         pressio.data_free(value_lp)
     elif isinstance(value, list):
         if value:
             # list is non-empty
             if isinstance(value[0], str):
                 op = pressio.option_new_strings(
                     pressio.vector_string([i.encode() for i in value]))
             elif isinstance(value[0], int) or isinstance(value[0], float):
                 arr = np.array(value)
                 lp = pressio.io_data_from_numpy(arr)
                 op = pressio.option_new_data(lp)
                 pressio.data_free(lp)
             else:
                 raise TypeError("unexpected list type: " + value)
         else:
             # list is empty
             op = pressio.option_new_strings(pressio.vector_string())
     elif isinstance(value, float):
         op = pressio.option_new_double(value)
     elif isinstance(value, str):
         op = pressio.option_new_string(value.encode())
     elif isinstance(value, bytes):
         op = pressio.option_new_string(value)
     elif isinstance(value, int):
         op = pressio.option_new_integer64(value)
     else:
         raise TypeError("Unsupported type " + str(type(value)))
     return op
Esempio n. 2
0
    def __init__(self, ids, early_config, metrics_config, name):
        try:
            config_lp = None
            library = pressio.instance()
            metrics_ids = pressio.vector_string([i.encode() for i in ids])
            self._metric = pressio.new_metrics(library, metrics_ids)
            self._metric_id = "composite"
            if not self._metric:
                raise PressioException.from_library(library)

            if name is not None:
                pressio.metrics_set_name(self._metric, name.encode())

            early_config_lp = _python_to_pressio(early_config)
            pressio.metrics_set_options(self._metric, early_config_lp)
            pressio.options_free(early_config_lp)

            config_lp_template = pressio.metrics_get_options(self._metric)
            config_lp = _python_to_pressio(metrics_config, config_lp_template)

            pressio.metrics_set_options(self._metric, config_lp)
        finally:
            pressio.release(library)
            pressio.options_free(config_lp)
            pressio.options_free(config_lp_template)
Esempio n. 3
0
    #DO I CARE ABOUT THIS ANYMORE?
    OutputID = re.findall("(\d+)", imgs)

    #load images
    pix_vals = im.load()
    width, height = im.size

    #Create Datasets From Image For extrapolation
    intArray = []
    intArray = createIntArray(pix_vals, width, height)
    floatArray = createFloatArray(intArray, width, height)

    library = pressio.instance()
    compressor = pressio.get_compressor(library, b"sz")
    sz_options = pressio.compressor_get_options(compressor)
    metric_ids = pressio.vector_string([b'time', b'size'])
    metrics = pressio.new_metrics(library, metric_ids)

    pressio.options_set_integer(sz_options, b"sz:error_bound_mode", sz.PSNR)
    pressio.options_set_double(sz_options, b"sz:psnr_err_bound",
                               float(sys.argv[1]))

    pressio.compressor_check_options(compressor, sz_options)
    pressio.compressor_set_options(compressor, sz_options)
    pressio.compressor_set_metrics(compressor, metrics)

    input_data = pressio.io_data_from_numpy(floatArray)

    compressed_data = pressio.data_new_empty(pressio.byte_dtype,
                                             pressio.vector_uint64_t())