Waymo Open Dataset 開發紀錄
contributed by < gyes00205
>
Download Dataset
Waymo Open Dataset
domain_adaptation 的資料沒有 label ,所以請下載 training/ 的資料去訓練
tfrecord 內容
- 五種 camera 所拍攝的照片以及 Lidar 資訊
- num_classes: 0: Unknown, 1: Vehicle, 2: Pedestrian, 3: Sign, 4: Cyclist
這次 project 不需要 sign 和 Unknown 這兩個 classes ,因此 label_map.pbtxt 修改如下:
- camera 種類: FRONT, FRONT_LEFT, FRONT_RIGHT, SIDE_LEFT, SIDE_RIGHT
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- bbox (x, y, w, h) 座標: , xy 代表 bbox 中心座標 , wh 代表寬和高
環境配置
安裝 Waymo open dataset
安裝 COCO API
安裝 Tensorflow 2 Object Detection API
參考 TensorFlow 2 Object Detection API tutorial 安裝套件
- git clone Tensorflow 2 Object Detection API
建立資料夾結構
轉換 tfrecord 格式
因為 waymo 的 tfrecord 除了有 Lidar 的資訊之外,他的 bbox 格式如下:
(x0, y0): 為中心點座標。 (w, h): 為長寬。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
而我們的目標是過濾掉 Lidar 並將 bbox 轉為以下格式:
(x1, y1): 為左上角座標。 (x2, y2): 為右下角座標。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
轉換 tfrecord 的程式碼參考 LevinJ/tf_obj_detection_api,並且做一些小修改。
create_record.py:
filepath: tfrecord 的路徑
data_dir: 轉換過後的 tfrecord 會儲存在 data_dir/processed 目錄下
執行方式如下:
執行完後 data/processed 便會出現處理完的 tfrecord。
下載預訓練模型
到 Tensorflow Model Zoo 下載 pretrained model。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
我下載的是 SSD ResNet50 V1 FPN 640x640 (RetinaNet50)
。
- 先到 pre-trained-models 目錄下
cd pre-trained-models
- 下載 SSD ResNet50 的 pretrained model
tar zxvf ssd_resnet50_v1_fpn_640x640_coco17_tpu-8.tar.gz
修改訓練用 config
到 configs/tf2 找到與 pretrained model 相對應的 config,也就是ssd_resnet50_v1_fpn_640x640_coco17_tpu-8.config
- 在 ssd_resnet50_v1_fpn_640x640_coco17_tpu-8 目錄下新增 pipeline.config,並將剛剛找到的 config 內容複製貼上,並且做一些修改。
- num_classes: 種類個數
- batch_size: bach size 大小,根據電腦的記憶體而有不同設置
- fine_tune_checkpoint: 更改成 pretrained model 的 ckpt-0 路徑
- num_steps: 訓練步數
- use_bfloat16: 是否使用 tpu,沒有使用設定為 false
- label_map_path: label_map.pbtxt 路徑
- train_input_reader: 將 input_path 設定成訓練用的 tfrecord 路徑
- metrics_set: "coco_detection_metrics"
- use_moving_averages: false
- eval_input_reader: 將 input_path 設定成評估用用的 tfrecord 路徑
訓練模型
model_main_tf2.py
model_dir: 會將訓練的 checkpoint 儲存在 model_dir 目錄下
pipeline_config_path: pipeline.config 路徑
執行方式如下:
執行結果如下: 每 100 steps 會印一次。
評估模型 (Optional)
model_main_tf2.py
checkpoint_dir: 讀取 checkpoint 的目錄。
執行方式如下:
執行結果: 會計算 AP 和 AR
AP for small object : area <
AP for medium object : < area <
AP for large object : < area

輸出模型
exporter_main_v2.py
input_type: image_tensor
pipeline_config_path: pipeline.config 的路徑
trained_checkpoint_dir: 儲存 checkpoint 的位置
output_directory: 輸出模型位置
執行方式如下:
執行結果如下:
使用模型預測圖片
detect.py
saved_model_path: 模型位置
test_path: 測試圖片位置
output_path: 輸出預測圖片位置
min_score_thresh: 信心水準
執行方式如下:
預測結果:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Reference
- LevinJ/tf_obj_detection_api
- Waymo Open Dataset
- Waymo quick start tutorial
- Tensorflow Object Detection API Tutorial