File size: 32,302 Bytes
2ce4541
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Image Classification with Vertex AI – Step-by-Step Guide</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/atom-one-dark.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
    <script src="https://kit.fontawesome.com/3a5a3f1b9a.js" crossorigin="anonymous"></script>
    <style>
        .dark-mode {
            background-color: #1a202c;
            color: #f7fafc;
        }
        .dark-mode .card {
            background-color: #2d3748;
            border-color: #4a5568;
        }
        .dark-mode .navbar {
            background-color: #2d3748;
            border-color: #4a5568;
        }
        .dark-mode .footer {
            background-color: #2d3748;
            border-color: #4a5568;
        }
        .dark-mode .code-block {
            background-color: #282c34;
        }
        .dark-mode .section-icon {
            color: #63b3ed;
        }
    </style>
</head>
<body class="bg-gray-50 text-gray-800 font-sans">
    <!-- Navigation -->
    <nav class="navbar bg-white shadow-sm sticky top-0 z-50">
        <div class="container mx-auto px-4 py-3 flex justify-between items-center">
            <div class="flex items-center space-x-2">
                <i class="fas fa-robot text-blue-500 text-2xl"></i>
                <span class="text-xl font-bold">Vertex AI Guide</span>
            </div>
            <div class="flex items-center space-x-4">
                <a href="#home" class="hover:text-blue-500">Home</a>
                <a href="#prerequisites" class="hover:text-blue-500">Prerequisites</a>
                <a href="#tutorial" class="hover:text-blue-500">Tutorial</a>
                <a href="#resources" class="hover:text-blue-500">Resources</a>
                <button id="darkModeToggle" class="p-2 rounded-full hover:bg-gray-200 dark-mode:hover:bg-gray-700">
                    <i class="fas fa-moon"></i>
                </button>
            </div>
        </div>
    </nav>

    <!-- Hero Section -->
    <section id="home" class="py-16 bg-gradient-to-r from-blue-50 to-indigo-50 dark-mode:from-gray-800 dark-mode:to-gray-900">
        <div class="container mx-auto px-4">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-4xl md:text-5xl font-bold mb-6">Image Classification with Vertex AI</h1>
                <p class="text-xl mb-8">A step-by-step guide to training and deploying image classification models using Google Vertex AI AutoML Vision</p>
                <div class="flex justify-center space-x-4">
                    <a href="#tutorial" class="bg-blue-500 hover:bg-blue-600 text-white px-6 py-3 rounded-lg font-medium">Start Tutorial</a>
                    <a href="#prerequisites" class="bg-gray-200 hover:bg-gray-300 dark-mode:bg-gray-700 dark-mode:hover:bg-gray-600 text-gray-800 dark-mode:text-gray-200 px-6 py-3 rounded-lg font-medium">Prerequisites</a>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction -->
    <section class="py-12">
        <div class="container mx-auto px-4">
            <div class="max-w-3xl mx-auto">
                <div class="card bg-white p-8 rounded-lg shadow-sm border border-gray-200 mb-8">
                    <h2 class="text-2xl font-bold mb-4">Welcome to the Guide!</h2>
                    <p class="mb-4">This tutorial is designed for developers, data scientists, and students who want to learn how to build image classification models without deep machine learning expertise.</p>
                    <p class="mb-4">We'll use Google Vertex AI's AutoML Vision, which automates much of the model training process while still delivering high-quality results. No need to write complex neural network architectures!</p>
                    <p>By the end of this guide, you'll be able to:</p>
                    <ul class="list-disc pl-6 mt-2 space-y-1">
                        <li>Prepare image datasets for classification</li>
                        <li>Train custom models with AutoML Vision</li>
                        <li>Evaluate model performance</li>
                        <li>Deploy models to production endpoints</li>
                        <li>Make predictions using the Python SDK</li>
                    </ul>
                </div>
            </div>
        </div>
    </section>

    <!-- Prerequisites -->
    <section id="prerequisites" class="py-12 bg-gray-50 dark-mode:bg-gray-900">
        <div class="container mx-auto px-4">
            <div class="max-w-4xl mx-auto">
                <div class="flex items-center mb-8">
                    <i class="fas fa-clipboard-check section-icon text-3xl mr-4"></i>
                    <h2 class="text-3xl font-bold">Prerequisites</h2>
                </div>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-cloud mr-2 text-blue-500"></i> Google Cloud Account
                        </h3>
                        <p>You'll need a Google Cloud account with billing enabled. Vertex AI is a paid service, but new users get $300 in free credits.</p>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-project-diagram mr-2 text-blue-500"></i> Google Cloud Project
                        </h3>
                        <p>Create a new project or select an existing one in the Google Cloud Console where you'll enable the Vertex AI API.</p>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-plug mr-2 text-blue-500"></i> Vertex AI API Enabled
                        </h3>
                        <p>Enable the Vertex AI API for your project. This can be done in the "APIs & Services" section of the Cloud Console.</p>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-database mr-2 text-blue-500"></i> Cloud Storage Bucket
                        </h3>
                        <p>Create a Cloud Storage bucket to store your training data. The bucket should be in the same region where you'll train your model.</p>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-code mr-2 text-blue-500"></i> Python Environment
                        </h3>
                        <p>Set up a Python environment (3.7+) with the Google Cloud SDK installed. We recommend using a virtual environment.</p>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-key mr-2 text-blue-500"></i> Authentication
                        </h3>
                        <p>Set up authentication by creating a service account and downloading the JSON key file. Set the GOOGLE_APPLICATION_CREDENTIALS environment variable.</p>
                    </div>
                </div>
                
                <div class="mt-8 card bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                    <h3 class="text-xl font-semibold mb-3">Install Required Packages</h3>
                    <p class="mb-4">Install the Google Cloud Vertex AI SDK and other required packages:</p>
                    <pre class="code-block bg-gray-100 p-4 rounded-lg overflow-x-auto"><code class="language-bash">pip install google-cloud-aiplatform pandas</code></pre>
                </div>
            </div>
        </div>
    </section>

    <!-- Tutorial Steps -->
    <section id="tutorial" class="py-12">
        <div class="container mx-auto px-4">
            <div class="max-w-4xl mx-auto">
                <div class="flex items-center mb-8">
                    <i class="fas fa-graduation-cap section-icon text-3xl mr-4"></i>
                    <h2 class="text-3xl font-bold">Step-by-Step Tutorial</h2>
                </div>
                
                <!-- Step 1 -->
                <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200 mb-8">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-500 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">1</div>
                        <h3 class="text-2xl font-semibold">Dataset Preparation</h3>
                    </div>
                    
                    <p class="mb-4">For image classification with AutoML Vision, your dataset needs to be structured in a specific way:</p>
                    
                    <div class="mb-4">
                        <h4 class="font-semibold mb-2">Folder Structure:</h4>
                        <pre class="code-block bg-gray-100 p-4 rounded-lg overflow-x-auto"><code class="language-plaintext">gs://your-bucket-name/
    ├── train/
    │   ├── class1/
    │   │   ├── image1.jpg
    │   │   ├── image2.jpg
    │   │   └── ...
    │   ├── class2/
    │   │   ├── image1.jpg
    │   │   ├── image2.jpg
    │   │   └── ...
    │   └── ...
    └── test/
        ├── class1/
        ├── class2/
        └── ...</code></pre>
                    </div>
                    
                    <div class="mb-4">
                        <h4 class="font-semibold mb-2">Requirements:</h4>
                        <ul class="list-disc pl-6 space-y-1">
                            <li>Minimum 10 images per class (100+ recommended for better performance)</li>
                            <li>Images should be in JPEG or PNG format</li>
                            <li>Each image should be at least 800x600 pixels</li>
                            <li>Balance your dataset across classes</li>
                        </ul>
                    </div>
                    
                    <div>
                        <h4 class="font-semibold mb-2">Upload to Cloud Storage:</h4>
                        <p>Use the Google Cloud Console or gsutil command-line tool to upload your dataset:</p>
                        <pre class="code-block bg-gray-100 p-4 rounded-lg overflow-x-auto mt-2"><code class="language-bash">gsutil -m cp -r /path/to/local/dataset gs://your-bucket-name</code></pre>
                    </div>
                </div>
                
                <!-- Step 2 -->
                <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200 mb-8">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-500 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">2</div>
                        <h3 class="text-2xl font-semibold">Create a Vertex AI Dataset</h3>
                    </div>
                    
                    <p class="mb-4">Now we'll create a dataset resource in Vertex AI that points to your Cloud Storage data.</p>
                    
                    <div class="mb-4">
                        <h4 class="font-semibold mb-2">Using the Python SDK:</h4>
                        <pre class="code-block bg-gray-100 p-4 rounded-lg overflow-x-auto"><code class="language-python">from google.cloud import aiplatform

# Initialize the Vertex AI client
aiplatform.init(project="your-project-id", location="us-central1")

# Create an image dataset
dataset = aiplatform.ImageDataset.create(
    display_name="flowers-classification",
    gcs_source="gs://your-bucket-name/train/**",
    import_schema_uri=aiplatform.schema.dataset.ioformat.image.classification.single_label,
)

print(f"Created dataset: {dataset.resource_name}")</code></pre>
                    </div>
                    
                    <div>
                        <h4 class="font-semibold mb-2">Alternative: Using the Console</h4>
                        <ol class="list-decimal pl-6 space-y-1">
                            <li>Go to the Vertex AI section in Google Cloud Console</li>
                            <li>Navigate to "Datasets" and click "Create"</li>
                            <li>Select "Image classification (Single-label)"</li>
                            <li>Enter a name and select your region</li>
                            <li>Choose "Select import files from Cloud Storage" and enter your path (gs://your-bucket-name/train/**)</li>
                            <li>Click "Create"</li>
                        </ol>
                    </div>
                </div>
                
                <!-- Step 3 -->
                <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200 mb-8">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-500 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">3</div>
                        <h3 class="text-2xl font-semibold">Train the AutoML Model</h3>
                    </div>
                    
                    <p class="mb-4">With your dataset ready, you can now train an AutoML Vision model. This process will automatically:</p>
                    <ul class="list-disc pl-6 mb-4 space-y-1">
                        <li>Split your data into training/validation sets</li>
                        <li>Select the best model architecture</li>
                        <li>Tune hyperparameters</li>
                        <li>Train and evaluate the model</li>
                    </ul>
                    
                    <div class="mb-4">
                        <h4 class="font-semibold mb-2">Using the Python SDK:</h4>
                        <pre class="code-block bg-gray-100 p-4 rounded-lg overflow-x-auto"><code class="language-python"># Define training job
training_job = aiplatform.AutoMLImageTrainingJob(
    display_name="train-flowers-classification",
    prediction_type="classification",
    multi_label=False,
    model_type="CLOUD",
)

# Run the training job
model = training_job.run(
    dataset=dataset,
    training_fraction_split=0.8,
    validation_fraction_split=0.1,
    test_fraction_split=0.1,
    budget_milli_node_hours=8000,  # 8 compute hours
    disable_early_stopping=False,
)

print(f"Training completed. Model: {model.resource_name}")</code></pre>
                    </div>
                    
                    <div>
                        <h4 class="font-semibold mb-2">Training Considerations:</h4>
                        <ul class="list-disc pl-6 space-y-1">
                            <li><strong>Budget:</strong> More compute hours generally lead to better models (default is 8 hours)</li>
                            <li><strong>Model Type:</strong> "CLOUD" for best accuracy, "MOBILE" for edge deployment</li>
                            <li><strong>Monitoring:</strong> Track progress in the Vertex AI Console</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Step 4 -->
                <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200 mb-8">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-500 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">4</div>
                        <h3 class="text-2xl font-semibold">Evaluate the Model</h3>
                    </div>
                    
                    <p class="mb-4">After training completes, you'll want to evaluate the model's performance before deployment.</p>
                    
                    <div class="mb-4">
                        <h4 class="font-semibold mb-2">View Evaluation Metrics:</h4>
                        <pre class="code-block bg-gray-100 p-4 rounded-lg overflow-x-auto"><code class="language-python"># Get evaluation metrics
evaluation = model.evaluate()

print("Model evaluation metrics:")
print(f"Precision: {evaluation.metrics['precision']}")
print(f"Recall: {evaluation.metrics['recall']}")
print(f"F1 Score: {evaluation.metrics['f1Score']}")
print(f"Confusion Matrix: {evaluation.metrics['confusionMatrix']}")</code></pre>
                    </div>
                    
                    <div class="mb-4">
                        <h4 class="font-semibold mb-2">Key Metrics to Check:</h4>
                        <ul class="list-disc pl-6 space-y-1">
                            <li><strong>Precision:</strong> Percentage of correct positive predictions</li>
                            <li><strong>Recall:</strong> Percentage of actual positives correctly identified</li>
                            <li><strong>F1 Score:</strong> Harmonic mean of precision and recall</li>
                            <li><strong>Confusion Matrix:</strong> Shows performance per class</li>
                        </ul>
                    </div>
                    
                    <div>
                        <h4 class="font-semibold mb-2">Console Visualization:</h4>
                        <p>For a more visual evaluation, check the "Evaluate" tab in the Vertex AI Console where you can see:</p>
                        <ul class="list-disc pl-6 space-y-1">
                            <li>Precision-recall curves</li>
                            <li>Confusion matrix visualization</li>
                            <li>Example predictions with confidence scores</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Step 5 -->
                <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200 mb-8">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-500 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">5</div>
                        <h3 class="text-2xl font-semibold">Deploy the Model</h3>
                    </div>
                    
                    <p class="mb-4">To make predictions, you need to deploy your model to an endpoint. This creates a scalable service that can handle prediction requests.</p>
                    
                    <div class="mb-4">
                        <h4 class="font-semibold mb-2">Using the Python SDK:</h4>
                        <pre class="code-block bg-gray-100 p-4 rounded-lg overflow-x-auto"><code class="language-python"># Create an endpoint
endpoint = aiplatform.Endpoint.create(
    display_name="flowers-classification-endpoint",
    project="your-project-id",
    location="us-central1",
)

# Deploy the model to the endpoint
endpoint.deploy(
    model=model,
    deployed_model_display_name="flowers-classification-model",
    traffic_percentage=100,
    machine_type="n1-standard-4",  # Choose appropriate machine type
    min_replica_count=1,
    max_replica_count=1,
)

print(f"Model deployed to endpoint: {endpoint.resource_name}")</code></pre>
                    </div>
                    
                    <div>
                        <h4 class="font-semibold mb-2">Deployment Considerations:</h4>
                        <ul class="list-disc pl-6 space-y-1">
                            <li><strong>Machine Type:</strong> Choose based on expected traffic (n1-standard-2 for testing, larger for production)</li>
                            <li><strong>Scaling:</strong> Set min/max replicas for automatic scaling</li>
                            <li><strong>Cost:</strong> You're billed while the endpoint is running</li>
                            <li><strong>Undeploy:</strong> Remember to undeploy when not in use to avoid charges</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Step 6 -->
                <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-500 text-white rounded-full w-8 h-8 flex items-center justify-center mr-3">6</div>
                        <h3 class="text-2xl font-semibold">Make Predictions</h3>
                    </div>
                    
                    <p class="mb-4">With your model deployed to an endpoint, you can now make predictions on new images.</p>
                    
                    <div class="mb-4">
                        <h4 class="font-semibold mb-2">Using the Python SDK:</h4>
                        <pre class="code-block bg-gray-100 p-4 rounded-lg overflow-x-auto"><code class="language-python">import base64

# Function to encode image
def encode_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")

# Example prediction
image_path = "path/to/your/test_image.jpg"
encoded_image = encode_image(image_path)

# Make prediction
prediction = endpoint.predict(
    instances=[{"content": encoded_image}],
    parameters={"confidenceThreshold": 0.5},  # Minimum confidence score
)

# Process results
for result in prediction.predictions:
    print("Predicted classes:")
    for i, (label, score) in enumerate(zip(result["displayNames"], result["confidences"])):
        print(f"{i+1}. {label}: {score:.2%}")</code></pre>
                    </div>
                    
                    <div class="mb-4">
                        <h4 class="font-semibold mb-2">Alternative: Batch Prediction</h4>
                        <p>For predicting on many images at once, use batch prediction:</p>
                        <pre class="code-block bg-gray-100 p-4 rounded-lg overflow-x-auto"><code class="language-python"># Create batch prediction job
batch_job = model.batch_predict(
    job_display_name="batch-pred-flowers",
    gcs_source="gs://your-bucket-name/test/**",
    gcs_destination_prefix="gs://your-bucket-name/predictions/",
    instances_format="jsonl",
    predictions_format="jsonl",
)

print(f"Batch prediction job: {batch_job.resource_name}")</code></pre>
                    </div>
                    
                    <div>
                        <h4 class="font-semibold mb-2">Prediction Options:</h4>
                        <ul class="list-disc pl-6 space-y-1">
                            <li><strong>Online Prediction:</strong> Low-latency requests to the endpoint (good for real-time applications)</li>
                            <li><strong>Batch Prediction:</strong> Process many images at once (good for offline processing)</li>
                            <li><strong>Confidence Threshold:</strong> Filter predictions by minimum confidence score</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Useful Resources -->
    <section id="resources" class="py-12 bg-gray-50 dark-mode:bg-gray-900">
        <div class="container mx-auto px-4">
            <div class="max-w-4xl mx-auto">
                <div class="flex items-center mb-8">
                    <i class="fas fa-book section-icon text-3xl mr-4"></i>
                    <h2 class="text-3xl font-bold">Useful Resources</h2>
                </div>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-file-alt mr-2 text-blue-500"></i> Official Documentation
                        </h3>
                        <ul class="space-y-2">
                            <li><a href="https://cloud.google.com/vertex-ai" class="text-blue-500 hover:underline" target="_blank">Vertex AI Documentation</a></li>
                            <li><a href="https://cloud.google.com/vision/automl/docs" class="text-blue-500 hover:underline" target="_blank">AutoML Vision Documentation</a></li>
                            <li><a href="https://cloud.google.com/python/docs/reference/aiplatform/latest" class="text-blue-500 hover:underline" target="_blank">Python SDK Reference</a></li>
                        </ul>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-video mr-2 text-blue-500"></i> Tutorials & Videos
                        </h3>
                        <ul class="space-y-2">
                            <li><a href="https://www.youtube.com/watch?v=zTz8w7Z8Q8I" class="text-blue-500 hover:underline" target="_blank">Vertex AI AutoML Vision Demo</a></li>
                            <li><a href="https://cloud.google.com/blog/topics/developers-practitioners/getting-started-vertex-ai" class="text-blue-500 hover:underline" target="_blank">Getting Started with Vertex AI</a></li>
                            <li><a href="https://cloud.google.com/ai-platform-unified/docs/tutorials" class="text-blue-500 hover:underline" target="_blank">Official Tutorials</a></li>
                        </ul>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-dollar-sign mr-2 text-blue-500"></i> Pricing & Quotas
                        </h3>
                        <ul class="space-y-2">
                            <li><a href="https://cloud.google.com/vertex-ai/pricing" class="text-blue-500 hover:underline" target="_blank">Vertex AI Pricing</a></li>
                            <li><a href="https://cloud.google.com/vertex-ai/docs/general/quotas" class="text-blue-500 hover:underline" target="_blank">Service Quotas</a></li>
                            <li><a href="https://cloud.google.com/free" class="text-blue-500 hover:underline" target="_blank">Free Tier Information</a></li>
                        </ul>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-users mr-2 text-blue-500"></i> Community Resources
                        </h3>
                        <ul class="space-y-2">
                            <li><a href="https://stackoverflow.com/questions/tagged/google-cloud-vertex-ai" class="text-blue-500 hover:underline" target="_blank">Stack Overflow</a></li>
                            <li><a href="https://github.com/GoogleCloudPlatform/vertex-ai-samples" class="text-blue-500 hover:underline" target="_blank">GitHub Samples</a></li>
                            <li><a href="https://groups.google.com/g/google-cloud-ai" class="text-blue-500 hover:underline" target="_blank">Google Group</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="footer bg-white py-8 border-t border-gray-200">
        <div class="container mx-auto px-4">
            <div class="max-w-4xl mx-auto">
                <div class="flex flex-col md:flex-row justify-between items-center">
                    <div class="mb-4 md:mb-0">
                        <div class="flex items-center space-x-2">
                            <i class="fas fa-robot text-blue-500 text-2xl"></i>
                            <span class="text-xl font-bold">Vertex AI Guide</span>
                        </div>
                        <p class="text-gray-600 mt-2">A step-by-step tutorial for image classification with Vertex AI</p>
                    </div>
                    <div class="flex space-x-4">
                        <a href="#" class="text-gray-600 hover:text-blue-500"><i class="fab fa-github text-xl"></i></a>
                        <a href="#" class="text-gray-600 hover:text-blue-500"><i class="fab fa-twitter text-xl"></i></a>
                        <a href="#" class="text-gray-600 hover:text-blue-500"><i class="fab fa-linkedin text-xl"></i></a>
                    </div>
                </div>
                <div class="mt-8 text-center text-gray-500 text-sm">
                    <p>This is an educational resource and not officially affiliated with Google Cloud.</p>
                    <p class="mt-2">© 2023 Vertex AI Guide. All rights reserved.</p>
                </div>
            </div>
        </div>
    </footer>

    <script>
        // Initialize syntax highlighting
        document.addEventListener('DOMContentLoaded', (event) => {
            document.querySelectorAll('pre code').forEach((block) => {
                hljs.highlightElement(block);
            });
        });

        // Dark mode toggle
        const darkModeToggle = document.getElementById('darkModeToggle');
        const html = document.documentElement;
        
        // Check for saved user preference
        const userPrefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
        const currentTheme = localStorage.getItem('theme');
        
        if (currentTheme === 'dark' || (!currentTheme && userPrefersDark)) {
            html.classList.add('dark-mode');
            darkModeToggle.innerHTML = '<i class="fas fa-sun"></i>';
        }
        
        darkModeToggle.addEventListener('click', () => {
            if (html.classList.contains('dark-mode')) {
                html.classList.remove('dark-mode');
                localStorage.setItem('theme', 'light');
                darkModeToggle.innerHTML = '<i class="fas fa-moon"></i>';
            } else {
                html.classList.add('dark-mode');
                localStorage.setItem('theme', 'dark');
                darkModeToggle.innerHTML = '<i class="fas fa-sun"></i>';
            }
        });
        
        // Smooth scrolling for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=mohpython/mohpython-vertex-ai" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>