Spaces:
Build error
Build error
Download inference_direct.py from cvachet/iris_classification_lambda: direct link, hf CLI and curl.
- Browser
- Download file 667 Bytes
-
https://huggingface.co/spaces/cvachet/iris_classification_lambda/resolve/8f37ccca3e1f5066e2fbb2f004236ab6dfc15952/inference_direct.py
- Command line
-
hf download hf://spaces/cvachet/iris_classification_lambda@8f37ccca3e1f5066e2fbb2f004236ab6dfc15952/inference_direct.py
-
curl -L -o inference_direct.py https://huggingface.co/spaces/cvachet/iris_classification_lambda/resolve/8f37ccca3e1f5066e2fbb2f004236ab6dfc15952/inference_direct.py
667 Bytes
| """ | |
| Direct inference with hard-coded data | |
| """ | |
| import json | |
| from classification.classifier import Classifier | |
| if __name__ == "__main__": | |
| cls = Classifier() | |
| # Training | |
| cls.train_and_save() | |
| # Testing | |
| data = {"features": [[6.5, 3.0, 5.8, 2.2], [6.1, 2.8, 4.7, 1.2]]} | |
| features = data["features"] | |
| results = cls.load_and_test(features) | |
| print("results:", results) | |
| # Response similar to REST API call | |
| response = { | |
| "statusCode": 200, | |
| "body": json.dumps( | |
| {"predictions": results["predictions"], "probabilities": results["probabilities"]} | |
| ), | |
| } | |
| print("Example REST API response: ", response) | |