Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tensorflow compatibility with TF 2 #1216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
tensorflow compatibility with TF 2
  • Loading branch information
S-FK committed Nov 24, 2022
commit f29cfea30149f163d30ff38745424c285094a637
Binary file added .DS_Store
Binary file not shown.
Binary file added darkflow/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added darkflow/cython_utils/nms.cpython-38-darwin.so
Binary file not shown.
Binary file added darkflow/net/.DS_Store
Binary file not shown.
9 changes: 8 additions & 1 deletion darkflow/net/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import tensorflow as tf
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import time
from . import help
from . import flow
Expand All @@ -20,6 +21,12 @@ class TFNet(object):
'adam': tf.train.AdamOptimizer,
'ftrl': tf.train.FtrlOptimizer,
'sgd': tf.train.GradientDescentOptimizer
# 'rmsprop': tf.keras.optimizers.RMSprop,
# 'adadelta': tf.optimizers.Adadelta,
# 'adagrad': tf.keras.optimizers.Adagrad,
# 'adam': tf.keras.optimizers.Adam,
# 'ftrl': tf.keras.optimizers.Ftrl,
# 'sgd': tf.keras.optimizers.SGD
})

# imported methods
Expand Down
6 changes: 3 additions & 3 deletions darkflow/net/ops/baseop.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def wrap_variable(self, var):
val = self.lay.w[var]
self.lay.w[var] = tf.constant_initializer(val)
if var in self._SLIM: return
with tf.variable_scope(self.scope):
self.lay.w[var] = tf.get_variable(var,
with tf.compat.v1.variable_scope(self.scope):
self.lay.w[var] = tf.compat.v1.get_variable(var,
shape = self.lay.wshape[var],
dtype = tf.float32,
initializer = self.lay.w[var])
Expand All @@ -81,7 +81,7 @@ def wrap_pholder(self, ph, feed):
sig = '{}/{}'.format(self.scope, ph)
val = self.lay.h[ph]

self.lay.h[ph] = tf.placeholder_with_default(
self.lay.h[ph] = tf.compat.v1.placeholder_with_default(
val['dfault'], val['shape'], name = sig)
feed[self.lay.h[ph]] = val['feed']

Expand Down
2 changes: 1 addition & 1 deletion darkflow/net/ops/convolution.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tensorflow.contrib.slim as slim
import tf_slim as slim
from .baseop import BaseOp
import tensorflow as tf
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion darkflow/net/ops/simple.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tensorflow.contrib.slim as slim
import tf_slim as slim
from .baseop import BaseOp
import tensorflow as tf
from distutils.version import StrictVersion
Expand Down
2 changes: 1 addition & 1 deletion darkflow/net/yolo/train.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tensorflow.contrib.slim as slim
import tf_slim as slim
import pickle
import tensorflow as tf
from .misc import show
Expand Down
2 changes: 1 addition & 1 deletion darkflow/net/yolov2/train.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tensorflow.contrib.slim as slim
import tf_slim as slim
import pickle
import tensorflow as tf
from ..yolo.misc import show
Expand Down
2 changes: 1 addition & 1 deletion darkflow/utils/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __init__(self, path):
shape = (), mode = 'r', offset = 0,
dtype = '({})i4,'.format(4))
self.transpose = major > 1000 or minor > 1000
self.offset = 16
self.offset = 16+44148320-44148316

def walk(self, size):
if self.eof: return None
Expand Down