|
856 | 856 | "training_task = ee.batch.Export.table.toCloudStorage(\n",
|
857 | 857 | " collection=ee.FeatureCollection(train_features),\n",
|
858 | 858 | " description=\"Training image export\",\n",
|
859 |
| - " bucket=bucket,\n", |
| 859 | + " bucket=cloud_storage_bucket,\n", |
860 | 860 | " fileNamePrefix=\"geospatial_training\",\n",
|
861 | 861 | " selectors=BANDS + [LABEL],\n",
|
862 | 862 | " fileFormat=\"TFRecord\",\n",
|
|
867 | 867 | "validation_task = ee.batch.Export.table.toCloudStorage(\n",
|
868 | 868 | " collection=ee.FeatureCollection(validation_features),\n",
|
869 | 869 | " description=\"Validation image export\",\n",
|
870 |
| - " bucket=bucket,\n", |
| 870 | + " bucket=cloud_storage_bucket,\n", |
871 | 871 | " fileNamePrefix=\"geospatial_validation\",\n",
|
872 | 872 | " selectors= BANDS + [LABEL],\n",
|
873 | 873 | " fileFormat='TFRecord')\n",
|
|
928 | 928 | "source": [
|
929 | 929 | "from google.cloud import aiplatform\n",
|
930 | 930 | "\n",
|
931 |
| - "aiplatform.init(project=project, staging_bucket=bucket)\n", |
| 931 | + "aiplatform.init(project=project, staging_bucket=cloud_storage_bucket)\n", |
932 | 932 | "\n",
|
933 | 933 | "job = aiplatform.CustomTrainingJob(\n",
|
934 | 934 | " display_name=\"geospatial_model_training\",\n",
|
|
955 | 955 | },
|
956 | 956 | "outputs": [],
|
957 | 957 | "source": [
|
958 |
| - "model = job.run(accelerator_type='NVIDIA_TESLA_K80', accelerator_count=1, args=[f'--bucket={bucket}'])" |
| 958 | + "model = job.run(accelerator_type='NVIDIA_TESLA_K80', accelerator_count=1, args=[f'--bucket={cloud_storage_bucket}'])" |
959 | 959 | ]
|
960 | 960 | },
|
961 | 961 | {
|
|
1013 | 1013 | " --source=serving_app \\\n",
|
1014 | 1014 | " --command=\"gunicorn\" \\\n",
|
1015 | 1015 | " --args=\"--threads=8,--timeout=0,main:app\" \\\n",
|
1016 |
| - " --region=\"us-central1\" \\\n", |
| 1016 | + " --region=\"{region}\" \\\n", |
1017 | 1017 | " --memory=\"1G\" \\\n",
|
1018 | 1018 | " --no-allow-unauthenticated \\"
|
1019 | 1019 | ]
|
|
1246 | 1246 | "requests.post(\n",
|
1247 | 1247 | " url=f'{service_url}/predict',\n",
|
1248 | 1248 | " headers={'Authorization': f'Bearer {identity_token}'},\n",
|
1249 |
| - " json={'data': prediction_data, 'bucket': bucket},\n", |
| 1249 | + " json={'data': prediction_data, 'bucket': cloud_storage_bucket},\n", |
1250 | 1250 | ").json()['predictions']"
|
1251 | 1251 | ]
|
1252 | 1252 | },
|
|
1284 | 1284 | " result = requests.post(\n",
|
1285 | 1285 | " url=f'{service_url}/predict',\n",
|
1286 | 1286 | " headers={'Authorization': f'Bearer {identity_token}'},\n",
|
1287 |
| - " json={'data': prediction_data, 'bucket': bucket},).json()\n", |
| 1287 | + " json={'data': prediction_data, 'bucket': cloud_storage_bucket},).json()\n", |
1288 | 1288 | " return result['predictions']['predictions'][0][0][0][0]"
|
1289 | 1289 | ]
|
1290 | 1290 | },
|
|
0 commit comments