How to use tensorflow eager execution only in specific parts of the application?

I've got few files with different files:

  • <-- Uses tensorflow based library darkflow that relies on the graph mode
  • <-- uses tf eager execution

During darkflow's TFNet initialization I get this error:

Traceback (most recent call last):
  File "/home/justin/Projects/comp3931/", line 6, in <module>
    watcher = Watcher('res/vid/planet_earth_s01e01/video.mp4', 'res/vid/planet_earth_s01e01/')
  File "/home/justin/Projects/comp3931/", line 9, in __init__
    self.detector = Detector()
  File "/home/justin/Projects/comp3931/", line 6, in __init__
    self.tfnet = TFNet(self.options)
  File "/usr/local/lib64/python3.6/site-packages/darkflow/net/", line 75, in __init__
  File "/usr/local/lib64/python3.6/site-packages/darkflow/net/", line 105, in build_forward
    self.inp = tf.placeholder(tf.float32, inp_size, 'input')
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/", line 1677, in placeholder
    raise RuntimeError("tf.placeholder() is not compatible with "
RuntimeError: tf.placeholder() is not compatible with eager execution.

So, I assume that when I instantiate Translator class from file it invokes eager execution on the whole program, which then is not compatible with calls to darkflow's TFNet class used in Dectector class from

If I run independently from others it works fine, other modules also work fine if run them without involved.

I guess the fact that they use different contexts (graph/eager), the whole thing can't run together in the same program. I've tried looking at the documentation, but could not find a way to switch back to graph mode when needed.

Is there any way I can run both eager and graph modes in the same application in different places?