Skip to content

Commit 44f6f75

Browse files
authored
Create README.md
1 parent 762233c commit 44f6f75

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

README.md

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# MathCanvas
2+
3+
This project is designed to analyze mathematical expressions from images and interpret drawings using AI-powered tools. By leveraging Google’s Generative AI (Gemini) and other tools, the application provides capabilities for solving mathematical problems and generating insightful descriptions of drawings. The project also includes functionality to create AI-generated images based on specified attributes, context, and style notes.
4+
5+
---
6+
7+
## Features
8+
9+
### 1. **Mathematical Expression Analysis**
10+
- Detect and solve mathematical expressions from input images.
11+
- Handle variable assignments, systems of equations, and abstract mathematical problems.
12+
- Support PEMDAS rule for accurate computations.
13+
14+
### 2. **Drawing Interpretation**
15+
- Identify primary objects and themes in drawings.
16+
- Provide detailed attributes, contextual descriptions, and stylistic notes.
17+
- Deliver results in a structured, easy-to-parse format.
18+
19+
### 3. **AI-Generated Images**
20+
- Generate high-quality images based on user-defined attributes, primary objects, context, and style.
21+
- Utilize advanced prompts for enhanced realism, detail, and resolution.
22+
23+
---
24+
25+
## Technologies Used
26+
27+
- **Python**: Core programming language for implementation.
28+
- **Google Generative AI (Gemini)**: AI-powered model for analyzing and interpreting inputs.
29+
- **Pillow**: Library for handling image processing tasks.
30+
- **dotenv**: Environment variable management.
31+
- **Requests**: HTTP requests for external API calls.
32+
33+
---
34+
35+
## Installation and Setup
36+
37+
### Prerequisites
38+
1. Python 3.7 or later
39+
2. A valid Google Generative AI (Gemini) API key
40+
41+
### Steps
42+
1. Clone the repository:
43+
```bash
44+
git clone <repository_url>
45+
cd <repository_name>
46+
```
47+
2. Create a `.env` file in the project root and add your Gemini API key:
48+
```env
49+
GEMINI_API_KEY=your_api_key_here
50+
```
51+
3. Install dependencies:
52+
```bash
53+
pip install -r requirements.txt
54+
```
55+
56+
---
57+
58+
## Usage
59+
60+
### 1. **Analyze Mathematical Expressions**
61+
```python
62+
from PIL import Image
63+
64+
dict_of_vars = {"x": 5, "y": 10}
65+
img = Image.open("path_to_math_image.jpg")
66+
result = analyze_image(img, dict_of_vars)
67+
print(result)
68+
```
69+
70+
### 2. **Understand Drawings**
71+
```python
72+
from PIL import Image
73+
74+
dict_of_vars = {}
75+
img = Image.open("path_to_drawing.jpg")
76+
result = understand_image(img, dict_of_vars)
77+
print(result)
78+
```
79+
80+
### 3. **Generate AI-Driven Images**
81+
```python
82+
image = generate_image(
83+
attributes="tall and ancient",
84+
primary_object="tree",
85+
context="in a foggy forest",
86+
style_notes="sketched with charcoal on canvas"
87+
)
88+
if image:
89+
image.show()
90+
image.save("output_image.jpg")
91+
```
92+
93+
---
94+
95+
## Project Structure
96+
```
97+
.
98+
├── analyze_image.py # Module for analyzing math expressions from images
99+
├── understand_image.py # Module for interpreting drawings
100+
├── generate_image.py # Module for generating AI-driven images
101+
├── requirements.txt # List of project dependencies
102+
├── .env # Environment variables
103+
├── README.md # Project documentation
104+
└── images/ # Folder for storing input/output images
105+
```
106+
107+
---
108+
109+
## API Documentation
110+
111+
### `analyze_image(img: Image, dict_of_vars: dict)`
112+
- **Input**:
113+
- `img`: An image object containing a mathematical expression.
114+
- `dict_of_vars`: Dictionary of variable assignments.
115+
- **Output**: A list of dictionaries with results.
116+
117+
### `understand_image(img: Image, dict_of_vars: dict)`
118+
- **Input**:
119+
- `img`: An image object of a drawing.
120+
- `dict_of_vars`: Optional dictionary for variable interpretation.
121+
- **Output**: A list of dictionaries describing the drawing.
122+
123+
### `generate_image(attributes: str, primary_object: str, context: str, style_notes: str)`
124+
- **Input**: Attributes, primary object, context, and style notes.
125+
- **Output**: A generated high-quality image.
126+
127+
---
128+
129+
## Example Scenarios
130+
131+
### 1. **Mathematical Problem-Solving**
132+
Upload an image containing equations or expressions, and the tool will return step-by-step solutions.
133+
134+
### 2. **Drawing Analysis**
135+
Provide a sketch or illustration, and the tool will describe the objects, context, and artistic style.
136+
137+
### 3. **Creative Image Generation**
138+
Define attributes and context for generating photorealistic or stylistic images.
139+
140+
---
141+
142+
## Acknowledgments
143+
- Google Generative AI (Gemini)
144+
- OpenAI
145+
- Python Community

0 commit comments

Comments
 (0)