TensorFlow-Unreal icon indicating copy to clipboard operation
TensorFlow-Unreal copied to clipboard

Error: AttributeError: 'TensorFlowComponent' object has no attribute 'tfapi'

Open youngbin-song opened this issue 4 years ago • 4 comments

Hi, I just started using this plugin for one of my project but I'm having difficulty in what's going wrong with my setup. I'm currently using UE 4.23 and have two separate projects for the GPU and CPU version of your plugin (same content and everything).

While the GPU version of the project seems to work fine, I encounter the error

`LogPython: Test2 input passed: {"id":"BP_Agents3","distanceToTarget":503.25839233398438,"bearingToTarget":-178.17808532714844,"distanceToNearestAgent":788.39898681640625,"bearingToNearestAgent":91.817146301269531,"agentOrientation":{"pitch":0,"yaw":0,"roll":0},"object":"BP_Agents_C'/Game/DSO_AISwarm/Maps/UEDPIE_0_TestingGround1.TestingGround1:PersistentLevel
.BP_Agents3'"}
LogPython: Error: 'TensorFlowComponent' object has no attribute 'tfapi'
LogPython: Error: Traceback (most recent call last):
LogPython: Error:   File "D:\Unreal Projects\Tensorflow_CPU\Plugins\tensorflow-ue4\Content\Scripts\TensorFlowComponent.py", line 109, in json_input
    self.json_input_blocking(args)

LogPython: Error:   File "D:\Unreal Projects\Tensorflow_CPU\Plugins\tensorflow-ue4\Content\Scripts\TensorFlowComponent.py", line 114, in json_input_blocking
    resultJson = self.tfapi.onJsonInput(json.loads(args))
LogPython: Error: AttributeError: 'TensorFlowComponent' object has no attribute 'tfapi'`

in the CPU version.

Just as a clarification, I am able to run the example projects which you've provided without any error. I'm not exactly sure what I'm doing wrong when running this project. Any point to the correct direction would be appreciated.

youngbin-song avatar Jan 18 '21 10:01 youngbin-song

It's possible that the current master branch doesn't contain TensorFlowComponent.py due to change to ml-remote (this change: https://github.com/getnamo/tensorflow-ue4/commit/27637fbe4f75addc850714d76d15e5b802228371#diff-47bd29075f8b8019f0beec6d86beda7c9bf67aaf05053dcbe0b3bcb63968517f). If you're using the older version, try to copy the TensorFlowComponent.py script to the plugin content/scripts folder.

getnamo avatar Jan 20 '21 22:01 getnamo

Thank you for the response. I got it to work but I'm not sure what I might say is correct. It turns there was something wrong with my Python code which generated the error.

youngbin-song avatar Jan 27 '21 04:01 youngbin-song

Interesting, if you find out what it was later, let us know here so we can have the instructions others who may do the same.

getnamo avatar Jan 27 '21 05:01 getnamo

This is just my hypothesis but whenever there were errors like syntax, spacing, indexing errors, the output log in UE4 would just print that 'TensorflowComponent' object has no attribute 'tfapi'. As a fix, I just made sure that there were no errors in the python code and it worked fine for me.

youngbin-song avatar Jan 27 '21 08:01 youngbin-song