The Recipe Analyzer is a web application designed to analyze recipes and extract nutritional information using BERT for Named Entity Recognition (NER). Instead of traditional food recommendation systems, this application uses advanced NLP techniques to identify ingredients and their associated nutrients.
- Recipe Analysis: Users can input a recipe description, and the application will process it to extract nutritional details.
- Nutritional Information Extraction: Utilizes a BERT-based model (
sgarbi/bert-fda-nutrition-ner
) from Hugging Face to identify and classify ingredients and nutrients.
- Backend: Django with Django REST Framework (DRF)
- NER Model: BERT-based model (
sgarbi/bert-fda-nutrition-ner
) from Hugging Face Transformers library - Frontend: HTML, CSS, and JavaScript
-
Clone the repository:
git clone https://github.com/yourusername/recipe-analyzer.git cd recipe-analyzer
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Run the Django development server:
python manage.py migrate python manage.py runserver
-
Navigate to
http://127.0.0.1:8000/api/analyzer/
in your web browser to use the application.
-
Access the Application
Open your browser and navigate to http://127.0.0.1:8000/api/analyzer/.
-
Analyze a Recipe
- Enter a recipe description (e.g., "2 mangoes, 1 tablespoon of salt, 1 cup of water").
- Click the "Analyze Recipe" button to see the nutritional analysis.
-
API Endpoint
- POST
/api/analyze/
: Analyzes the provided recipe and returns nutritional information. - GET
/api/analyze/
: Returns a message indicating that only POST requests are supported.
- POST
Request Body:
{
"recipe": "string" // The recipe description to be analyzed
}
Response:
{
"analysis": [
{
"ingredient": "string", // Extracted ingredient
"major_nutrient": "string" // Nutrient associated with the ingredient
}
]
}
This project is licensed under the MIT License - see the LICENSE file for details.