File size: 6,422 Bytes
8eab354
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# InklyAI Running Guide

## 🎯 **Complete Guide to Running InklyAI**

This guide covers all the different ways to run InklyAI, from quick demos to production deployments.

## ⚑ **Quick Start (30 seconds)**

```bash
# Install dependencies
pip install -r requirements.txt

# Start web UI
python web_app.py

# Open http://localhost:8080 in your browser
```

## 🌐 **1. Web UI Mode** (Interactive Interface)

### **Start Web Application**
```bash
python web_app.py
```

### **Access Points**
- **Main Interface**: http://localhost:8080
- **Agent Management**: http://localhost:8080/agents
- **API Health**: http://localhost:8080/api/health

### **Features**
- βœ… Drag & drop signature upload
- βœ… Real-time verification results
- βœ… Agent management dashboard
- βœ… Live statistics and monitoring
- βœ… Mobile-responsive design
- βœ… Professional agent naming (Agent_01, Agent_02, etc.)

### **Demo Mode**
```bash
python demo_web_ui.py
```
Automatically starts server and opens browser.

## πŸ–₯️ **2. Standalone Mode** (Command Line)

### **Main Demo**
```bash
python demo.py
```
Runs the complete signature verification demo with sample data.

### **AgentAI Integration Test**
```bash
python simple_agentai_test.py
```
Tests the AgentAI integration functionality.

### **Web UI Test**
```bash
python test_web_ui.py
```
Tests the web UI functionality.

### **Jupyter Notebook**
```bash
jupyter notebook notebooks/signature_verification_demo.ipynb
```
Interactive notebook for analysis and experimentation.

### **Python Script Usage**
```python
from src.models.siamese_network import SignatureVerifier

# Initialize verifier
verifier = SignatureVerifier()

# Verify signatures
similarity, is_genuine = verifier.verify_signatures(
    "signature1.png", 
    "signature2.png", 
    threshold=0.5
)

print(f"Similarity: {similarity:.3f}")
print(f"Genuine: {is_genuine}")
```

## πŸ€– **3. AgentAI Integration Mode** (Production)

### **REST API Server**
```bash
python flask_api.py
```
Starts the production-ready API server.

### **AgentAI Integration**
```python
from agentai_integration import AgentAISignatureManager

# Initialize signature manager
signature_manager = AgentAISignatureManager(threshold=0.75)

# Register agent
signature_manager.register_agent_signature("Agent_01", "template.png")

# Verify signature
result = signature_manager.verify_agent_signature("Agent_01", "signature.png")
print(f"Verified: {result.is_verified}")
```

### **API Endpoints**
- `POST /api/verify` - Verify two signatures
- `POST /api/verify-agent` - Verify against agent template
- `GET /api/agents` - List registered agents
- `POST /api/register-agent` - Register new agent
- `GET /api/stats` - Get verification statistics

## 🎯 **Choosing the Right Mode**

### **Web UI Mode** - Best for:
- Interactive demonstrations
- Testing and development
- Non-technical users
- Quick signature verification
- Agent management tasks

### **Standalone Mode** - Best for:
- Command-line operations
- Automated scripts
- Integration testing
- Development and debugging
- Jupyter notebook analysis

### **AgentAI Integration Mode** - Best for:
- Production deployments
- Multi-agent systems
- High-volume processing
- Enterprise applications
- API-based integrations

## πŸ“Š **Performance Comparison**

| Mode | Response Time | Throughput | Use Case |
|------|---------------|------------|----------|
| Web UI | < 100ms | 100+ req/min | Interactive use |
| Standalone | < 50ms | 1000+ req/min | Batch processing |
| AgentAI API | < 75ms | 500+ req/min | Production systems |

## πŸ”§ **Configuration Options**

### **Environment Variables**
```bash
export PORT=8080              # Web server port
export DEBUG=False            # Debug mode
export THRESHOLD=0.75         # Verification threshold
```

### **Command Line Options**
```bash
# Custom port
python web_app.py --port 9000

# Debug mode
python web_app.py --debug

# Custom threshold
python simple_agentai_test.py --threshold 0.8
```

## πŸš€ **Production Deployment**

### **Using Gunicorn**
```bash
gunicorn -w 4 -b 0.0.0.0:8080 web_app:app
```

### **Using Docker**
```bash
# Build image
docker build -t inklyai .

# Run container
docker run -p 8080:8080 inklyai
```

### **Using Systemd**
```ini
[Unit]
Description=InklyAI Web Application
After=network.target

[Service]
Type=simple
User=inklyai
WorkingDirectory=/opt/inklyai
ExecStart=/opt/inklyai/venv/bin/python web_app.py
Restart=always

[Install]
WantedBy=multi-user.target
```

## πŸ› **Troubleshooting**

### **Common Issues**

#### **Port Already in Use**
```bash
# Kill process using port 8080
lsof -ti:8080 | xargs kill -9

# Or use different port
python web_app.py --port 9000
```

#### **Module Import Errors**
```bash
# Install dependencies
pip install -r requirements.txt

# Check Python path
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
```

#### **File Upload Errors**
- Check file size (max 16MB)
- Verify file type (images only)
- Ensure upload directory exists
- Check file permissions

### **Debug Mode**
```bash
# Enable debug logging
export DEBUG=True
python web_app.py
```

## πŸ“ˆ **Monitoring & Logs**

### **View Logs**
```bash
# Web application logs
tail -f logs/web_app.log

# AgentAI integration logs
tail -f logs/agentai.log

# All logs
tail -f logs/*.log
```

### **Health Checks**
```bash
# Check web server health
curl http://localhost:8080/api/health

# Check agent status
curl http://localhost:8080/api/agents

# Check statistics
curl http://localhost:8080/api/stats
```

## πŸŽ‰ **Success Indicators**

### **Web UI Running Successfully**
- βœ… Server starts without errors
- βœ… Browser opens to http://localhost:8080
- βœ… Agent dropdown shows Agent_01, Agent_02, etc.
- βœ… File upload works
- βœ… Verification returns results

### **Standalone Mode Working**
- βœ… Demo runs without errors
- βœ… Sample signatures load
- βœ… Verification completes
- βœ… Results display correctly

### **AgentAI Integration Active**
- βœ… API server responds
- βœ… Agents can be registered
- βœ… Signatures can be verified
- βœ… Statistics are tracked

## πŸš€ **Next Steps**

1. **Explore the Web UI** - Try uploading signatures
2. **Test Agent Management** - Register new agents
3. **Run Integration Tests** - Verify all functionality
4. **Deploy to Production** - Use the API mode
5. **Monitor Performance** - Check logs and statistics

**InklyAI is now ready for use in any mode you choose! πŸŽ‰**