capradeepgujaran commited on
Commit
e95d9e4
1 Parent(s): 1ded730

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +75 -14
README.md CHANGED
@@ -1,14 +1,75 @@
1
- ---
2
- title: AI-Powered Snag Tool
3
- emoji: 🌖
4
- colorFrom: purple
5
- colorTo: red
6
- sdk: gradio
7
- sdk_version: 5.1.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- short_description: Process image using Llama 3.2 and provide snag details
12
- ---
13
-
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Construction Image Analyzer with Chat
2
+
3
+ ### Overview
4
+ This project is a web application built using Gradio that allows users to upload construction site images and receive automated analysis and suggestions for improvement. The application utilizes the Groq AI platform to process and interpret the images, providing detailed insights and actionable steps.
5
+
6
+ ### Features
7
+ 1. **Image Upload**: Users can upload construction site images directly through the web interface.
8
+ 2. **Automated Analysis**: The application uses advanced machine learning models to identify potential issues within the images, categorize them, and provide descriptions along with step-by-step solutions.
9
+ 3. **Interactive Chat**: Users can ask follow-up questions based on the initial analysis, and receive real-time responses from the AI assistant.
10
+ 4. **Logging and Error Handling**: Comprehensive logging and error handling ensure robust operation and easy troubleshooting.
11
+
12
+ ### Installation
13
+ To run this application, you need to have Python installed on your system. Follow these steps to install the required dependencies:
14
+
15
+ ```bash
16
+ pip install gradio pillow base64 io json groq logging
17
+ ```
18
+
19
+ Additionally, you will need to obtain a `GROQ_API_KEY` from the Groq platform and set it as an environment variable:
20
+
21
+ ```bash
22
+ export GROQ_API_KEY=your_groq_api_key_here
23
+ ```
24
+
25
+ ### Usage
26
+ 1. **Launch the Application**:
27
+ Run the main script to start the Gradio interface:
28
+
29
+ ```bash
30
+ python your_script_name.py
31
+ ```
32
+
33
+ 2. **Access the Interface**:
34
+ Open a web browser and navigate to `http://localhost:7860`. You should see the Construction Image Analyzer interface.
35
+
36
+ 3. **Upload an Image**:
37
+ - Click on the "Upload Construction Image" button.
38
+ - Select or drag-and-drop an image file from your local machine.
39
+
40
+ 4. **Receive Analysis**:
41
+ - Once the image is uploaded, click the "Analyze Image" button.
42
+ - The application will display the analyzed results, including identified issues, categories, and suggested steps.
43
+
44
+ 5. **Interact via Chat**:
45
+ - Use the text box below the chatbot to ask additional questions related to the image analysis.
46
+ - The AI assistant will respond in real-time with relevant information.
47
+
48
+ ### Code Explanation
49
+
50
+ #### Imports
51
+ The code imports necessary libraries and modules, including Gradio for the web interface, Pillow for image processing, and Groq for AI inference.
52
+
53
+ #### Logging Setup
54
+ Logging is configured to capture debug and error messages, which helps in monitoring and debugging the application.
55
+
56
+ #### Environment Variable Check
57
+ The script checks if the `GROQ_API_KEY` is set in the environment variables. If not, it logs an error and raises a `ValueError`.
58
+
59
+ #### Image Encoding Function
60
+ The `encode_image` function converts an image (either a file path or a PIL Image object) to a Base64-encoded string.
61
+
62
+ #### Image Analysis Function
63
+ The `analyze_construction_image` function handles the image analysis process. It encodes the image, sends it to the Groq API for analysis, and processes the response to extract and format the results.
64
+
65
+ #### Chat Function
66
+ The `chat_about_image` function enables interactive chatting with the AI assistant. It constructs a conversation history and makes API calls to receive responses.
67
+
68
+ #### Gradio Interface
69
+ The Gradio interface is created with components for uploading images, displaying analysis results, and interacting via chat. Events are linked to the corresponding functions to handle user actions.
70
+
71
+ #### Main Execution
72
+ The script launches the Gradio interface when executed directly.
73
+
74
+ ### Conclusion
75
+ This project provides a powerful tool for construction site managers and inspectors to quickly assess and improve the quality of construction sites. By leveraging AI technology, it simplifies the inspection process and ensures timely resolution of potential issues.