Skip to content

Commit c4fb2f9

Browse files
authored
Fix ema (#883)
* fix ema * update README
1 parent c64759c commit c4fb2f9

File tree

6 files changed

+46
-86
lines changed

6 files changed

+46
-86
lines changed

Diff for: efficientdet/keras/README.md

+38-81
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@
33
[1] Mingxing Tan, Ruoming Pang, Quoc V. Le. EfficientDet: Scalable and Efficient Object Detection. CVPR 2020.
44
Arxiv link: https://arxiv.org/abs/1911.09070
55

6-
Updates:
7-
8-
- **Jul20: Added keras/TF2 and new SOTA D7x: 55.1mAP with 153ms**
9-
- Apr22: Sped up end-to-end latency: D0 has up to >200 FPS throughput on Tesla V100.
10-
* A great collaboration with [@fsx950223](https://github.com/fsx950223).
11-
- Apr1: Updated results for test-dev and added EfficientDet-D7.
12-
- Mar26: Fixed a few bugs and updated all checkpoints/results.
13-
- Mar24: Added tutorial with visualization and coco eval.
14-
- Mar 13: Released the initial code and models.
15-
166
**Quick start tutorial: [tutorial.ipynb](tutorial.ipynb)**
177

188
**Quick install dependencies: ```pip install -r requirements.txt```**
@@ -25,7 +15,7 @@ EfficientDets are a family of object detection models, which achieve state-of-th
2515
EfficientDets are developed based on the advanced backbone, a new BiFPN, and a new scaling technique:
2616

2717
<p align="center">
28-
<img src="./g3doc/network.png" width="800" />
18+
<img src="../g3doc/network.png" width="800" />
2919
</p>
3020

3121
* **Backbone**: we employ [EfficientNets](https://arxiv.org/abs/1905.11946) as our backbone networks.
@@ -38,10 +28,10 @@ Our model family starts from EfficientDet-D0, which has comparable accuracy as [
3828
<table border="0">
3929
<tr>
4030
<td>
41-
<img src="./g3doc/flops.png" width="100%" />
31+
<img src="../g3doc/flops.png" width="100%" />
4232
</td>
4333
<td>
44-
<img src="./g3doc/params.png", width="100%" />
34+
<img src="../g3doc/params.png", width="100%" />
4535
</td>
4636
</tr>
4737
</table>
@@ -56,15 +46,15 @@ We have provided a list of EfficientDet checkpoints and results as follows:
5646

5747
| Model | AP<sup>test</sup> | AP<sub>50</sub> | AP<sub>75</sub> |AP<sub>S</sub> | AP<sub>M</sub> | AP<sub>L</sub> | AP<sup>val</sup> | | #params | #FLOPs |
5848
|---------- |------ |------ |------ | -------- | ------| ------| ------ |------ |------ | :------: |
59-
| EfficientDet-D0 ([h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d0.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d0.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d0_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d0_coco_test-dev2017.txt)) | 34.6 | 53.0 | 37.1 | 12.4 | 39.0 | 52.7 | 34.3 | | 3.9M | 2.54B |
60-
| EfficientDet-D1 ([h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d1.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d1.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d1_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d1_coco_test-dev2017.txt)) | 40.5 | 59.1 | 43.7 | 18.3 | 45.0 | 57.5 | 40.2 | | 6.6M | 6.10B |
61-
| EfficientDet-D2 ([h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d2.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d2.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d2_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d2_coco_test-dev2017.txt)) | 43.0 | 62.3 | 46.2 | 22.5 | 47.0 | 58.4 | 42.5 | | 8.1M | 11.0B |
62-
| EfficientDet-D3 ([h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d3.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d3.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d3_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d3_coco_test-dev2017.txt)) | 47.5 | 66.2 | 51.5 | 27.9 | 51.4 | 62.0 | 47.2 | | 12.0M | 24.9B |
63-
| EfficientDet-D4 ([h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d4.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d4.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d4_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d4_coco_test-dev2017.txt)) | 49.7 | 68.4 | 53.9 | 30.7 | 53.2 | 63.2 | 49.3 | | 20.7M | 55.2B |
64-
| EfficientDet-D5 ([h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d5.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d5.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d5_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d5_coco_test-dev2017.txt)) | 51.5 | 70.5 | 56.1 | 33.9 | 54.7 | 64.1 | 51.2 | | 33.7M | 130B |
65-
| EfficientDet-D6 ([h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d6.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d6.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d6_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d6_coco_test-dev2017.txt)) | 52.6 | 71.5 | 57.2 | 34.9 | 56.0 | 65.4 | 52.1 | | 51.9M | 226B |
66-
| EfficientDet-D7 ([h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d7.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d7.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d7_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d7_coco_test-dev2017.txt)) | 53.7 | 72.4 | 58.4 | 35.8 | 57.0 | 66.3 | 53.4 | | 51.9M | 325B |
67-
| EfficientDet-D7x ([h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d7x.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d7x.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d7x_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d7x_coco_test-dev2017.txt)) | 55.1 | 74.3 | 59.9 | 37.2 | 57.9 | 68.0 | 54.4 | | 77.0M | 410B |
49+
| EfficientDet-D0 ([ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d0.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d0_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d0_coco_test-dev2017.txt)) | 34.6 | 53.0 | 37.1 | 12.4 | 39.0 | 52.7 | 34.3 | | 3.9M | 2.54B |
50+
| EfficientDet-D1 ([ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d1.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d1_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d1_coco_test-dev2017.txt)) | 40.5 | 59.1 | 43.7 | 18.3 | 45.0 | 57.5 | 40.2 | | 6.6M | 6.10B |
51+
| EfficientDet-D2 ([ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d2.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d2_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d2_coco_test-dev2017.txt)) | 43.0 | 62.3 | 46.2 | 22.5 | 47.0 | 58.4 | 42.5 | | 8.1M | 11.0B |
52+
| EfficientDet-D3 ([ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d3.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d3_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d3_coco_test-dev2017.txt)) | 47.5 | 66.2 | 51.5 | 27.9 | 51.4 | 62.0 | 47.2 | | 12.0M | 24.9B |
53+
| EfficientDet-D4 ([ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d4.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d4_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d4_coco_test-dev2017.txt)) | 49.7 | 68.4 | 53.9 | 30.7 | 53.2 | 63.2 | 49.3 | | 20.7M | 55.2B |
54+
| EfficientDet-D5 ([ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d5.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d5_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d5_coco_test-dev2017.txt)) | 51.5 | 70.5 | 56.1 | 33.9 | 54.7 | 64.1 | 51.2 | | 33.7M | 130B |
55+
| EfficientDet-D6 ([ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d6.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d6_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d6_coco_test-dev2017.txt)) | 52.6 | 71.5 | 57.2 | 34.9 | 56.0 | 65.4 | 52.1 | | 51.9M | 226B |
56+
| EfficientDet-D7 ([ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d7.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d7_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d7_coco_test-dev2017.txt)) | 53.7 | 72.4 | 58.4 | 35.8 | 57.0 | 66.3 | 53.4 | | 51.9M | 325B |
57+
| EfficientDet-D7x ([ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/efficientdet-d7x.tar.gz), [val](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/val/d7x_coco_val.txt), [test-dev](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco2/testdev/d7x_coco_test-dev2017.txt)) | 55.1 | 74.3 | 59.9 | 37.2 | 57.9 | 68.0 | 54.4 | | 77.0M | 410B |
6858

6959
<sup><em>val</em> denotes validation results, <em>test-dev</em> denotes test-dev2017 results. AP<sup>val</sup> is for validation accuracy, all other AP results in the table are for COCO test-dev2017. All accuracy numbers are for single-model single-scale without ensemble or test-time augmentation. EfficientDet-D0 to D6 are trained for 300 epochs and D7/D7x are trained for 600 epochs.</sup>
7060

@@ -73,11 +63,11 @@ In addition, the following table includes a list of models trained with fixed 64
7363

7464
| Model | mAP | Latency |
7565
| ------ | ------ | ------ |
76-
| D2(640) [h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d2-640.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d2-640.tar.gz) | 41.7 | 14.8ms |
77-
| D3(640) [h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d3-640.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d3-640.tar.gz) | 44.0 | 18.7ms |
78-
| D4(640) [h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d4-640.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d4-640.tar.gz) | 45.7 | 21.7ms |
79-
| D5(640 [h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d5-640.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d5-640.tar.gz) | 46.6 | 26.6ms |
80-
| D6(640) [h5](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d6-640.h5), [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d6-640.tar.gz) | 47.9 | 33.8ms |
66+
| D2(640) [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d2-640.tar.gz) | 41.7 | 14.8ms |
67+
| D3(640) [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d3-640.tar.gz) | 44.0 | 18.7ms |
68+
| D4(640) [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d4-640.tar.gz) | 45.7 | 21.7ms |
69+
| D5(640) [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d5-640.tar.gz) | 46.6 | 26.6ms |
70+
| D6(640) [ckpt](https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco640/efficientdet-d6-640.tar.gz) | 47.9 | 33.8ms |
8171

8272

8373

@@ -96,10 +86,9 @@ Then you will get:
9686
- saved model under `savedmodeldir/`
9787
- frozen graph with name `savedmodeldir/efficientdet-d0_frozen.pb`
9888
- TensorRT saved model under `savedmodeldir/tensorrt_fp32/`
99-
- tflite file with name `efficientdet-d0.tflite`
89+
- tflite file with name `savedmodeldir/fp32.tflite`
10090

10191
Notably,
102-
--tflite_path only works after 2.3.0-dev20200521 ,
10392
--model_dir=xx/archive is the folder for exporting the best model.
10493

10594

@@ -154,12 +143,12 @@ latency and throughput are:
154143

155144
# Step2: inference image.
156145
!python inspector.py --mode=infer \
157-
--model_name=efficientdet-d0 --model_dir=efficientdet-d0 \
146+
--model_name=efficientdet-d0 --saved_model_dir=/tmp/saved_model \
158147
--hparams="image_size=1920x1280" \
159148
--input_image=img.png --output_image_dir=/tmp/
160149

161150

162-
Alternatively, if you want to do inference using frozen graph instead of saved model, you can run
151+
If you want to do inference using frozen graph, you can run
163152

164153
# Step 1 is the same as before.
165154
# Step 2: do inference with frozen graph.
@@ -168,18 +157,28 @@ Alternatively, if you want to do inference using frozen graph instead of saved m
168157
--saved_model_dir=/tmp/saved_model/efficientdet-d0_frozen.pb \
169158
--input_image=img.png --output_image_dir=/tmp/
170159

160+
If you want to do inference using tflite, you can run
161+
162+
# Step 1 is the same as before.
163+
# Step 2: do inference with frozen graph.
164+
!python inspector.py --mode=infer \
165+
--model_name=efficientdet-d0 \
166+
--saved_model_dir=/tmp/saved_model/fp32.tflite \
167+
--input_image=img.png --output_image_dir=/tmp/
168+
171169
Lastly, if you only have one image and just want to run a quick test, you can also run the following command (it is slow because it needs to construct the graph from scratch):
172170

173171
# Run inference for a single image.
174-
!python inspector.py --mode=infer --model_name=$MODEL \
172+
!python inspector.py --mode=infer \
173+
--model_name=efficientdet-d0 --model_dir=$CKPT_PATH \
175174
--hparams="image_size=1920x1280" \
176-
--model_dir=$CKPT_PATH --input_image=img.png --output_image_dir=/tmp
175+
--input_image=img.png --output_image_dir=/tmp/
177176
# you can visualize the output /tmp/0.jpg
178177

179178
Here is an example of EfficientDet-D0 visualization: more on [tutorial](tutorial.ipynb)
180179

181180
<p align="center">
182-
<img src="./g3doc/street.jpg" width="800" />
181+
<img src="../g3doc/street.jpg" width="800" />
183182
</p>
184183

185184
## 6. Inference for videos.
@@ -243,67 +242,25 @@ Create a config file for the PASCAL VOC dataset called voc_config.yaml and put t
243242
var_freeze_expr: '(efficientnet|fpn_cells|resample_p6)'
244243
label_map: {1: aeroplane, 2: bicycle, 3: bird, 4: boat, 5: bottle, 6: bus, 7: car, 8: cat, 9: chair, 10: cow, 11: diningtable, 12: dog, 13: horse, 14: motorbike, 15: person, 16: pottedplant, 17: sheep, 18: sofa, 19: train, 20: tvmonitor}
245244

246-
Finetune needs to use --ckpt rather than --backbone_ckpt.
245+
Finetune needs to use --pretrained_ckpt.
247246

248247
!python train.py
249248
--training_file_pattern=tfrecord/pascal*.tfrecord \
250249
--val_file_pattern=tfrecord/pascal*.tfrecord \
250+
--val_file_pattern=tfrecord/*.json \
251251
--model_name=efficientdet-d0 \
252252
--model_dir=/tmp/efficientdet-d0-finetune \
253-
--ckpt=efficientdet-d0 \
253+
--pretrained_ckpt=efficientdet-d0 \
254254
--batch_size=64 \
255255
--eval_samples=1024 \
256256
--num_examples_per_epoch=5717 --num_epochs=50 \
257257
--hparams=voc_config.yaml
258258

259259
If you want to continue to train the model, simply re-run the above command because the `num_epochs` is a maximum number of epochs. For example, to reproduce the result of efficientdet-d0, set `--num_epochs=300` then run the command multiple times until the training is finished.
260260

261-
If you want to do inference for custom data, you can run
262-
263-
# Setting hparams-flag is needed sometimes.
264-
!python inspector.py --mode=infer \
265-
--model_name=efficientdet-d0 --model_dir=efficientdet-d0 \
266-
--hparams=voc_config.yaml \
267-
--input_image=img.png --output_image_dir=/tmp/
268-
269-
You should check more details of runmode which is written in caption-4.
270-
271261
## 9. Train on multi GPUs.
272262

273-
Create a config file for the PASCAL VOC dataset called voc_config.yaml and put this in it.
274-
275-
num_classes: 21
276-
var_freeze_expr: '(efficientnet|fpn_cells|resample_p6)'
277-
label_map: {1: aeroplane, 2: bicycle, 3: bird, 4: boat, 5: bottle, 6: bus, 7: car, 8: cat, 9: chair, 10: cow, 11: diningtable, 12: dog, 13: horse, 14: motorbike, 15: person, 16: pottedplant, 17: sheep, 18: sofa, 19: train, 20: tvmonitor}
278-
279-
Download efficientdet coco checkpoint.
280-
281-
!wget https://storage.googleapis.com/cloud-tpu-checkpoints/efficientdet/coco/efficientdet-d0.tar.gz
282-
!tar xf efficientdet-d0.tar.gz
283-
284-
Finetune needs to use --ckpt rather than --backbone_ckpt.
285-
286-
python train.py \
287-
--training_file_pattern=tfrecord/pascal*.tfrecord \
288-
--val_file_pattern=tfrecord/pascal*.tfrecord \
289-
--model_name=efficientdet-d0 \
290-
--model_dir=/tmp/efficientdet-d0-finetune \
291-
--ckpt=efficientdet-d0 \
292-
--batch_size=64 \
293-
--eval_samples=1024 \
294-
--num_examples_per_epoch=5717 --num_epochs=50 \
295-
--hparams=voc_config.yaml \
296-
--strategy=gpus
297-
298-
If you want to do inference for custom data, you can run
299-
300-
# Setting hparams-flag is needed sometimes.
301-
!python inspector.py --mode=infer \
302-
--model_name=efficientdet-d0 --model_dir=efficientdet-d0 \
303-
--hparams=voc_config.yaml \
304-
--input_image=img.png --output_image_dir=/tmp/
305-
306-
You should check more details of runmode which is written in caption-4.
263+
Just add ```--strategy=gpus```
307264

308265
## 10. Training EfficientDets on TPUs.
309266

@@ -335,7 +292,7 @@ EfficientDets use a lot of GPU memory for a few reasons:
335292
* Large internal activations for backbone: our backbone uses a relatively large expansion ratio (6), causing the large expanded activations.
336293
* Deep BiFPN: our BiFPN has multiple top-down and bottom-up paths, which leads to a lot of intermediate memory usage during training.
337294

338-
To train this model on GPU with low memory there is an experimental option gradient_checkpointing.
295+
To train this model on GPU with low memory there is an experimental option grad_checkpoint.
339296

340297
Check these links for a high-level idea of what gradient checkpointing is doing:
341298
1. https://medium.com/tensorflow/fitting-larger-networks-into-memory-583e3c758ff9

Diff for: efficientdet/keras/eval.py

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def main(_):
7676
model.build((None, *config.image_size, 3))
7777
util_keras.restore_ckpt(model,
7878
tf.train.latest_checkpoint(FLAGS.model_dir),
79+
config.moving_average_decay,
7980
skip_mismatch=False)
8081
@tf.function
8182
def model_fn(images, labels):

Diff for: efficientdet/keras/inference.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ def build(self, params_override=None):
202202
self.model = efficientdet_keras.EfficientDetModel(config=config)
203203
image_size = utils.parse_image_size(params['image_size'])
204204
self.model.build((self.batch_size, *image_size, 3))
205-
util_keras.restore_ckpt(self.model, self.ckpt_path, skip_mismatch=False)
205+
util_keras.restore_ckpt(self.model, self.ckpt_path,
206+
self.params['moving_average_decay'],
207+
skip_mismatch=False)
206208

207209
def visualize(self, image, boxes, classes, scores, **kwargs):
208210
"""Visualize prediction on image."""

0 commit comments

Comments
 (0)