A webpage that deploys Text2Brain model for predicting brain activation maps from free-form text query. The webpage is built with Flask + SQLite + AngularJS + Redis + RQ.
The setup is largely similar to this RealPython tutorial (we highly recommend going through this tutorial).
Essentially there are two main python files, app.py
is the Flask web server and worker.py
performs the inference.
app.py
receives input query, which is then passed to a job that is queued by Redis and run in the background by worker.py
without interfering with new web requests.
Requirements:
- Install virtualenv and install python 3.6.14
- Create a virtual environment with venv and install packages under
requirements.txt
- Install sqlite
- Install redis
- Download checkpoints from Google Drive and do
tar -xzvf text2brain_checkpoint.tar.gz
- Download uncased SciBert pretrained model from AllenAI S3 and unzip into
scibert_scivocab_uncased
directory
How to run locally in debug mode:
- Set the environment variables required by
config.py
- Initialize the database
from app import db; db.create_all()
- Run the worker
python worker.py
- Run the web server on another terminal window/tab
python app.py
Please contact Gia at [email protected]