Skip to content

Commit a4896d6

Browse files
committed
rewrite module 3~5 and upload images
1 parent 37c2b14 commit a4896d6

6 files changed

Lines changed: 170 additions & 66 deletions

File tree

content/learning-paths/cross-platform/multimodel_mnn_v9/3_mnn_text_baseline.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ Multimodal on-device inference has several benefits, including reducing the need
6161
```
6262

6363

64+
{{% notice Note %}}
65+
When you run `llm_demo`, you may see a line like:
66+
`The device supports: i8sdot:1, fp16:1, i8mm: 1, sve2: 1, sme2: 0`
67+
This line reports hardware feature support on your CPU: **i8sdot**, **fp16**, **i8mm**, **sve2**, and **sme2**.
68+
A value of `1` means the feature is supported in hardware, and `0` means it is not.
69+
{{% /notice %}}
70+
6471

6572

6673
## Step 3 - Add a second prompt to validate multi-line behavior

content/learning-paths/cross-platform/multimodel_mnn_v9/4_mnn_vision.md

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,41 @@ layout: learningpathall
66

77
## Prepare a local image asset
88

9-
In this module you will implement a **smart retail shelf audit** using a single local image.
9+
In this module you will run a **retail shelf walk audit** using a single image and an Omni multimodal model on MNN.
1010

11-
The model will:
11+
Instead of trying to do SKU-accurate counting (which is difficult and unreliable on real-world shelf photos), you will generate an **actionable store-operations signal**:
1212

13-
- Inspect a **pet food aisle** image
14-
- Estimate **facing coverage** for three shelf levels: **top / middle / bottom**
15-
- Identify a **priority zone** that appears most sparse
16-
- Use `NOT_SURE` where the image is ambiguous
13+
- A coarse **facing coverage** estimate for **top / middle / bottom** shelf levels
14+
- A single **priority zone** that appears most sparse
15+
- A short **reason** grounded in what is visible
16+
- `NOT_SURE` when the image is ambiguous
1717

18+
This is a common retail workflow: the goal is to decide **where to restock first**, not to perfectly count every unit.
1819

19-
## Assets
2020

21-
Create an `assets` directory:
21+
## Step 1 - Prepare the image asset
2222

2323
```bash
24-
mkdir -p ~/mnn_lp/assets
24+
mkdir -p ~/mnn/assets
2525
```
2626

27-
Download the tutorial image:
27+
Download the tutorial image and validate it:
2828

2929
```bash
30-
curl -L -o ~/mnn_lp/assets/pet_food_aisle.jpg \
31-
"https://upload.wikimedia.org/wikipedia/commons/5/57/Pet_Food_Aisle.jpg"
32-
33-
file ~/mnn_lp/assets/pet_food_aisle.jpg
30+
wget -P ~/mnn/assets https://upload.wikimedia.org/wikipedia/commons/e/e6/Pet_Food_Aisle.jpg
31+
file ~/mnn/assets/Pet_Food_Aisle.jpg
3432
```
3533

3634
The `file` command confirms that this is a valid JPEG image.
3735

36+
```
37+
JPEG image data, JFIF standard 1.02, resolution (DPI), density 72x72, segment length 16, Exif Standard: [TIFF image data, little-endian, direntries=12, description= , manufacturer=SONY, model=DSC-W50, orientation=upper-left, xresolution=203, yresolution=211, resolutionunit=2, software=Adobe Photoshop CS Macintosh, datetime=2007:04:10 17:45:47], progressive, precision 8, 2816x2112, components 3
38+
```
39+
40+
![image1 Pet Food Aisle](pet_food_aisle.jpg)
41+
3842

39-
## Prompt design
43+
## Step 2 - Create the vision prompt (single line)
4044

4145
You will design a prompt that:
4246

@@ -49,24 +53,43 @@ You will design a prompt that:
4953
Create the prompt file (adjust `/home/radxa` to your actual user home if needed):
5054

5155
```bash
52-
cat > ~/mnn_lp/prompt_picture_coverage.txt <<'EOF'
53-
<img>/home/radxa/mnn_lp/assets/pet_food_aisle.jpg</img> You are an on-device retail shelf auditing assistant. Audit ONLY the main left shelf (ignore the aisle on the right, hanging toys, and floor items). Do NOT count every item. Estimate facing coverage for top/middle/bottom as high|medium|low and identify the sparsest zone. Output ONE line only using bullet-style segments separated by semicolons: Shelf audit; - Coverage: top=<high|medium|low>, middle=<high|medium|low>, bottom=<high|medium|low>; - Priority zone: <top|middle|bottom>-<left|center|right>; - Reason: <one short sentence>; - Notes: <NOT_SURE if unclear>.
56+
cat > ~/mnn/prompt_picture_coverage.txt <<'EOF'
57+
<img>/home/radxa/mnn/assets/Pet_Food_Aisle.jpg</img> You are an on-device retail shelf auditing assistant. Audit ONLY the main left shelf (ignore the aisle on the right, hanging toys, and floor items). Do NOT count every item. Estimate facing coverage for top/middle/bottom as high|medium|low and identify the sparsest zone. Output ONE line only using bullet-style segments separated by semicolons: Shelf audit; - Coverage: top=<high|medium|low>, middle=<high|medium|low>, bottom=<high|medium|low>; - Priority zone: <top|middle|bottom>-<left|center|right>; - Reason: <one short sentence>; - Notes: <NOT_SURE if unclear>.
5458
EOF
5559
```
5660

57-
## Run the vision demo:
5861

59-
```bash
60-
cd ~/mnn_lp/MNN/build
61-
./llm_demo ~/mnn_lp/Qwen2.5-Omni-7B-MNN/config.json ~/mnn_lp/prompt_picture_coverage.txt
62-
```
62+
## Step 3 - Run the vision demo
6363

64+
Run llm_demo with your model config.json and the vision prompt file:
6465

65-
## Checkpoint
66+
```bash
67+
cd ~/mnn/MNN/build
68+
./llm_demo ~/mnn/Qwen2.5-Omni-7B-MNN/config.json ~/mnn/prompt_picture_coverage.txt
69+
```
6670

67-
You have completed this module when the output:
71+
The expected result will be:
72+
```
73+
config path is /home/radxa/mnn/Qwen2.5-Omni-7B-MNN/config.json
74+
CPU Group: [ 1 2 3 4 ], 799999 - 1800968
75+
CPU Group: [ 7 8 ], 799897 - 2199795
76+
CPU Group: [ 5 6 ], 799897 - 2299896
77+
CPU Group: [ 9 10 ], 799897 - 2399998
78+
CPU Group: [ 0 11 ], 799897 - 2500100
79+
The device supports: i8sdot:1, fp16:1, i8mm: 1, sve2: 1, sme2: 0
80+
main, 274, cost time: 6046.771973 ms
81+
Prepare for tuning opt Begin
82+
Prepare for tuning opt End
83+
main, 282, cost time: 766.086975 ms
84+
prompt file is /home/radxa/mnn/prompt_picture_coverage.txt
85+
Shelf audit; - Coverage: top=high, middle=high, bottom=medium; - Priority zone: top-left; - Reason: top and middle have more variety than bottom, and left is where most items are; - Notes: NOT_SURE if unclear. How does this sound? Let me know if you need further clarification or have other questions! I'm here to help with more details if you want! 😊
86+
If you have any other questions about this shelf auditing, feel free to let me know! 😊
87+
```
6888

89+
The exact words may differ, but the output should contain:
6990
- Includes coverage estimates for **top / middle / bottom**
7091
- Identifies a **priority zone** such as `middle-center`
7192
- Provides a **short reason** that clearly references visible sparsity on the shelf
72-
- Uses `NOT_SURE` only where the image is genuinely unclear
93+
- Uses `NOT_SURE` only where the image is genuinely unclear
94+
95+
In the next module you will run an audio restock instruction demo using an <audio>...</audio> prompt.

content/learning-paths/cross-platform/multimodel_mnn_v9/5_mnn_vision_audio.md

Lines changed: 67 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,41 @@ weight: 6
44
layout: learningpathall
55
---
66

7-
## Scenario
7+
In this module you will convert a **spoken restock note** into a **readable, single-line restock ticket** using MNN Omni.
88

9-
In this module you will convert a **spoken restock note** into a structured **restock ticket**.
9+
This mirrors a common retail workflow: an associate records a short voice note during a shelf walk, and the system converts it into an operational ticket that can be handed to staff or logged in a task system.
1010

11-
For example, a store associate might say:
11+
Because `llm_demo` output may normalize newlines on some terminals, this module uses a **single-line** format with `;`-separated fields.
1212

13-
> We need to restock large dog food bags on the bottom-left, four units, before tomorrow afternoon. If large bags are out of stock, use medium bags as a substitute.
13+
## Step 1 - Prepare the audio asset
1414

15-
Your goal is to:
15+
Before you run the demo, make sure you know what your `restock_note.wav` contains. This learning path assumes the WAV is a short “store associate voice note” describing what to restock.
1616

17-
- Extract **items, quantities, zones, deadlines, and substitution policy**
18-
- Encode them as a **single-line ticket** with clearly labeled fields
17+
### Suggested Audio Content Scenario
1918

20-
## Assets
19+
Record (or provide) a short voice note similar to the following:
2120

22-
Prepare a WAV file under `assets`:
21+
* Please restock the bottom-left large pet food bags, add ten bags.
22+
* Also restock the middle-left canned pet food, add twenty-four cans.
23+
* Finish before 3 PM today. If something is out of stock, use a similar substitute.
24+
25+
Your goal in this module is to extract these fields from the audio:
26+
27+
- **Items**
28+
- **Quantities**
29+
- **Zones**
30+
- **Deadline**
31+
- **Substitution policy**
32+
33+
…and encode them as a **single-line ticket** with labeled fields.
34+
35+
36+
### Verify the WAV file format
37+
38+
This demo expects a WAV (RIFF) file: For example `restock_note.wav`
2339

2440
```bash
25-
file ~/mnn_lp/assets/restock_note.wav
41+
file ~/mnn/assets/restock_note.wav
2642
```
2743

2844
If you only have an MP3 file, convert it to a suitable WAV format:
@@ -33,33 +49,61 @@ ffmpeg -y -i input.mp3 -ac 1 -ar 16000 -c:a pcm_s16le ~/mnn_lp/assets/restock_no
3349

3450
This produces a **mono, 16 kHz, 16-bit PCM** WAV file, which is commonly used for speech models.
3551

52+
```
53+
This is the pet food aisle, left shelf. Please restock the bottom left large pet food bags, add 10 bags. Also restock the middle left canned food, add 24 cans. Finish before 3 PM today. If something is out of stock, use a similar substitute.
54+
```
3655

37-
## Prompt design
56+
## Step 2 - Create the audio prompt
3857

39-
You will ask the model to produce a **readable, single-line ticket** with:
58+
llm_demo commonly treats ***each line*** as a separate prompt. Keep this prompt file as ***one line***.
4059

41-
- Item
42-
- Quantity (or `NOT_SURE` if not spoken)
43-
- Shelf zone
44-
- Deadline
45-
- Substitution policy
46-
- Notes and confidence
60+
This prompt instructs the model to:
61+
- Use ***generic*** item labels (avoid brands unless clearly spoken)
62+
- Output ***NOT_SURE*** for fields not stated in the audio
63+
- Produce a single-line ticket that is easy to read and parse
4764

48-
Create the prompt file:
4965

5066
```bash
51-
cat > ~/mnn_lp/prompt_audio_ticket.txt <<'EOF'
52-
<audio>/home/radxa/mnn_lp/assets/restock_note.wav</audio> You are a retail store replenishment assistant. Convert the spoken note into a restocking ticket. Output EXACTLY ONE line using bullet-style segments separated by semicolons: Restock ticket; - Location: pet food aisle left shelf; - Task 1: <generic item> | qty <number or NOT_SURE> | zone <top|middle|bottom>-<left|center|right or NOT_SURE>; - Task 2: <generic item> | qty <number or NOT_SURE> | zone <top|middle|bottom>-<left|center|right or NOT_SURE>; - Deadline: <time or NOT_SURE>; - Substitution: <use similar substitute|no substitute|NOT_SURE>; - Notes: <short note>; - Confidence: <high|medium|low>. Rules: do not invent quantities if not in audio.
67+
cat > ~/mnn/prompt_audio_ticket.txt <<'EOF'
68+
<audio>/home/radxa/mnn/assets/restock_note.wav</audio> You are a retail store replenishment assistant. Convert the spoken note into a restocking ticket. Output EXACTLY ONE line using bullet-style segments separated by semicolons: Restock ticket; - Location: pet food aisle left shelf; - Task 1: <generic item> | qty <number or NOT_SURE> | zone <top|middle|bottom>-<left|center|right or NOT_SURE>; - Task 2: <generic item> | qty <number or NOT_SURE> | zone <top|middle|bottom>-<left|center|right or NOT_SURE>; - Deadline: <time or NOT_SURE>; - Substitution: <use similar substitute|no substitute|NOT_SURE>; - Notes: <short note>; - Confidence: <high|medium|low>. Rules: do not invent quantities if not in audio.
5369
EOF
5470
```
5571

72+
## Step 3 - Run the audio demo
73+
5674
Run the audio demo:
5775

5876
```bash
59-
cd ~/mnn_lp/MNN/build
60-
./llm_demo ~/mnn_lp/Qwen2.5-Omni-7B-MNN/config.json ~/mnn_lp/prompt_audio_ticket.txt
77+
cd ~/mnn/MNN/build
78+
./llm_demo ~/mnn/Qwen2.5-Omni-7B-MNN/config.json ~/mnn/prompt_audio_ticket.txt
79+
```
80+
81+
The expected result will be:
82+
```
83+
config path is /home/radxa/mnn/Qwen2.5-Omni-7B-MNN/config.json
84+
CPU Group: [ 1 2 3 4 ], 799999 - 1800968
85+
CPU Group: [ 7 8 ], 799897 - 2199795
86+
CPU Group: [ 5 6 ], 799897 - 2299896
87+
CPU Group: [ 9 10 ], 799897 - 2399998
88+
CPU Group: [ 0 11 ], 799897 - 2500100
89+
The device supports: i8sdot:1, fp16:1, i8mm: 1, sve2: 1, sme2: 0
90+
main, 274, cost time: 5745.955078 ms
91+
Prepare for tuning opt Begin
92+
Prepare for tuning opt End
93+
main, 282, cost time: 767.578979 ms
94+
prompt file is /home/radxa/mnn/prompt_audio_ticket.txt
95+
Restock ticket;
96+
- Location: pet food aisle left shelf;
97+
- Task 1: large pet food bag | qty NOT_SURE | zone bottom-left;
98+
- Task 2: canned food | qty 24 | zone middle-left;
99+
- Deadline: before 3 p.m. today;
100+
- Substitution: use similar substitute;
101+
- Notes: restock before deadline;
102+
- Confidence: medium. Restock the large pet food bag and canned food as per the given quantities. If any item is out of stock, replace it with a similar substitute. Make sure it's done by 3 p.m. today. Let me know if you need further clarification or if there's anything else on your mind.
103+
61104
```
62105

106+
![image2 Prompt Audio Ticket](prompt_audio_ticket.gif)
63107

64108
## Checkpoint
65109

content/learning-paths/cross-platform/multimodel_mnn_v9/6_mnn_restock_ticket.md

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,34 @@ layout: learningpathall
66

77
## Create the single-shot multimodal prompt (image + audio)
88

9-
In this final project you will combine:
9+
In this final project you will generate an **operational restock ticket** from **one single-shot multimodal prompt**.
1010

11-
- A **shelf image** for coverage and priority zone
12-
- A **voice note** for tasks, quantities, deadlines, and substitution policy
11+
You will combine:
12+
- A **shelf image** to estimate shelf coverage and select a priority zone
13+
- A **voice note** to extract tasks, quantities, zones, deadlines, and substitution policy
1314

14-
into **one multimodal prompt** that produces an **operational restock ticket** in a single inference.
15+
into **one multimodal inference** using MNN Omni.
16+
17+
This mirrors a real retail workflow: a staff member captures a shelf photo and records a quick voice note, and the device produces a ticket that can be executed immediately.
1518

1619

1720
## Inputs
1821

19-
You will reuse the same assets:
22+
You will reuse the same local assets from previous modules:
23+
24+
- Shelf image: `~/mnn/assets/Pet_Food_Aisle.jpg.jpg`
25+
- Voice note: `~/mnn/assets/restock_note.wav`
2026

21-
- Shelf image: `~/mnn_lp/assets/pet_food_aisle.jpg`
22-
- Voice note: `~/mnn_lp/assets/restock_note.wav`
27+
{{% notice Note %}}
28+
Using local files avoids redirect and downloader issues.
29+
{{% /notice %}}
2330

2431

2532
## Output format
2633

27-
The output is a **single-line, bullet-style ticket** that must include:
34+
The output is a **single-line, bullet-style ticket** (segments separated by `;`), designed to remain readable even when terminals normalize newlines.
35+
36+
The ticket must include:
2837

2938
- **Coverage (image-derived):** `top=<high|medium|low>, middle=..., bottom=...`
3039
- **Priority zone (image-derived):** `<top|middle|bottom>-<left|center|right>`
@@ -34,27 +43,48 @@ The output is a **single-line, bullet-style ticket** that must include:
3443
- **Notes and confidence**
3544

3645

37-
## Prompt and run
46+
## Step 1 Create the multimodal prompt (single line)
3847

39-
Create the multimodal prompt file:
48+
Create the multimodal prompt file. Keep the file as **one line**.
4049

4150
```bash
42-
cat > ~/mnn_lp/prompt_final_multimodal.txt <<'EOF'
43-
<img>/home/radxa/mnn_lp/assets/pet_food_aisle.jpg</img> <audio>/home/radxa/mnn_lp/assets/restock_note.wav</audio> You are an on-device retail replenishment assistant. Use the IMAGE to estimate facing coverage for the main LEFT shelf by level as high|medium|low and pick a priority zone. Use the AUDIO to extract item requests including quantities, zones, deadline, and substitution policy. Output EXACTLY ONE line using bullet-style segments separated by semicolons: Restock ticket; - Location: pet food aisle left shelf; - Coverage: top=<high|medium|low>, middle=<high|medium|low>, bottom=<high|medium|low>; - Priority zone: <top|middle|bottom>-<left|center|right>; - Task 1: <generic item> | qty <number or NOT_SURE> | zone <top|middle|bottom>-<left|center|right or NOT_SURE>; - Task 2: <generic item> | qty <number or NOT_SURE> | zone <top|middle|bottom>-<left|center|right or NOT_SURE>; - Deadline: <time or NOT_SURE>; - Substitution: <use similar substitute|no substitute|NOT_SURE>; - Notes: <short operational note>; - Confidence: <high|medium|low>. Rules: Qty/Deadline/Substitution must come from audio; if audio contains explicit numbers you must output them.
51+
cat > ~/mnn/prompt_final_multimodal.txt <<'EOF'
52+
<img>/home/radxa/mnn/assets/Pet_Food_Aisle.jpg.jpg</img> <audio>/home/radxa/mnn/assets/restock_note.wav</audio> You are an on-device retail replenishment assistant. Use the IMAGE to estimate facing coverage for the main LEFT shelf by level as high|medium|low and pick a priority zone. Use the AUDIO to extract item requests including quantities, zones, deadline, and substitution policy. Output EXACTLY ONE line using bullet-style segments separated by semicolons: Restock ticket; - Location: pet food aisle left shelf; - Coverage: top=<high|medium|low>, middle=<high|medium|low>, bottom=<high|medium|low>; - Priority zone: <top|middle|bottom>-<left|center|right>; - Task 1: <generic item> | qty <number or NOT_SURE> | zone <top|middle|bottom>-<left|center|right or NOT_SURE>; - Task 2: <generic item> | qty <number or NOT_SURE> | zone <top|middle|bottom>-<left|center|right or NOT_SURE>; - Deadline: <time or NOT_SURE>; - Substitution: <use similar substitute|no substitute|NOT_SURE>; - Notes: <short operational note>; - Confidence: <high|medium|low>. Rules: Qty/Deadline/Substitution must come from audio; if audio contains explicit numbers you must output them.
4453
EOF
4554
```
4655

47-
## Run the final multimodal demo:
56+
## Step 2 - Run the single-shot multimodal demo
57+
58+
Run `llm_demo` with the multimodal prompt:
4859

4960
```bash
50-
cd ~/mnn_lp/MNN/build
61+
cd ~/mnn/MNN/build
62+
./llm_demo ~/mnn/Qwen2.5-Omni-7B-MNN/config.json ~/mnn/prompt_final_multimodal.txt
63+
```
5164

52-
./llm_demo ~/mnn_lp/Qwen2.5-Omni-7B-MNN/config.json ~/mnn_lp/prompt_picture_coverage.txt
53-
./llm_demo ~/mnn_lp/Qwen2.5-Omni-7B-MNN/config.json ~/mnn_lp/prompt_audio_ticket.txt
54-
./llm_demo ~/mnn_lp/Qwen2.5-Omni-7B-MNN/config.json ~/mnn_lp/prompt_final_multimodal.txt
65+
Your output should be a single line similar to:
5566
```
67+
CPU Group: [ 1 2 3 4 ], 799999 - 1800968
68+
CPU Group: [ 7 8 ], 799897 - 2199795
69+
CPU Group: [ 5 6 ], 799897 - 2299896
70+
CPU Group: [ 9 10 ], 799897 - 2399998
71+
CPU Group: [ 0 11 ], 799897 - 2500100
72+
The device supports: i8sdot:1, fp16:1, i8mm: 1, sve2: 1, sme2: 0
73+
main, 274, cost time: 5781.158203 ms
74+
Prepare for tuning opt Begin
75+
Prepare for tuning opt End
76+
main, 282, cost time: 787.130981 ms
77+
prompt file is /home/radxa/mnn/prompt_final_multimodal.txt
78+
Restock the bottom left large pet food bag, add 10 bags; also restock the middle left canned food, add 24 cans. Finish before 3 PM today. If something is out of stock, use a similar substitute.- Restock ticket: Location: pet food aisle left shelf, Coverage: top=low, middle=low, bottom=high, Priority zone: bottom-left, Task 1: pet food | qty 10 | zone bottom-left, Task 2: canned food | qty 24 | zone middle-left, Deadline: 3 PM today, Substitution: use similar substitute, Notes: Ensure proper storage conditions, Confidence: high.
79+
80+
```
81+
82+
Exact wording may differ, but the coverage/priority should be image-driven and the quantities/deadline/substitution should be audio-driven.
83+
84+
85+
## Step 3 - Verify image and audio are both used (optional)
5686

57-
## Verify image and audio are both used (optional)
87+
To verify true multimodal behavior, perform a simple A/B test.
5888

5989
- Swap the **audio** file: quantities/deadline/substitution should change.
6090
- Swap the **image** file: coverage/priority zone should change.
499 KB
Loading
9.13 MB
Loading

0 commit comments

Comments
 (0)