Extensible adapter to integrate to integrate various models into applications.
284
Model-Mesh is a sentiment analysis web application powered by FastAPI. It provides a simple API to predict the sentiment of text (positive or negative) using models like BERT. The app also includes a frontend UI that allows users to input text and view sentiment predictions in a user-friendly way. We are using DVC for version controlling datasets and models, along with AWS S3 as the remote storage. Overall this project includes an API, model manager, and adapters for managing and running various machine learning models.
Clone the Repository:
git clone https://github.com/cosminmemetea/model-mesh.git
cd model-mesh
Build the Docker Image:
Build the Docker image using the Dockerfile:
docker build -t model-mesh:latest .
For easy build and redeployment in the docker container:
docker compose up --build modelmesh
Run the Docker Container:
Run the container on port 5050 (or one of your choice, but make sure you update docker related files and app.py):
docker run -d -p 5050:5050 model-mesh:latest
Access the Application:
API (FastAPI): Once the container is running, you can access the FastAPI Swagger UI at:
http://localhost:5050/docs
Frontend UI: To check the mood prediction UI, open your browser and go to:
http://localhost:5050/
Before starting, ensure you have the following installed:
Create an S3 Bucket:
Configure AWS CLI:
pip install awscli
aws configure
json)Install DVC with S3 support:
pip install "dvc[s3]"
Initialize DVC in the project: Navigate to your project directory and initialize DVC:
dvc init
Add data files or directories to DVC: Organize your data into raw/ and processed/ folders, and then track them with DVC:
dvc add data/raw/ data/processed/
Configure the S3 remote storage for DVC: Replace your-bucket-name and path/to/folder with your actual S3 bucket name and folder path:
dvc remote add -d s3remote s3://your-bucket-name/path/to/folder
Push the data to S3: Once you've added data files to DVC, push them to the S3 bucket:
dvc push
Track new data: After adding new data files or directories, use:
dvc add <path_to_data>
Check DVC status: View the state of your tracked files and their storage locations:
dvc status
Pull data from S3: If you or another collaborator needs to retrieve the data tracked in DVC from S3:
dvc pull
Push data to S3: After adding or modifying datasets, push them to S3:
dvc push
Check DVC remotes: List all configured remotes:
dvc remote list
DVC tracks files by their MD5 hashes for efficient version control. When pushing to S3, files will appear as hashed filenames (e.g., md5/hex/hash), which are mapped to the original filenames in your Git repository. This ensures that no duplicate files are stored and changes are versioned.
When collaborators clone this repository, they can pull the necessary data using DVC. After setting up DVC and configuring the S3 remote, run:
dvc pull
To version control new data, add the files using dvc add and then commit the changes in Git. Push the updated .dvc files to the repository, and use dvc push to sync the data to S3. Add the following DVC files to Git after every change:
git add data/.gitignore data/raw.dvc data/processed.dvc
git commit -m "Tracked new data with DVC"
git push
Never commit large datasets directly to Git; always use DVC to track them.
Below are the datasets used for this project:
Sentiment140 (Twitter data)
IMDb Movie Reviews
Amazon Product Reviews
Yelp Reviews
To download datasets from Kaggle, you will need to set up the Kaggle API on your machine.
Install the Kaggle API using pip:
pip install kaggle
kaggle.json file.kaggle.json to the appropriate directory:
mkdir -p ~/.kaggle
mv ~/Downloads/kaggle.json ~/.kaggle/
chmod 600 ~/.kaggle/kaggle.json
C:\Users\<YourUsername>\.kaggle\kaggle.json.After the Kaggle API is configured, you can download datasets using the following commands:
IMDb Movie Reviews:
kaggle datasets download -d lakshmi25npathi/imdb-dataset-of-50k-movie-reviews
unzip imdb-dataset-of-50k-movie-reviews.zip -d data/raw/
Amazon Reviews:
kaggle datasets download -d bittlingmayer/amazonreviews
unzip amazonreviews.zip -d data/raw/
Content type
Image
Digest
sha256:fd45aecd3…
Size
1.4 GB
Last updated
about 2 years ago
docker pull come23/model-mesh