Spaces:
Sleeping
Sleeping
| import json | |
| import logging | |
| from argparse import ArgumentParser | |
| import evaluate | |
| import numpy as np | |
| logger = logging.getLogger(__name__) | |
| parser = ArgumentParser( | |
| description="Compute the matching series score between two time series freezed in a numpy array" | |
| ) | |
| parser.add_argument("predictions", type=str, help="Path to the numpy array containing the predictions") | |
| parser.add_argument("references", type=str, help="Path to the numpy array containing the references") | |
| parser.add_argument("--output", type=str, help="Path to the output file") | |
| parser.add_argument("--batch_size", type=int, help="Batch size to use for the computation") | |
| args = parser.parse_args() | |
| if not args.predictions or not args.references: | |
| raise ValueError("You must provide the path to the predictions and references numpy arrays") | |
| predictions = np.load(args.predictions) | |
| references = np.load(args.references) | |
| logger.info(f"predictions shape: {predictions.shape}") | |
| logger.info(f"references shape: {references.shape}") | |
| import matching_series | |
| metric = matching_series.matching_series() | |
| # metric = evaluate.load("matching_series.py") | |
| results = metric.compute(predictions=predictions, references=references, batch_size=args.batch_size) | |
| print(results) | |
| if args.output: | |
| with open(args.output, "w") as f: | |
| json.dump(results, f) | |