Detext is a web-based text classification tool that determines whether a given text is "safe" or "fraud". It uses technologies such as React, FastAPI, Pydantic, Huggingface's Transformers to offer a robust solution for text classification tasks. The Detext's dataset is built from the three collated fraud/scam/spam datasets.
To classify text as either "safe" or "fraud" using machine learning models.
- 🧠 Classifies text to determin if it's safe or fraud
- 💻 Frontend built with React for a seamless user experience
- ⚡ Fast and responsive backend with FastAPI
- 📜 API documentation available at
/docsfor easy interaction - 🧪 Easy to train and customize model
- Frontend: React, SASS
- Backend: FastAPI, Pydantic
- Modeling: Huggingface Transformers, DistilBERT (uncased)
# Clone the repo
git clone https://github.com/markcalendario/detext.git
cd detext# Navigate to the client directory
cd client
# Install dependencies
npm install
# Start the development server
npm run dev# Navigate to the server directory
cd server
# Install dependencies
pip install -r requirements.txt
# Start the FastAPI server
fastapi dev main.pyTo train the model, follow these steps:
Create a virtual environment:
cd trainer
python -m venv venvActivate the virtual environment:
.\venv\Scripts\activateCreate a Jupyter kernel for the virtual environment:
pip install ipykernel
python -m ipykernel install --user --name=detext-venv
# Restart the code editor to switch to the new kernelRun the training notebook:
Open the notebook trainer.ipynb and train the model using Huggingface transformers.
Once the model is trained, copy the model files to the backend to be used for predictions.
# Copy the trained model to the server's model dir
cp -r trainer/out/detext_dataset/* server/model/detext/Ensure the model files include:
- The model checkpoint (e.g.,
pytorch_model.binor similar) - The model configuration (e.g.,
config.json) - Tokenizer files (e.g.,
tokenizer.json)
Once the project is set up and running, you can:
-
Run the React frontend:
- Open a web browser and navigate to
http://localhost:5173(default port for React). - Input text into the provided form, and the system will classify whether it is safe or fraud.
- Open a web browser and navigate to
-
Access FastAPI Documentation:
- The FastAPI backend provides interactive API documentation at
http://localhost:8000/docs. - Here you can view available endpoints, try them out, and see example requests and responses for the text classification service.
- The FastAPI backend provides interactive API documentation at
# Build and run client and server concurrently using docker compose
docker compose up --build -d