Skip to content

Commit cbb6247

Browse files
committed
Bring tensorflow/models slim up to date.
Includes new gan nets. Inclues new NasNet models. PiperOrigin-RevId: 173772097
1 parent edcd29f commit cbb6247

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3766
-226
lines changed

research/slim/BUILD

+133-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Description:
22
# Contains files for loading, training and evaluating TF-Slim-based models.
33

4-
package(default_visibility = ["//visibility:public"])
4+
package(
5+
default_visibility = ["//visibility:public"],
6+
)
57

68
licenses(["notice"]) # Apache 2.0
79

810
exports_files(["LICENSE"])
911

10-
package_group(name = "internal")
11-
1212
py_library(
1313
name = "dataset_utils",
1414
srcs = ["datasets/dataset_utils.py"],
@@ -35,6 +35,7 @@ py_binary(
3535
name = "build_imagenet_data",
3636
srcs = ["datasets/build_imagenet_data.py"],
3737
deps = [
38+
# "//numpy",
3839
"//tensorflow",
3940
],
4041
)
@@ -44,6 +45,7 @@ py_library(
4445
srcs = ["datasets/download_and_convert_cifar10.py"],
4546
deps = [
4647
":dataset_utils",
48+
# "//numpy",
4749
"//tensorflow",
4850
],
4951
)
@@ -62,6 +64,7 @@ py_library(
6264
srcs = ["datasets/download_and_convert_mnist.py"],
6365
deps = [
6466
":dataset_utils",
67+
# "//numpy",
6568
"//tensorflow",
6669
],
6770
)
@@ -73,6 +76,7 @@ py_binary(
7376
":download_and_convert_cifar10",
7477
":download_and_convert_flowers",
7578
":download_and_convert_mnist",
79+
"//tensorflow",
7680
],
7781
)
7882

@@ -137,6 +141,7 @@ py_test(
137141
srcs_version = "PY2AND3",
138142
deps = [
139143
":model_deploy",
144+
# "//numpy",
140145
"//tensorflow",
141146
],
142147
)
@@ -154,6 +159,7 @@ py_library(
154159
srcs = ["preprocessing/inception_preprocessing.py"],
155160
deps = [
156161
"//tensorflow",
162+
"//tensorflow/python:control_flow_ops",
157163
],
158164
)
159165

@@ -192,10 +198,13 @@ py_library(
192198
deps = [
193199
":alexnet",
194200
":cifarnet",
201+
":cyclegan",
195202
":inception",
196203
":lenet",
197204
":mobilenet_v1",
205+
":nasnet",
198206
":overfeat",
207+
":pix2pix",
199208
":resnet_v1",
200209
":resnet_v2",
201210
":vgg",
@@ -206,6 +215,7 @@ py_library(
206215
name = "alexnet",
207216
srcs = ["nets/alexnet.py"],
208217
srcs_version = "PY2AND3",
218+
deps = ["//tensorflow"],
209219
)
210220

211221
py_test(
@@ -227,6 +237,45 @@ py_library(
227237
],
228238
)
229239

240+
py_library(
241+
name = "cyclegan",
242+
srcs = ["nets/cyclegan.py"],
243+
deps = [
244+
# "//numpy",
245+
"//tensorflow",
246+
],
247+
)
248+
249+
py_test(
250+
name = "cyclegan_test",
251+
srcs = ["nets/cyclegan_test.py"],
252+
shard_count = 3,
253+
srcs_version = "PY2AND3",
254+
deps = [
255+
":cyclegan",
256+
"//tensorflow",
257+
],
258+
)
259+
260+
py_library(
261+
name = "dcgan",
262+
srcs = ["nets/dcgan.py"],
263+
deps = [
264+
"//tensorflow",
265+
],
266+
)
267+
268+
py_test(
269+
name = "dcgan_test",
270+
srcs = ["nets/dcgan_test.py"],
271+
shard_count = 3,
272+
srcs_version = "PY2AND3",
273+
deps = [
274+
":dcgan",
275+
"//tensorflow",
276+
],
277+
)
278+
230279
py_library(
231280
name = "inception",
232281
srcs = ["nets/inception.py"],
@@ -244,6 +293,7 @@ py_library(
244293
name = "inception_utils",
245294
srcs = ["nets/inception_utils.py"],
246295
srcs_version = "PY2AND3",
296+
deps = ["//tensorflow"],
247297
)
248298

249299
py_library(
@@ -252,6 +302,7 @@ py_library(
252302
srcs_version = "PY2AND3",
253303
deps = [
254304
":inception_utils",
305+
"//tensorflow",
255306
],
256307
)
257308

@@ -261,6 +312,7 @@ py_library(
261312
srcs_version = "PY2AND3",
262313
deps = [
263314
":inception_utils",
315+
"//tensorflow",
264316
],
265317
)
266318

@@ -270,6 +322,7 @@ py_library(
270322
srcs_version = "PY2AND3",
271323
deps = [
272324
":inception_utils",
325+
"//tensorflow",
273326
],
274327
)
275328

@@ -279,13 +332,15 @@ py_library(
279332
srcs_version = "PY2AND3",
280333
deps = [
281334
":inception_utils",
335+
"//tensorflow",
282336
],
283337
)
284338

285339
py_library(
286340
name = "inception_resnet_v2",
287341
srcs = ["nets/inception_resnet_v2.py"],
288342
srcs_version = "PY2AND3",
343+
deps = ["//tensorflow"],
289344
)
290345

291346
py_test(
@@ -296,6 +351,7 @@ py_test(
296351
srcs_version = "PY2AND3",
297352
deps = [
298353
":inception",
354+
# "//numpy",
299355
"//tensorflow",
300356
],
301357
)
@@ -308,6 +364,7 @@ py_test(
308364
srcs_version = "PY2AND3",
309365
deps = [
310366
":inception",
367+
# "//numpy",
311368
"//tensorflow",
312369
],
313370
)
@@ -320,6 +377,7 @@ py_test(
320377
srcs_version = "PY2AND3",
321378
deps = [
322379
":inception",
380+
# "//numpy",
323381
"//tensorflow",
324382
],
325383
)
@@ -360,6 +418,7 @@ py_library(
360418
name = "mobilenet_v1",
361419
srcs = ["nets/mobilenet_v1.py"],
362420
srcs_version = "PY2AND3",
421+
deps = ["//tensorflow"],
363422
)
364423

365424
py_test(
@@ -370,6 +429,49 @@ py_test(
370429
srcs_version = "PY2AND3",
371430
deps = [
372431
":mobilenet_v1",
432+
# "//numpy",
433+
"//tensorflow",
434+
],
435+
)
436+
437+
py_library(
438+
name = "nasnet_utils",
439+
srcs = ["nets/nasnet/nasnet_utils.py"],
440+
srcs_version = "PY2AND3",
441+
deps = [
442+
"//tensorflow",
443+
],
444+
)
445+
446+
py_library(
447+
name = "nasnet",
448+
srcs = ["nets/nasnet/nasnet.py"],
449+
srcs_version = "PY2AND3",
450+
deps = [
451+
":nasnet_utils",
452+
"//tensorflow",
453+
],
454+
)
455+
456+
py_test(
457+
name = "nasnet_utils_test",
458+
size = "medium",
459+
srcs = ["nets/nasnet/nasnet_utils_test.py"],
460+
srcs_version = "PY2AND3",
461+
deps = [
462+
":nasnet_utils",
463+
"//tensorflow",
464+
],
465+
)
466+
467+
py_test(
468+
name = "nasnet_test",
469+
size = "large",
470+
srcs = ["nets/nasnet/nasnet_test.py"],
471+
shard_count = 10,
472+
srcs_version = "PY2AND3",
473+
deps = [
474+
":nasnet",
373475
"//tensorflow",
374476
],
375477
)
@@ -378,6 +480,7 @@ py_library(
378480
name = "overfeat",
379481
srcs = ["nets/overfeat.py"],
380482
srcs_version = "PY2AND3",
483+
deps = ["//tensorflow"],
381484
)
382485

383486
py_test(
@@ -391,10 +494,28 @@ py_test(
391494
],
392495
)
393496

497+
py_library(
498+
name = "pix2pix",
499+
srcs = ["nets/pix2pix.py"],
500+
srcs_version = "PY2AND3",
501+
deps = ["//tensorflow"],
502+
)
503+
504+
py_test(
505+
name = "pix2pix_test",
506+
srcs = ["nets/pix2pix_test.py"],
507+
srcs_version = "PY2AND3",
508+
deps = [
509+
":pix2pix",
510+
"//tensorflow",
511+
],
512+
)
513+
394514
py_library(
395515
name = "resnet_utils",
396516
srcs = ["nets/resnet_utils.py"],
397517
srcs_version = "PY2AND3",
518+
deps = ["//tensorflow"],
398519
)
399520

400521
py_library(
@@ -403,6 +524,7 @@ py_library(
403524
srcs_version = "PY2AND3",
404525
deps = [
405526
":resnet_utils",
527+
"//tensorflow",
406528
],
407529
)
408530

@@ -413,7 +535,9 @@ py_test(
413535
shard_count = 2,
414536
srcs_version = "PY2AND3",
415537
deps = [
538+
":resnet_utils",
416539
":resnet_v1",
540+
# "//numpy",
417541
"//tensorflow",
418542
],
419543
)
@@ -424,6 +548,7 @@ py_library(
424548
srcs_version = "PY2AND3",
425549
deps = [
426550
":resnet_utils",
551+
"//tensorflow",
427552
],
428553
)
429554

@@ -434,7 +559,9 @@ py_test(
434559
shard_count = 2,
435560
srcs_version = "PY2AND3",
436561
deps = [
562+
":resnet_utils",
437563
":resnet_v2",
564+
# "//numpy",
438565
"//tensorflow",
439566
],
440567
)
@@ -443,6 +570,7 @@ py_library(
443570
name = "vgg",
444571
srcs = ["nets/vgg.py"],
445572
srcs_version = "PY2AND3",
573+
deps = ["//tensorflow"],
446574
)
447575

448576
py_test(
@@ -494,7 +622,6 @@ py_binary(
494622
srcs = ["eval_image_classifier.py"],
495623
deps = [
496624
":dataset_factory",
497-
":model_deploy",
498625
":nets_factory",
499626
":preprocessing_factory",
500627
"//tensorflow",
@@ -508,6 +635,7 @@ py_binary(
508635
":dataset_factory",
509636
":nets_factory",
510637
"//tensorflow",
638+
"//tensorflow/python:platform",
511639
],
512640
)
513641

@@ -521,7 +649,7 @@ py_test(
521649
],
522650
deps = [
523651
":export_inference_graph",
524-
":nets_factory",
525652
"//tensorflow",
653+
"//tensorflow/python:platform",
526654
],
527655
)

research/slim/README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,16 @@ Model | TF-Slim File | Checkpoint | Top-1 Accuracy| Top-5 Accuracy |
259259
[MobileNet_v1_1.0_224](https://arxiv.org/pdf/1704.04861.pdf)|[Code](https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.py)|[mobilenet_v1_1.0_224_2017_06_14.tar.gz](http://download.tensorflow.org/models/mobilenet_v1_1.0_224_2017_06_14.tar.gz)|70.7|89.5|
260260
[MobileNet_v1_0.50_160](https://arxiv.org/pdf/1704.04861.pdf)|[Code](https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.py)|[mobilenet_v1_0.50_160_2017_06_14.tar.gz](http://download.tensorflow.org/models/mobilenet_v1_0.50_160_2017_06_14.tar.gz)|59.9|82.5|
261261
[MobileNet_v1_0.25_128](https://arxiv.org/pdf/1704.04861.pdf)|[Code](https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.py)|[mobilenet_v1_0.25_128_2017_06_14.tar.gz](http://download.tensorflow.org/models/mobilenet_v1_0.25_128_2017_06_14.tar.gz)|41.3|66.2|
262+
[NASNet-A_Mobile_224](https://arxiv.org/abs/1707.07012)#|[Code](https://github.com/tensorflow/models/blob/master/research/slim/nets/nasnet/nasnet.py)|[nasnet-a_mobile_04_10_2017.tar.gz](https://storage.googleapis.com/download.tensorflow.org/models/nasnet-a_mobile_04_10_2017.tar.gz)|74.0|91.6|
263+
[NASNet-A_Large_331](https://arxiv.org/abs/1707.07012)#|[Code](https://github.com/tensorflow/models/blob/master/research/slim/nets/nasnet/nasnet.py)|[nasnet-a_large_04_10_2017.tar.gz](https://storage.googleapis.com/download.tensorflow.org/models/nasnet-a_large_04_10_2017.tar.gz)|82.7|96.2|
262264

263265
^ ResNet V2 models use Inception pre-processing and input image size of 299 (use
264266
`--preprocessing_name inception --eval_image_size 299` when using
265267
`eval_image_classifier.py`). Performance numbers for ResNet V2 models are
266268
reported on the ImageNet validation set.
267269

270+
(#) More information and details about the NASNet architectures are available at this [README](nets/nasnet/README.md)
271+
268272
All 16 MobileNet Models reported in the [MobileNet Paper](https://arxiv.org/abs/1704.04861) can be found [here](https://github.com/tensorflow/models/tree/master/research/slim/nets/mobilenet_v1.md).
269273

270274
(\*): Results quoted from the [paper](https://arxiv.org/abs/1603.05027).
@@ -393,7 +397,8 @@ $ python eval_image_classifier.py \
393397
--model_name=inception_v3
394398
```
395399

396-
See the [evaluation module example](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/slim#evaluation-loop) for an example of how to evaluate a model at multiple checkpoints during or after the training.
400+
See the [evaluation module example](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/slim#evaluation-loop)
401+
for an example of how to evaluate a model at multiple checkpoints during or after the training.
397402

398403
# Exporting the Inference Graph
399404
<a id='Export'></a>

0 commit comments

Comments
 (0)