Skip to content

Commit 50b3814

Browse files
changjian-wangChangjian Wang
andauthored
Update the samples for 2025-05-01-preview API (#30)
* Update samples and apiversion to 2025-05-01-preview. * Remove unnecessary properties and sample code block. * Update variable ANALYZER_ID. * Fix bugs and improve the readme.md. * Fix bugs and improve the README.md. * Remove output. * Improve README.md * Remove useless characters. * Remove useless printf() and restore part of 'create analyzer'. * Improve README.md * Improve README.md * Improve README.md * Remove test person id and with "existing_person_id" to replace. * Remove test guid and use existing_person_id to replace. * Improve README.md on updating the usage of 'CUSTOM_ANALYZER_ID'. * Improve README.md and notebook's description. * Improve README.md and fix issues of `conversational_field_extraction.ipynb` * Improve texts of README.md and management.ipynb. * Update baseAnalyzerId. * Remove 'chart' line from field_extraction.ipynb. * add "segmentationMode": "noSegmentation" in market_video.json config section --------- Co-authored-by: Changjian Wang <[email protected]>
1 parent 3788347 commit 50b3814

25 files changed

+223
-146
lines changed

README.md

Lines changed: 82 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,71 @@
22

33
Welcome! Content Understanding is a solution that analyzes and comprehends various media content, such as **documents, images, audio, and video**, transforming it into structured, organized, and searchable data.
44

5-
- The samples in this repository default to the latest preview API version: **(2024-12-01-preview)**.
6-
7-
## Features
8-
9-
Azure AI Content Understanding is a new Generative AI-based [Azure AI service](https://learn.microsoft.com/en-us/azure/ai-services/content-understanding/overview), designed to process/ingest content of any type (documents, images, audio, and video) into a user-defined output format. Content Understanding offers a streamlined process to reason over large amounts of unstructured data, accelerating time-to-value by generating an output that can be integrated into automation and analytical workflows.
10-
11-
## Samples
12-
13-
| File | Description |
14-
| --- | --- |
15-
| [content_extraction.ipynb](notebooks/content_extraction.ipynb) | In this sample we will show content understanding API can help you get semantic information from your file. For example OCR with table in document, audio transcription, and face analysis in video. |
16-
| [field_extraction.ipynb](notebooks/field_extraction.ipynb) | In this sample we will show how to create an analyzer to extract fields in your file. For example invoice amount in the document, how many people in an image, names mentioned in an audio, or summary of a video. You can customize the fields by creating your own analyzer template. |
17-
| [conversational_field_extraction.ipynb](notebooks/conversational_field_extraction.ipynb) | This sample shows you how to evaluate conversational audio data that has previously been transcribed with Content Understanding or Azure AI Speech in in an efficient way to optimize processing quality. This also allows you to re-analyze data in a cost-efficient way. This sample is based on the [field_extraction.ipynb](notebooks/field_extraction.ipynb) sample. |
18-
| [analyzer_training.ipynb](notebooks/analyzer_training.ipynb) | If you want to futher boost the performance for field extraction, we can do training when you provide few labeled samples to the API. Note: This feature is available to document scenario now. |
19-
| [management.ipynb](notebooks/management.ipynb) | This sample will demo how to create a minimal analyzer, list all the analyzers in your resource, and delete the analyzer you don't need. |
20-
| [build_person_directory.ipynb](notebooks/build_person_directory.ipynb) | This sample will demo how to enroll people’s faces from images and build a Person Directory. | |
5+
- The samples in this repository default to the latest preview API version: **2025-05-01-preview**.
6+
- This repo will provide more samples for new functionalities in Preview.2 **2025-05-01-preview** soon.
7+
- As of 2025/05, 2025-05-01-preview is only available in the regions documented in [Content Understanding region and language support](https://learn.microsoft.com/en-us/azure/ai-services/content-understanding/language-region-support).
8+
- To access the sample code for version 2024-12-01-preview, please check out the corresponding Git tag 2024-12-01-preview, or download it directly from the [release page](https://github.com/Azure-Samples/azure-ai-content-understanding-python/releases/tag/2024-12-01-preview).
219

2210
## Getting started
11+
You can run the sample in GitHub Codespaces or in your local environment. For a smoother, hassle-free experience, we recommend starting with Codespaces.
12+
2313
### GitHub Codespaces
2414
You can run this repo virtually by using GitHub Codespaces, which will open a web-based VS Code in your browser.
2515

2616
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?skip_quickstart=true&machine=basicLinux32gb&repo=899687170&ref=main&geo=UsEast&devcontainer_path=.devcontainer%2Fdevcontainer.json)
2717

18+
Once you click the link above, please follow the steps below to set up the Codespace.
19+
20+
1. Create a new Codespace by selecting the main branch, your preferred region for the Codespace, and the 2-core machine type, as shown in the screenshot below. \
21+
![Create CodeSpace](/docs/create-codespace/1-Create%20Codespace.png)
22+
2. Once the Codespace is ready, open the terminal and follow the instructions in the "Configure Azure AI service resource" section to set up a valid Content Understanding resource.
23+
24+
2825
### Local environment
2926
1. Make sure the following tools are installed:
3027

3128
* [Azure Developer CLI (azd)](https://aka.ms/install-azd)
3229
* [Python 3.11+](https://www.python.org/downloads/)
30+
* [Git LFS](https://git-lfs.com/)
3331

3432
2. Make a new directory called `azure-ai-content-understanding-python` and clone this template into it using the `azd` CLI:
35-
36-
```shell
33+
```
3734
azd init -t azure-ai-content-understanding-python
3835
```
39-
4036
You can also use git to clone the repository if you prefer.
37+
```
38+
git clone https://github.com/Azure-Samples/azure-ai-content-understanding-python.git
39+
cd azure-ai-content-understanding-python
40+
```
41+
- **Important:** If you use `git clone`, make sure to install Git LFS and run `git lfs pull` to download sample files in the `data` directory:
42+
43+
```shell
44+
git lfs install
45+
git lfs pull
46+
```
47+
3. Set Dev container Environment
48+
- Install tools that support dev containers
49+
- **Visual Studio Code**
50+
Download and install [Visual Studio Code](https://code.visualstudio.com/).
51+
52+
- **Dev Containers Extension**
53+
In the VS Code extension marketplace, install the extension named "Dev Containers".\
54+
(The extension was previously called "Remote - Containers", but has since been renamed and integrated into Dev Containers.)
55+
56+
- **Docker**
57+
Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) (available for Windows, macOS, and Linux).\
58+
Docker is used to manage and run the container environment.
59+
- Start Docker and ensure it is running in the background.
60+
61+
- Open the project and start the Dev Container
62+
- Open the project folder with VS Code.
63+
- Press `F1` or `Ctrl+Shift+P`, type and select:
64+
```
65+
Dev Containers: Reopen in Container
66+
```
67+
Or click the green icon in the lower left corner of VS Code and select "Reopen in Container".
68+
- VS Code will automatically detect the `.devcontainer` folder, build the development container, and install the necessary dependencies.
69+
- ![How to set dev container environment](./docs/dev-container-setup.gif "dev container setup")
4170
4271
## Configure Azure AI service resource
4372
### (Option 1) Use `azd` commands to auto create temporal resources to run sample
@@ -46,6 +75,11 @@ You can run this repo virtually by using GitHub Codespaces, which will open a we
4675
```shell
4776
azd auth login
4877
```
78+
If the previous command doesn’t work, try the following one and follow the on-screen instructions.
79+
```
80+
azd auth login --use-device-code
81+
```
82+
4983
1. Setting up environment, following prompts to choose location
5084
```shell
5185
azd up
@@ -54,18 +88,42 @@ You can run this repo virtually by using GitHub Codespaces, which will open a we
5488
5589
### (Option 2) Manually create resources and set environment variables
5690
1. Create [Azure AI Services resource](docs/create_azure_ai_service.md)
57-
1. Go to `Access Control (IAM)` in resource, grant yourself role `Cognitive Services User`
91+
2. Go to `Access Control (IAM)` in resource, grant yourself role `Cognitive Services User`
5892
- It's necessary even you are the owner of the resource
59-
1. Copy `notebooks/.env.sample` to `notebooks/.env`
60-
1. Fill **AZURE_AI_ENDPOINT** with the endpoint from your Azure portal Azure AI Services instance.
61-
1. Login Azure
93+
3. Copy `notebooks/.env.sample` to `notebooks/.env`
94+
4. Fill **AZURE_AI_ENDPOINT** with the endpoint from your Azure portal Azure AI Services instance.
95+
5. Login Azure
6296
```shell
6397
azd auth login
6498
```
6599

66100
## Open a Jupyter notebook and follow the step-by-step guidance
67101

68-
Navigate to the `notebooks` directory and select the sample notebook you are interested in. Since Codespaces is pre-configured with the necessary environment, you can directly execute each step in the notebook.
102+
Navigate to the `notebooks` directory and select the sample notebook you are interested in. Since the Dev Container (in Codespaces or in your local enviornment) is pre-configured with the necessary environment, you can directly execute each step in the notebook.
103+
104+
1. Select one of the notebooks of interest in the notebooks/ directory. We recommend you to start with "content_extraction.ipynb" to understand the basic concepts.
105+
![Select *.ipynb](/docs/create-codespace/2-Select%20file.ipynb.png)
106+
1. Select Kernel
107+
![Select Kernel](/docs/create-codespace/3-Select%20Kernel.png)
108+
1. Select Python Environment \
109+
![Select Python Environment](/docs/create-codespace/4-Select%20Python%20Environment.png)
110+
1. Run \
111+
![Run](/docs/create-codespace/5-Run.png)
112+
113+
## Features
114+
115+
Azure AI Content Understanding is a new Generative AI-based [Azure AI service](https://learn.microsoft.com/en-us/azure/ai-services/content-understanding/overview), designed to process/ingest content of any type (documents, images, audio, and video) into a user-defined output format. Content Understanding offers a streamlined process to reason over large amounts of unstructured data, accelerating time-to-value by generating an output that can be integrated into automation and analytical workflows.
116+
117+
## Samples
118+
119+
| File | Description |
120+
| --- | --- |
121+
| [content_extraction.ipynb](notebooks/content_extraction.ipynb) | In this sample we will show content understanding API can help you get semantic information from your file. For example OCR with table in document, audio transcription, and face analysis in video. |
122+
| [field_extraction.ipynb](notebooks/field_extraction.ipynb) | In this sample we will show how to create an analyzer to extract fields in your file. For example invoice amount in the document, how many people in an image, names mentioned in an audio, or summary of a video. You can customize the fields by creating your own analyzer template. |
123+
| [conversational_field_extraction.ipynb](notebooks/conversational_field_extraction.ipynb) | This sample shows you how to evaluate conversational audio data that has previously been transcribed with Content Understanding or Azure AI Speech in in an efficient way to optimize processing quality. This also allows you to re-analyze data in a cost-efficient way. This sample is based on the [field_extraction.ipynb](notebooks/field_extraction.ipynb) sample. |
124+
| [analyzer_training.ipynb](notebooks/analyzer_training.ipynb) | If you want to futher boost the performance for field extraction, we can do training when you provide few labeled samples to the API. Note: This feature is available to document scenario now. |
125+
| [management.ipynb](notebooks/management.ipynb) | This sample will demo how to create a minimal analyzer, list all the analyzers in your resource, and delete the analyzer you don't need. |
126+
| [build_person_directory.ipynb](notebooks/build_person_directory.ipynb) | This sample will demo how to enroll people’s faces from images and build a Person Directory. | |
69127

70128
## More Samples using Azure Content Understanding
71129
[Azure Search with Content Understanding](https://github.com/Azure-Samples/azure-ai-search-with-content-understanding-python)

analyzer_templates/audio_transcription.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"scenario": "conversation",
32
"description": "Sample audio transcription",
3+
"baseAnalyzerId": "prebuilt-audioAnalyzer",
44
"config": {
55
"returnDetails": true,
66
"locales": ["en-US"]

analyzer_templates/call_recording_analytics.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "Sample call recording analytics",
3-
"scenario": "callCenter",
3+
"baseAnalyzerId": "prebuilt-callCenter",
44
"config": {
55
"returnDetails": true,
66
"locales": ["en-US"]

analyzer_templates/call_recording_analytics_text.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "Sample call recording analytics",
3-
"scenario": "text",
3+
"baseAnalyzerId": "prebuilt-audioAnalyzer",
44
"config": {
55
"returnDetails": true
66
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"description": "Sample document content analyzer",
3-
"scenario": "document",
3+
"baseAnalyzerId": "prebuilt-documentAnalyzer",
44
"fieldSchema": {}
55
}

analyzer_templates/content_video.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "Sample video content analyzer",
3-
"scenario": "videoShot",
3+
"baseAnalyzerId": "prebuilt-videoAnalyzer",
44
"config": {
55
"returnDetails": true,
66
"locales": [

analyzer_templates/conversational_audio_analytics.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"scenario": "conversation",
32
"description": "Sample conversational audio analytics",
3+
"baseAnalyzerId": "prebuilt-audioAnalyzer",
44
"config": {
55
"returnDetails": true,
66
"locales": ["en-US"]

analyzer_templates/face_aware_in_video.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"description": "Generate face-aware content understanding from video.",
3+
"baseAnalyzerId": "prebuilt-videoAnalyzer",
34
"config": {
45
"enableFace": true,
56
"returnDetails": true,

analyzer_templates/image_chart.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "Extract detailed structured information from charts and diagrams.",
3-
"scenario": "image",
3+
"baseAnalyzerId": "prebuilt-imageAnalyzer",
44
"config": {
55
"returnDetails": false
66
},

analyzer_templates/invoice.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "Sample invoice analyzer",
3-
"scenario": "document",
3+
"baseAnalyzerId": "prebuilt-documentAnalyzer",
44
"fieldSchema": {
55
"fields": {
66
"VendorName": {

0 commit comments

Comments
 (0)