Skip to content

Commit

Permalink
tensorpack.tfv1
Browse files Browse the repository at this point in the history
  • Loading branch information
ppwwyyxx committed Jul 26, 2020
1 parent 8e6f930 commit 425f9d2
Show file tree
Hide file tree
Showing 26 changed files with 31 additions and 203 deletions.
2 changes: 1 addition & 1 deletion docs/modules/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ API Documentation
.. toctree::
:maxdepth: 1


dataflow
dataflow.dataset
dataflow.imgaug
Expand All @@ -17,3 +16,4 @@ API Documentation
tfutils
utils
contrib
tfv1
1 change: 0 additions & 1 deletion examples/ConvolutionalPoseMachines/README.md

This file was deleted.

28 changes: 0 additions & 28 deletions examples/DisturbLabel/README.md

This file was deleted.

22 changes: 0 additions & 22 deletions examples/DisturbLabel/disturb.py

This file was deleted.

64 changes: 0 additions & 64 deletions examples/DisturbLabel/mnist-disturb.py

This file was deleted.

Binary file removed examples/DisturbLabel/mnist.png
Binary file not shown.
60 changes: 0 additions & 60 deletions examples/DisturbLabel/svhn-disturb.py

This file was deleted.

Binary file removed examples/DisturbLabel/svhn.png
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/FasterRCNN/modeling/generalized_rcnn.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# File:

from tensorpack.compat import tfv1 as tf
from tensorpack import tfv1 as tf
from tensorpack import ModelDesc
from tensorpack.models import GlobalAvgPooling, l2_regularizer, regularize_cost
from tensorpack.tfutils import optimizer
Expand Down
3 changes: 1 addition & 2 deletions examples/ImageNetModels/alexnet.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File: alexnet.py

import argparse
import numpy as np
import os
import cv2
import tensorflow as tf

from tensorpack import tfv1 as tf
from tensorpack import *
from tensorpack.dataflow import imgaug
from tensorpack.tfutils import argscope
Expand Down
4 changes: 1 addition & 3 deletions examples/ImageNetModels/imagenet_utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# -*- coding: utf-8 -*-
# File: imagenet_utils.py


import multiprocessing
import numpy as np
import os
from abc import abstractmethod
import cv2
import tensorflow as tf
import tqdm

from tensorpack import tfv1 as tf
from tensorpack import ModelDesc
from tensorpack.dataflow import (
AugmentImageComponent, BatchData, MultiThreadMapData,
Expand Down
3 changes: 1 addition & 2 deletions examples/ImageNetModels/inception-bn.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File: inception-bn.py
# Author: Yuxin Wu

import argparse
import os
import tensorflow as tf
from tensorpack import tfv1 as tf

from tensorpack import *
from tensorpack.dataflow import dataset
Expand Down
2 changes: 1 addition & 1 deletion examples/ImageNetModels/shufflenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import os
import cv2
import tensorflow as tf
from tensorpack import tfv1 as tf

from tensorpack import *
from tensorpack.dataflow import imgaug
Expand Down
2 changes: 1 addition & 1 deletion examples/ImageNetModels/vgg16.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import argparse
import os
import tensorflow as tf
from tensorpack import tfv1 as tf

from tensorpack import *
from tensorpack.tfutils import argscope
Expand Down
8 changes: 5 additions & 3 deletions examples/SpatialTransformer/mnist-addition.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File: mnist-addition.py
# Author: Yuxin Wu

import argparse
import numpy as np
import os
import cv2
import tensorflow as tf
from tensorpack import tfv1 as tf

from tensorpack import *
from tensorpack.dataflow import dataset
Expand Down Expand Up @@ -194,7 +193,10 @@ def get_data(isTrain):

ds = JoinData([ds, ds])
# stack the two digits into two channels, and label it with the sum
ds = MapData(ds, lambda dp: [np.stack([dp[0], dp[2]], axis=2), dp[1] + dp[3]])

def mapper(dp):
return [np.stack([dp[0], dp[2]], axis=2), dp[1] + dp[3]]
ds = MapData(ds, dp)
ds = BatchData(ds, 128)
return ds

Expand Down
2 changes: 1 addition & 1 deletion examples/basics/cifar-convnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Author: Yuxin Wu
import argparse
import os
from tensorpack.compat import tfv1 as tf
from tensorpack import tfv1 as tf

from tensorpack import *
from tensorpack.dataflow import dataset
Expand Down
2 changes: 1 addition & 1 deletion examples/basics/export-model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import argparse
import cv2
from tensorpack.compat import tfv1 as tf
from tensorpack import tfv1 as tf
from tensorpack import *
from tensorpack.tfutils.export import ModelExporter

Expand Down
2 changes: 1 addition & 1 deletion examples/basics/mnist-convnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# File: mnist-convnet.py

from tensorpack.compat import tfv1 as tf
from tensorpack import tfv1 as tf
from tensorpack import *
from tensorpack.dataflow import dataset
from tensorpack.tfutils import summary
Expand Down
2 changes: 1 addition & 1 deletion examples/basics/mnist-tflayers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# File: mnist-tflayers.py

from tensorpack.compat import tfv1 as tf
from tensorpack import tfv1 as tf
from tensorpack import *
from tensorpack.dataflow import dataset
from tensorpack.tfutils import summary
Expand Down
2 changes: 1 addition & 1 deletion examples/basics/mnist-visualizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The same MNIST ConvNet example, but with weights/activations visualization.
"""

from tensorpack.compat import tfv1 as tf
from tensorpack import tfv1 as tf
from tensorpack import *
from tensorpack.dataflow import dataset

Expand Down
2 changes: 1 addition & 1 deletion examples/basics/svhn-digit-convnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import argparse
import os
from tensorpack.compat import tfv1 as tf
from tensorpack import tfv1 as tf
from tensorpack import *
from tensorpack.dataflow import dataset
from tensorpack.tfutils.summary import *
Expand Down
2 changes: 2 additions & 0 deletions tensorpack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
from tensorpack.train import *
from tensorpack.input_source import *
from tensorpack.predict import *

from tensorpack.compat import tfv1
5 changes: 4 additions & 1 deletion tensorpack/compat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tensorflow as tf


def backport_tensor_spec():
def _backport_tensor_spec():
if hasattr(tf, 'TensorSpec'):
return tf.TensorSpec
try:
Expand All @@ -19,6 +19,9 @@ def backport_tensor_spec():


def is_tfv2():
"""
Returns whether tensorflow is operating in V2 mode.
"""
try:
from tensorflow.python import tf2
return tf2.enabled()
Expand Down
4 changes: 2 additions & 2 deletions tensorpack/dataflow/imgaug/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_transform(self, img):
arr = cv2.warpAffine(arr, mat, arr.shape)
assert np.all(arr == orig)
"""
mat = cv2.getRotationMatrix2D(tuple(center - 0.5), deg, 1)
mat = cv2.getRotationMatrix2D(tuple(center - 0.5), float(deg), 1)
return WarpAffineTransform(
mat, img.shape[1::-1], interp=self.interp,
borderMode=self.border, borderValue=self.border_value)
Expand All @@ -104,7 +104,7 @@ def _get_deg(self, img):
deg = self._rand_range(-self.max_deg, self.max_deg)
if self.step_deg:
deg = deg // self.step_deg * self.step_deg
return deg
return float(deg)

def get_transform(self, img):
deg = self._get_deg(img)
Expand Down

0 comments on commit 425f9d2

Please sign in to comment.