A newer version of the Gradio SDK is available: 6.14.0
title: Environmental Impact Analyzer
emoji: ⚡
colorFrom: green
colorTo: red
sdk: gradio
sdk_version: 5.33.0
app_file: app.py
pinned: false
short_description: Gives Carbon Footprint Score for products description or url
Enviromental Impact Analyzer
This project, "Environmental Impact Analyzer," is a Gradio-based application designed to assess the environmental footprint of products. Users can input either a product description or a URL to a product page, and the application will extract relevant information, calculate its carbon footprint, generate an environmental sustainability score, and provide actionable recommendations for improvement.
Features:
- Product Information Extraction: Automatically extracts key environmental factors from text descriptions or web pages (via URL scraping).
- Carbon Footprint Calculation: Integrates with the Climatiq API to estimate the carbon emissions associated with the product's manufacturing and transportation.
- Environmental Scoring: Leverages advanced Large Language Models (LLMs) to generate a comprehensive sustainability score (0-100) based on multiple environmental criteria.
- Improvement Recommendations: Provides specific and actionable suggestions to reduce the product's environmental impact. Intuitive Gradio Interface: Offers an easy-to-use web interface for seamless interaction.
How It Works
The core of the Environmental Impact Analyzer is built using LangGraph, enabling a stateful, multi-step agentic workflow:
- Input Classification: Determines if the user input is a direct product description or a URL.
- Information Extraction:
- If a URL, it scrapes the product information from the web page.
- If a description, it directly processes the provided text.
- An LLM (
deepseek-ai/DeepSeek-R1) is then used to extract structured environmental data (e.g., material composition, manufacturing location, weight, transport distance, recyclability).
- Carbon Footprint Calculation: The extracted data is sent to the Climatiq API to calculate the estimated carbon footprint (in kg CO2e) based on factors like materials and transportation.
- Environmental Scoring & Recommendations:
- An LLM (
meta-llama/Meta-Llama-3.1-70B-Instruct) evaluates the extracted data and carbon footprint. - It generates an overall environmental score (0-100), considering factors like carbon emissions, material sustainability, manufacturing practices, transport, longevity, and end-of-life. The scoring is calibrated to recognize positive environmental efforts.
- It also provides a category breakdown of the score and actionable recommendations for improving the product's environmental impact.
- An LLM (
Note: You can also change the Models for your liking to increse Speed or more accuracy.but make sure hyperbolic supports it.
Tech Stack
| Category | Technology | Purpose |
|---|---|---|
| Framework | Gradio | Building the interactive web user interface. |
| Agentic Workflow | LangGraph | Orchestrating multi-step agent logic and state management. |
| LLM Integration | Hugging Face Inference Client | Interacting with Large Language Models hosted on Hugging Face Hub. |
| Core LLM | deepseek-ai/DeepSeek-R1 |
Generates environmental scores, category breakdowns, and recommendations. |
| External APIs | Climatiq API | Calculates carbon footprint based on product data. |
| Web Scraping | requests, BeautifulSoup (via scrapper.py) |
Fetching and parsing HTML content from product URLs. |
| Prompting | langchain.prompts.ChatPromptTemplate |
Structuring and templating LLM prompts for consistent input. |
| Environment Mgt. | python-dotenv |
Loading environment variables from .env files for secure key management. |
| Data Typing | typing, typing_extensions (TypedDict) |
Enhancing code readability and maintainability with type hints. |
Setup and Installation
To run this project locally, follow these steps:
1. Clone the Repository
git clone [https://huggingface.co/spaces/Agents-MCP-Hackathon/Environmental-Impact-Analyzer](https://huggingface.co/spaces/Agents-MCP-Hackathon/Environmental-Impact-Analyzer)
cd Environmental-Impact-Analyzer
2. Create a Virtual Environment (Recommended)
python -m venv .venv
# On Windows
.venv\Scripts\activate
# On macOS/Linux
source .venv/bin/activate
3. Install Dependencies
pip install -r requirements.txt
4. 4. Configure Environment Variables
Create a .env file in the root directory of your project and add the following:
HF_API_KEY="hf_YOUR_HUGGING_FACE_ACCESS_TOKEN"
CLIMATIQ_API_KEY="YOUR_CLIMATIQ_API_KEY"
5. Run the Application
python app.py