Skip to content

Commit 052c00d

Browse files
No public description
PiperOrigin-RevId: 822784936
1 parent a3a337c commit 052c00d

File tree

2 files changed

+28
-34
lines changed
  • official/projects/waste_identification_ml/llm_applications/milk_pouch_detection

2 files changed

+28
-34
lines changed

official/projects/waste_identification_ml/llm_applications/milk_pouch_detection/README.md

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ frames.
66
### Prerequisites
77

88
- GCP account with Compute Engine access
9-
- A folder containing image frames to process
9+
- A GCP bucket folder containing images to process
1010

1111
### Setup Instructions
1212

@@ -36,30 +36,21 @@ detection pipeline.
3636

3737
### 4. Process Your Images
3838

39-
Given a folder path containing your test images, run:
39+
Given a gcs bucket path containing your test images, run:
4040

4141
```bash
42-
bash run_pipeline.sh --input_dir=/path/to/test_images
42+
bash run_pipeline.sh --gcs_path=/path/to/test_images
4343
```
4444

45-
Replace `/path/to/test_images` with the actual path to your image folder.
46-
47-
### 5. View Results
48-
49-
The pipeline will create two folders inside your input directory:
50-
51-
- **`dairy/`** - Contains all cropped objects identified as dairy products
52-
- **`others/`** - Contains all cropped objects that are not dairy products
53-
54-
### Example
45+
Replace `/path/to/test_images` with the actual bucket path to your image
46+
folder, for example:
5547

5648
```bash
57-
# If your images are in /home/user/test_images
58-
bash run_pipeline.sh --input_dir=/home/user/test_images
49+
bash run_pipeline.sh --gcs_path=gs://dairy_product_detection/test_images/
5950

6051
# Results will be in:
61-
# /home/user/test_images/dairy/
62-
# /home/user/test_images/others/
52+
# $gcs_path/predictions/dairy/
53+
# $gcs_path/predictions/others/
6354
```
6455

6556
### Troubleshooting
@@ -84,28 +75,27 @@ a particular category (e.g., dairy products, bottles, cans, etc.).
8475
Execute the following command to extract objects and generate dataset files:
8576

8677
```python
87-
python3 extract_objects.py --input_dir=/test_images --category_name=dairy
78+
python3 extract_objects.py --gcs_path=/test_path --category_name=${category}
8879
```
8980

9081
Replace:
9182

92-
- `/test_images` with the path to your image folder.
93-
- `dairy` with your category name (e.g., bottles, cans, plastic, etc.)
83+
- `/test_path` with the path to your image folder.
84+
- `category` with your category name (e.g., bottles, cans, plastic, etc.)
9485

9586
### 3. Generated Outputs
9687

97-
The script will generate two types of outputs inside your input directory:
88+
The script will generate two types of outputs:
9889

9990
#### For Image Classification Models
10091

101-
A folder named **`tempdir/`** will be created containing:
102-
103-
- All cropped objects extracted from the images
104-
- These cropped images can be directly used to train an image classifier model
92+
A folder named **objects_for_classification** will be created containing all
93+
cropped objects extracted from the images. These cropped images can be
94+
directly used to train an image classifier model
10595

10696
#### For Object Detection/Segmentation Models
10797

108-
A COCO format JSON file will be generated containing:
98+
A COCO JSON file will be generated containing:
10999

110100
- Annotations for all detected objects
111101
- Bounding boxes and segmentation masks
@@ -115,13 +105,13 @@ A COCO format JSON file will be generated containing:
115105

116106
```python
117107
# Extract dairy products from images
118-
python3 extract_objects.py --input_dir=/home/user/dairy_images --category_name=dairy
108+
python3 extract_objects.py --gcs_path=/home/user/dairy_images --category_name=dairy
119109

120110
# Extract plastic bottles
121-
python3 extract_objects.py --input_dir=/home/user/bottle_images --category_name=bottles
111+
python3 extract_objects.py --gcs_path=/home/user/bottle_images --category_name=bottles
122112

123113
# Extract metal cans
124-
python3 extract_objects.py --input_dir=/home/user/can_images --category_name=cans
114+
python3 extract_objects.py --gcs_path=/home/user/can_images --category_name=cans
125115
```
126116

127117
### Output Structure
@@ -132,18 +122,21 @@ After running the script, your directory will look like:
132122
/test_images/
133123
├── image1.jpg
134124
├── image2.jpg
135-
├── tempdir/ # Cropped objects for classification
125+
├── objects_for_classification
136126
│ ├── crop_001.jpg
137127
│ ├── crop_002.jpg
138128
│ └── ...
139-
└── annotations.json # COCO format file for detection/segmentation
129+
└── annotations.json # COCO format file for detection/segmentation
140130
```
141131

142132
### Use Cases
143133

144-
- **Image Classification**: Use images from `tempdir/` folder
145-
- **Object Detection**: Use the COCO JSON file with original images
146-
- **Instance Segmentation**: Use the COCO JSON file with segmentation masks
134+
- **Image Classification Training/Finetuning**: Use images from
135+
`objects_for_classification/` folder
136+
- **Object Detection Training/Finetuning**: Use the COCO JSON file with
137+
original images
138+
- **Instance Segmentation Training/Finetuning**: Use the COCO JSON file with
139+
segmentation masks
147140

148141
### Tips
149142

official/projects/waste_identification_ml/llm_applications/milk_pouch_detection/setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ sed -i 's|from official.projects.waste_identification_ml.llm_applications.milk_p
9696

9797
curl -sS -o models_utils.py https://raw.githubusercontent.com/tensorflow/models/master/official/projects/waste_identification_ml/llm_applications/milk_pouch_detection/models_utils.py
9898
curl -sS -o extract_objects.py https://raw.githubusercontent.com/tensorflow/models/master/official/projects/waste_identification_ml/llm_applications/milk_pouch_detection/extract_objects.py
99+
curl -sS -o batched_io.py https://raw.githubusercontent.com/tensorflow/models/master/official/projects/waste_identification_ml/llm_applications/milk_pouch_detection/batched_io.py
99100
curl -sS -o run_pipeline.sh https://raw.githubusercontent.com/tensorflow/models/master/official/projects/waste_identification_ml/llm_applications/milk_pouch_detection/run_pipeline.sh
100101
echo "Files downloaded and modified successfully!"
101102

0 commit comments

Comments
 (0)