|
60 | 60 | },
|
61 | 61 | {
|
62 | 62 | "cell_type": "code",
|
63 |
| - "execution_count": 3, |
| 63 | + "execution_count": null, |
64 | 64 | "metadata": {},
|
65 | 65 | "outputs": [],
|
66 | 66 | "source": [
|
|
81 | 81 | "client = AzureContentUnderstandingClient(\n",
|
82 | 82 | " endpoint=os.getenv(\"AZURE_AI_ENDPOINT\"),\n",
|
83 | 83 | " api_version=os.getenv(\"AZURE_AI_API_VERSION\", \"2024-12-01-preview\"),\n",
|
84 |
| - " subscription_key=os.getenv(\"AZURE_AI_API_KEY\"),\n", |
85 |
| - " api_token=os.getenv(\"AZURE_AI_API_TOKEN\"),\n", |
86 | 84 | " x_ms_useragent=\"azure-ai-content-understanding-python/analyzer_training\",\n",
|
87 | 85 | ")"
|
88 | 86 | ]
|
|
99 | 97 | },
|
100 | 98 | {
|
101 | 99 | "cell_type": "code",
|
102 |
| - "execution_count": null, |
| 100 | + "execution_count": 4, |
103 | 101 | "metadata": {},
|
104 |
| - "outputs": [], |
| 102 | + "outputs": [ |
| 103 | + { |
| 104 | + "name": "stderr", |
| 105 | + "output_type": "stream", |
| 106 | + "text": [ |
| 107 | + "INFO:python.content_understanding_client:Analyzer train-sample-18473b27-6d27-4d51-8906-9e341ad3fb59 create request accepted.\n", |
| 108 | + "INFO:python.content_understanding_client:Request 7a0f7689-2b41-4a5e-96bc-c7ef8cb72c5e in progress ...\n", |
| 109 | + "INFO:python.content_understanding_client:Request 7a0f7689-2b41-4a5e-96bc-c7ef8cb72c5e in progress ...\n", |
| 110 | + "INFO:python.content_understanding_client:Request 7a0f7689-2b41-4a5e-96bc-c7ef8cb72c5e in progress ...\n", |
| 111 | + "INFO:python.content_understanding_client:Request 7a0f7689-2b41-4a5e-96bc-c7ef8cb72c5e in progress ...\n", |
| 112 | + "INFO:python.content_understanding_client:Request 7a0f7689-2b41-4a5e-96bc-c7ef8cb72c5e in progress ...\n", |
| 113 | + "INFO:python.content_understanding_client:Request result is ready after 13.72 seconds.\n", |
| 114 | + "INFO:root:Here is the analyzer detail for train-sample-18473b27-6d27-4d51-8906-9e341ad3fb59\n", |
| 115 | + "INFO:root:{\n", |
| 116 | + " \"id\": \"7a0f7689-2b41-4a5e-96bc-c7ef8cb72c5e\",\n", |
| 117 | + " \"status\": \"Succeeded\",\n", |
| 118 | + " \"result\": {\n", |
| 119 | + " \"analyzerId\": \"train-sample-18473b27-6d27-4d51-8906-9e341ad3fb59\",\n", |
| 120 | + " \"description\": \"Extract useful information from purchase order\",\n", |
| 121 | + " \"createdAt\": \"2024-12-09T23:58:59Z\",\n", |
| 122 | + " \"lastModifiedAt\": \"2024-12-09T23:59:14Z\",\n", |
| 123 | + " \"config\": {\n", |
| 124 | + " \"returnDetails\": false,\n", |
| 125 | + " \"enableOcr\": true,\n", |
| 126 | + " \"enableLayout\": true,\n", |
| 127 | + " \"enableBarcode\": false,\n", |
| 128 | + " \"enableFormula\": false\n", |
| 129 | + " },\n", |
| 130 | + " \"fieldSchema\": {\n", |
| 131 | + " \"fields\": {\n", |
| 132 | + " \"PurchaseOrderNumber\": {\n", |
| 133 | + " \"type\": \"string\",\n", |
| 134 | + " \"method\": \"extract\",\n", |
| 135 | + " \"description\": \"\"\n", |
| 136 | + " },\n", |
| 137 | + " \"PurchaseDate\": {\n", |
| 138 | + " \"type\": \"date\",\n", |
| 139 | + " \"method\": \"extract\",\n", |
| 140 | + " \"description\": \"\"\n", |
| 141 | + " },\n", |
| 142 | + " \"TotalPayment\": {\n", |
| 143 | + " \"type\": \"number\",\n", |
| 144 | + " \"method\": \"extract\",\n", |
| 145 | + " \"description\": \"\"\n", |
| 146 | + " },\n", |
| 147 | + " \"ShippedToAddress\": {\n", |
| 148 | + " \"type\": \"string\",\n", |
| 149 | + " \"method\": \"extract\",\n", |
| 150 | + " \"description\": \"\"\n", |
| 151 | + " }\n", |
| 152 | + " }\n", |
| 153 | + " },\n", |
| 154 | + " \"trainingData\": {\n", |
| 155 | + " \"containerUrl\": \"https://chethodevusw2.blob.core.windows.net/test?sv=2023-01-03&st=2024-12-09T19%3A27%3A04Z&se=2024-12-10T19%3A27%3A04Z&skoid=4de42c4d-0fe6-4b96-93a4-161b1303ea3b&sktid=72f988bf-86f1-41af-91ab-2d7cd011db47&skt=2024-12-09T19%3A27%3A04Z&ske=2024-12-10T19%3A27%3A04Z&sks=b&skv=2023-01-03&sr=c&sp=rl&sig=sbUVLXK2JfJdUG7Fxyakg1e9lR%2B%2B6oMISoZqfudtvgw%3D\",\n", |
| 156 | + " \"kind\": \"blob\",\n", |
| 157 | + " \"prefix\": \"train\"\n", |
| 158 | + " },\n", |
| 159 | + " \"warnings\": [],\n", |
| 160 | + " \"status\": \"ready\",\n", |
| 161 | + " \"scenario\": \"document\"\n", |
| 162 | + " }\n", |
| 163 | + "}\n" |
| 164 | + ] |
| 165 | + } |
| 166 | + ], |
105 | 167 | "source": [
|
106 | 168 | "import uuid\n",
|
107 | 169 | "ANALYZER_ID = \"train-sample-\" + str(uuid.uuid4())\n",
|
108 | 170 | "\n",
|
109 | 171 | "response = client.begin_create_analyzer(\n",
|
110 | 172 | " ANALYZER_ID,\n",
|
111 |
| - " analyzer_schema_path=analyzer_template,\n", |
| 173 | + " analyzer_template_path=analyzer_template,\n", |
112 | 174 | " training_storage_container_sas_url=os.getenv(\"TRAINING_DATA_SAS_URL\"),\n",
|
113 | 175 | " training_storage_container_path_prefix=os.getenv(\"TRAINING_DATA_PATH\"),\n",
|
114 | 176 | ")\n",
|
|
139 | 201 | "name": "stderr",
|
140 | 202 | "output_type": "stream",
|
141 | 203 | "text": [
|
142 |
| - "INFO:python.content_understanding_client:Analyzing file ../data/purchase_order.jpg with analyzer: train-sample-3292ff56-bc75-4bf0-8a09-8aa866d8553f\n", |
143 |
| - "INFO:python.content_understanding_client:Request 9ed825c9-551e-45e2-8ec0-1ae555bcd56f in progress ...\n", |
144 |
| - "INFO:python.content_understanding_client:Request 9ed825c9-551e-45e2-8ec0-1ae555bcd56f in progress ...\n", |
145 |
| - "INFO:python.content_understanding_client:Request 9ed825c9-551e-45e2-8ec0-1ae555bcd56f in progress ...\n", |
146 |
| - "INFO:python.content_understanding_client:Request 9ed825c9-551e-45e2-8ec0-1ae555bcd56f in progress ...\n", |
147 |
| - "INFO:python.content_understanding_client:Request result is ready after 11.27 seconds.\n", |
| 204 | + "INFO:python.content_understanding_client:Analyzing file ../data/purchase_order.jpg with analyzer: train-sample-18473b27-6d27-4d51-8906-9e341ad3fb59\n", |
| 205 | + "INFO:python.content_understanding_client:Request dced30f5-bb4d-473b-8b7a-13a7e29ed3ac in progress ...\n", |
| 206 | + "INFO:python.content_understanding_client:Request dced30f5-bb4d-473b-8b7a-13a7e29ed3ac in progress ...\n", |
| 207 | + "INFO:python.content_understanding_client:Request result is ready after 5.52 seconds.\n", |
148 | 208 | "INFO:root:{\n",
|
149 |
| - " \"id\": \"9ed825c9-551e-45e2-8ec0-1ae555bcd56f\",\n", |
| 209 | + " \"id\": \"dced30f5-bb4d-473b-8b7a-13a7e29ed3ac\",\n", |
150 | 210 | " \"status\": \"Succeeded\",\n",
|
151 | 211 | " \"result\": {\n",
|
152 |
| - " \"analyzerId\": \"train-sample-3292ff56-bc75-4bf0-8a09-8aa866d8553f\",\n", |
| 212 | + " \"analyzerId\": \"train-sample-18473b27-6d27-4d51-8906-9e341ad3fb59\",\n", |
153 | 213 | " \"apiVersion\": \"2024-12-01-preview\",\n",
|
154 |
| - " \"createdAt\": \"2024-12-09T19:42:58Z\",\n", |
| 214 | + " \"createdAt\": \"2024-12-09T23:59:16Z\",\n", |
155 | 215 | " \"warnings\": [],\n",
|
156 | 216 | " \"contents\": [\n",
|
157 | 217 | " {\n",
|
|
253 | 313 | "name": "stderr",
|
254 | 314 | "output_type": "stream",
|
255 | 315 | "text": [
|
256 |
| - "INFO:python.content_understanding_client:Analyzer train-sample-3292ff56-bc75-4bf0-8a09-8aa866d8553f deleted.\n" |
| 316 | + "INFO:python.content_understanding_client:Analyzer train-sample-18473b27-6d27-4d51-8906-9e341ad3fb59 deleted.\n" |
257 | 317 | ]
|
258 | 318 | },
|
259 | 319 | {
|
|
0 commit comments