File size: 7,138 Bytes
cd62586
 
 
 
 
 
1791631
cd62586
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
---
title: Makerspace Inventory AI
emoji: πŸ”§
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: "5.50.0"
app_file: app.py
pinned: false
---

# πŸ”§ Makerspace Inventory Management System

An intelligent, AI-powered inventory management system designed for makerspaces, workshops, and educational facilities. This system combines computer vision, natural language processing, and optimization algorithms to streamline inventory tracking and improve workspace efficiency.

![Python](https://img.shields.io/badge/Python-3.10-blue)
![Gradio](https://img.shields.io/badge/Gradio-5.9-orange)
![License](https://img.shields.io/badge/License-MIT-green)

## 🌟 Features

### πŸ›’ **Smart Check-Out System**
- **AI-Powered Image Recognition**: Upload photos or use your webcam to automatically identify tools and equipment
- **Gemini Vision AI**: Utilizes Google's Gemini 2.5 Flash model for accurate item detection
- **Vector Search**: ChromaDB-powered semantic search for fuzzy matching between detected items and inventory
- **Real-time Inventory Updates**: Automatic quantity tracking and session logging
- **Multi-Item Support**: Scan multiple items in a single image

### πŸ“¦ **Intelligent Item Addition**
- **OCR Receipt Processing**: Upload PDF or image receipts to automatically extract items
- **Fuzzy Matching**: Smart name matching to find items even with typos or variations
- **Interactive Editing**: Review and modify detected items before adding to inventory
- **Manual Entry**: Quick single-item updates with auto-completion
- **Update History**: Complete audit trail of all inventory changes

### πŸ“Š **Data-Driven Layout Optimization**
- **Pattern Mining**: Discovers which items are frequently checked out together
- **Association Rules**: Calculates support, confidence, and lift metrics for item pairs
- **Distance Optimization**: Uses greedy relocation algorithm to minimize walking distance
- **Visual Analytics**: Side-by-side comparison of current vs. optimized layouts
- **Actionable Recommendations**: Specific move suggestions with quantified benefits

## πŸš€ How to Use

### Check Out Items
1. Click **"πŸ›’ Check Out Items"** on the main menu
2. Upload an image of items or use your webcam
   - Or manually type item names (comma-separated)
3. Review detected items and adjust quantities
4. Confirm checkout (optionally enter user ID)

### Add Items to Inventory
1. Click **"πŸ“¦ Add Items"** on the main menu
2. **Receipt Upload Tab**:
   - Upload a PDF or image receipt
   - Review extracted items
   - Check/uncheck items to include
   - Edit quantities if needed
   - Click "Apply Updates"
3. **Manual Entry Tab**:
   - Type item name
   - Enter quantity
   - Click "Add to Inventory"

### Analyze Layout Efficiency
1. Click **"πŸ“Š Inventory Analysis"** on the main menu
2. Adjust analysis parameters:
   - **Minimum Support**: Pattern frequency threshold (0.02 = 2%)
   - **Top K Pairs**: Number of frequent pairs to optimize (25)
   - **Maximum Moves**: Limit on relocations (10)
   - **Minimum Gain**: Distance improvement threshold (0.05 units)
3. Click "πŸ” Run Analysis"
4. Review:
   - Frequent item pairs
   - Relocation recommendations
   - Distance savings
   - Visual layout comparison

## πŸ“ˆ Key Metrics Explained

### **Support**
Frequency of items appearing together in checkout sessions
- Example: 0.10 = items appear together in 10% of checkouts

### **Lift**
How much more likely items are checked out together vs. randomly
- Lift > 1: Positive correlation (should be near each other)
- Lift = 2: Items are 2Γ— more likely to be checked out together

### **Confidence A→B**
Probability of checking out item B when checking out item A
- Example: 0.80 = 80% chance of checking B with A

### **Distance Saved**
Reduction in walking distance by relocating items
- Measured in grid units (1 unit β‰ˆ 1 meter)

## πŸ› οΈ Technology Stack

- **Frontend**: Gradio 5.9 (Interactive web interface)
- **AI/ML**:
  - Google Gemini 2.5 Flash (Vision AI for image recognition)
  - Sentence Transformers (Semantic embeddings)
  - ChromaDB (Vector database for similarity search)
- **OCR**: Tesseract + Pytesseract
- **Data Processing**: Pandas, NumPy
- **Optimization**: Custom greedy algorithm for layout optimization
- **Visualization**: Matplotlib
- **Fuzzy Matching**: RapidFuzz

## πŸ“‚ File Structure

```
.
β”œβ”€β”€ app.py                    # Main application file
β”œβ”€β”€ requirements.txt          # Python dependencies
β”œβ”€β”€ README.md                # This file
β”œβ”€β”€ items.csv                # Inventory database
β”œβ”€β”€ locations.csv            # Physical location grid
β”œβ”€β”€ checkouts.csv            # Checkout history
β”œβ”€β”€ update_log.csv           # Inventory update log
β”œβ”€β”€ screwdriver.png          # Example checkout image
└── mcmaster_receipt.pdf     # Example receipt
```

## πŸ”§ Local Setup

### Prerequisites
- Python 3.10 or higher
- Tesseract OCR installed on your system

### Installation

1. Clone the repository:
```bash
git clone <repository-url>
cd makerspace-inventory
```

2. Install system dependencies (Ubuntu/Debian):
```bash
sudo apt-get update
sudo apt-get install -y tesseract-ocr poppler-utils
```

3. Install Python dependencies:
```bash
pip install -r requirements.txt
```

4. Run the application:
```bash
python app.py
```

5. Open your browser to `http://localhost:7860`

### Environment Variables
The Gemini API key is currently hardcoded. For production use, set it as an environment variable:
```bash
export GEMINI_API_KEY="your-api-key-here"
```

## πŸ“Š Data Format

### items.csv
```csv
item_id,item_name,category,quantity,unit,description,location_id
I0001,Hex Key Set,Hand Tools,12,sets,Standard SAE hex key sets,L001
```

### locations.csv
```csv
location_id,x,y,capacity
L001,0,0,1
```

### checkouts.csv
```csv
timestamp,user_id,session_id,item_id
2025-12-05T10:30:00Z,U0001,S00001,I0001
```

## 🎯 Use Cases

- **Makerspaces & Fab Labs**: Track tools and equipment usage
- **Educational Workshops**: Monitor student equipment checkouts
- **Tool Libraries**: Manage community tool sharing
- **Research Labs**: Optimize equipment layout based on usage patterns
- **Manufacturing Facilities**: Improve tool room efficiency

## 🀝 Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

### Development Roadmap
- [ ] Barcode/QR code scanning
- [ ] User authentication system
- [ ] Advanced analytics dashboard
- [ ] Mobile app integration
- [ ] Multi-location support
- [ ] Automated reorder suggestions
- [ ] Integration with purchasing systems

## πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

## πŸ‘₯ Authors

Developed as part of a makerspace automation project.

## πŸ™ Acknowledgments

- Google Gemini AI for vision capabilities
- Anthropic Claude for development assistance
- Open-source community for amazing tools and libraries

## πŸ“ž Support

For questions, issues, or feature requests, please open an issue on GitHub or contact the development team.

---

**Built with ❀️ for makers, by makers**