You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
3 years ago | |
---|---|---|
generated | 3 years ago | |
.gitignore | 3 years ago | |
Readme.design.md | 3 years ago | |
Readme.md | 3 years ago | |
eval_accuracy.py | 3 years ago | |
language_detector.py | 3 years ago | |
requirements.txt | 3 years ago | |
run-server.sh | 3 years ago | |
server.py | 3 years ago | |
test.py | 3 years ago |
Readme.md
Prerequisite
- python3
Installation
To avoid local package pollution, it would be better to create virtual environment for this installation
pip3 install virtualenv
# Create a virtual env in ./venv directory
virtualenv ./venv
# Activate virtualenv
. ./venv/bin/activate
Then install dependencies
pip3 install -r ./requirements.txt
Running server
./run-server.sh
# INFO:language-detector:Training model ...
# INFO:language-detector:Downloading dataset from url ...
# INFO:language-detector:Saved dataset to cache ...
# INFO:language-detector:Training complete. Feature count: 6109840
# INFO:language-detector:saved model lang-detect-MNB.pkl
# INFO: Started server process [1780455]
# INFO:uvicorn.error:Started server process [1780455]
# INFO: Waiting for application startup.
# INFO:uvicorn.error:Waiting for application startup.
# INFO: Application startup complete.
# INFO:uvicorn.error:Application startup complete.
# INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
# INFO:uvicorn.error:Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
checking API response from terminal
curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" "http://localhost:8000/api/language/predict" -d '{"text": "Hello how old are you"}'
# {"lang": "English", "score": 0.9998260997236165}