Spaces:
Sleeping
Sleeping
🚀 Quick Start Guide
Installation
- Install dependencies:
pip install -r requirements.txt
- Run the application:
python main.py
- Access the application:
Nhớ kích hoạt môi trường trước
conda activate ./env
- Dashboard: http://localhost:8000
- Swagger API Docs: http://localhost:8000/docs ⭐ (Show this to your teacher!)
- ReDoc: http://localhost:8000/redoc
First Time Usage
- Go to http://localhost:8000/login
- Click "Register here" and create an account
- Login with your credentials
- You'll be redirected to the dashboard
Testing Single Prediction
- Select a product from dropdown
- Click "Single Comment" tab
- Enter a Vietnamese comment like: "Sản phẩm rất tốt, chất lượng cao, đóng gói cẩn thận"
- Click "Predict Rating"
- See the result with rating and confidence
Testing Batch Prediction (CSV)
- Create a CSV file with this format:
Comment
"Sản phẩm rất tốt, đóng gói cẩn thận"
"Chất lượng kém, không như mô tả"
"Giao hàng nhanh, sản phẩm ổn"
"Rất hài lòng với sản phẩm này"
"Giá hơi cao nhưng chất lượng tốt"
- Select a product
- Click "Upload CSV" tab
- Upload your CSV file
- Click "Predict Batch"
- View:
- Bar chart showing rating distribution
- Word cloud of common words
- Full results table
- Download CSV with predictions
Swagger UI Demo (For Teacher)
- Open http://localhost:8000/docs
- Show the endpoints:
- Authentication (register, login)
- Predictions (single, batch)
- History
- Click "Try it out" to test any endpoint
- Show the automatic request/response documentation
Replace Dummy ML Model
Edit app/services/ml_service.py:
def __init__(self):
# Load your real model here
self.model = load_model('path/to/your/model')
self.tokenizer = load_tokenizer('path/to/tokenizer')
def predict_single(self, text: str) -> Dict[str, any]:
# Your preprocessing
preprocessed = self.preprocess(text)
# Your prediction
prediction = self.model.predict(preprocessed)
rating = int(prediction) # Convert to 1-5
return {
'rating': rating,
'confidence': float(prediction_confidence)
}
Troubleshooting
"Module not found":
pip install -r requirements.txt
"Port already in use":
Edit main.py and change port 8000 to another number.
"Database locked": Close any other instances of the app and restart.
Project Highlights for Presentation
✅ FastAPI with automatic Swagger UI (bonus points!)
✅ JWT Authentication (secure login)
✅ RESTful API design (professional structure)
✅ Data Visualization (charts + word clouds)
✅ Batch Processing (CSV upload/download)
✅ Responsive UI (TailwindCSS)
✅ Database Integration (SQLite with history tracking)
Good luck! 🎓