Download predict.py from chiru112/ec-starter-test: direct link, hf CLI and curl.
- Browser
- Download file 880 Bytes
-
https://huggingface.co/chiru112/ec-starter-test/resolve/main/predict.py
- Command line
-
hf download hf://chiru112/ec-starter-test/predict.py
-
curl -L -o predict.py https://huggingface.co/chiru112/ec-starter-test/resolve/main/predict.py
880 Bytes
| """Offline CPU inference. Replace the frequency baseline with your own model.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| import pandas as pd | |
| from inputs import prepare_inputs | |
| def predict_file(input_path, output_path): | |
| root = Path(__file__).parent | |
| frame = prepare_inputs(pd.read_parquet(input_path)) | |
| weights = json.loads((root / 'weights/baseline.json').read_text()) | |
| # Load your model once. Batch its predictions here. | |
| with Path(output_path).open('w') as output: | |
| for key in frame.id: | |
| output.write(json.dumps({'id':key, 'prediction':weights['prediction']}) + '\n') | |
| if __name__ == '__main__': | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument('--input', required=True) | |
| parser.add_argument('--output', required=True) | |
| args = parser.parse_args() | |
| predict_file(args.input, args.output) | |