Spaces:
Sleeping
Sleeping
Download test_local_model.py from upandit/mood-app-api-version: direct link, hf CLI and curl.
- Browser
- Download file 746 Bytes
-
https://huggingface.co/spaces/upandit/mood-app-api-version/resolve/main/test_local_model.py
- Command line
-
hf download hf://spaces/upandit/mood-app-api-version/test_local_model.py
-
curl -L -o test_local_model.py https://huggingface.co/spaces/upandit/mood-app-api-version/resolve/main/test_local_model.py
746 Bytes
| # test_local_model.py | |
| from transformers import pipeline | |
| def test_local_model_load(): | |
| """ | |
| Test that the local sentiment model loads and returns valid output. | |
| """ | |
| model = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") | |
| result = model("I am happy!")[0] | |
| # Assertions to make sure model output has expected keys | |
| assert "label" in result, "Model output missing 'label'" | |
| assert "score" in result, "Model output missing 'score'" | |
| assert isinstance(result["score"], float), "'score' should be a float" | |
| assert isinstance(result["label"], str), "'label' should be a string" | |
| if __name__ == "__main__": | |
| test_local_model_load() | |
| print("✅ Local model test passed!") | |