Deploying a Flask app with a Spacy pipeline
Hi all! I've deployed a web app using Flask, via Railway.app. Using Github. Couldn't believe how easy it was.
Project ID: 8ce9ac55-ca78-4140-aaae-601754cc857c
Repository: https://github.com/oozr/globalscaleoflanguages
Website: www.globalscaleoflanguages.com
The web app is a text anlyser. Asks for input text from the user, then analyses the text using the Python library Textstat.
All good so far. I'm now trying to make it more advanced by integrating Spacy library to lemmatize the text (to then lookup the lemmatized words in a sql table of words that I have with rated difficulty). It works in my offline environment because I have the pipeline downloaded on my local host. My issue is in loading the pipeline for the deployed app: error with the code: nlp = spacy.load("en_core_web_sm").
Spacy is in my requirements.txt file. But I'm not sure how to load/add the pipeline for visitors to the web app. Is this something that needs to be loaded every time a user comes to the web app/makes a request? If so how do I go about loading the pipeline. Or would it be better to go via an API route?
This is the best help I could find on StackOverflow, but to be honest I don't really understand it as I'm fairly new to CS.
https://stackoverflow.com/questions/46990884/how-to-use-spacy-nlp-from-within-a-website - answer from Ines Montahy.
Thanks guys, any advice appreciated.
GitHub
GitHub - oozr/globalscaleoflanguages
Contribute to oozr/globalscaleoflanguages development by creating an account on GitHub.
Stack Overflow
How to use Spacy NLP from within a website
I have been practicing with Spacy NLP within the Jupyter Notebook for some time, and have created some scripts that work for what I need.
I also have a website that I have created (built in React)...
4 Replies
Project ID:
8ce9ac55-ca78-4140-aaae-601754cc857c
you just need to download the pipeline on railway, download the pipeline by changing your Procfile to this
Perfect, that works! I'm told I can also add the Python wheel to the requirements.txt app:
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0-py3-none-any.whl
I've tried both, and they both work. Not sure if they're the same solution, or if one is preferable. But thanks again!!
no problem!