# 🏗️ Construction Site Safety Analyzer ## Overview The **Construction Site Safety Analyzer** is a powerful tool designed to enhance workplace safety and compliance through AI-powered image and video analysis. Leveraging the capabilities of Llama 3.2 90B Vision and expert chat assistance, this application helps identify safety issues, categorize them, provide detailed descriptions, and suggest steps to resolve them. ## Features ### 1. Image Analysis - **Upload Multiple Images**: Easily upload multiple construction site images for comprehensive analysis. - **Automatic Image Resizing**: Ensures that images do not exceed API size limits while maintaining quality. - **Safety Hazard Identification**: Identifies potential safety hazards, categorizes them, and provides detailed descriptions. - **Resolution Suggestions**: Offers actionable steps to mitigate identified risks. ### 2. Video Analysis - **Upload Videos**: Upload videos to analyze specific frames for safety hazard identification. - **Key Frame Extraction**: Extracts key frames from videos at specified time points (default: start, middle, end). - **Detailed Analysis**: Provides detailed analysis for each extracted frame, similar to image analysis. ### 3. Expert Chat Assistance - **Interactive Chat**: Engage in real-time conversations with an AI assistant specializing in construction site safety. - **Question-Based Analysis**: Ask questions about specific safety measures or regulations related to the analyzed hazards. - **Comprehensive Insights**: Receive detailed answers based on the initial analysis, enhancing understanding and decision-making. ## Getting Started ### Prerequisites - Python 3.8+ - `pip` (Python package installer) ### Installation 1. Clone the repository: ```bash git clone https://github.com/your-repo/construction-site-safety-analyzer.git cd construction-site-safety-analyzer ``` 2. Install dependencies: ```bash pip install -r requirements.txt ``` 3. Set up environment variables: ```bash export GROQ_API_KEY="your-groq-api-key" ``` ### Running the Application To launch the application, simply run the main script: ```bash python app.py ``` This will start a local server, and you can access the application via your web browser at `http://localhost:7860`. ## Usage 1. **Upload Images/Videos**: Navigate to the "Upload Construction Site Images" or "Upload Construction Site Video" sections and select the appropriate files. 2. **Analyze Safety Hazards**: Click the "🔍 Analyze Safety Hazards" button to initiate the analysis process. 3. **View Analysis Results**: The safety analysis results will be displayed in the "Safety Analysis Results and Expert Chat" section. 4. **Chat with the Assistant**: Engage in interactive conversations with the AI assistant to get more insights or ask questions about specific safety measures. ## Requirements The application requires the following Python packages: - `os` - `base64` - `gradio` - `PIL` - `io` - `json` - `groq` - `logging` - `cv2` - `numpy` - `traceback` These dependencies can be installed using `pip` as shown in the installation instructions. ## Contributing Contributions are welcome! Feel free to submit pull requests, report bugs, or suggest improvements. ## License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. --- Built with ❤️ by [Your Name]