Ros u-net usage error
I want to instantly process the data I receive from the car camera on via u-net. But I'm getting an error like this ;
[ERROR] [1602424911.184610, 2209.890000]: bad callback: <function func at 0x7fe16503cb50>
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "cvbridge-model.py", line 215, in func
hesapla(cv_goruntu)
File "cvbridge-model.py", line 185, in hesapla
sag = model.predict(right)
File "/home/bozkaya/.local/lib/python2.7/site-packages/keras/engine/training.py", line 1456, in predict
self._make_predict_function()
File "/home/bozkaya/.local/lib/python2.7/site-packages/keras/engine/training.py", line 378, in _make_predict_function
**kwargs)
File "/home/bozkaya/.local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 3009, in function
**kwargs)
File "/home/bozkaya/.local/lib/python2.7/site-packages/tensorflow/python/keras/backend.py", line 3479, in function
return GraphExecutionFunction(inputs, outputs, updates=updates, **kwargs)
File "/home/bozkaya/.local/lib/python2.7/site-packages/tensorflow/python/keras/backend.py", line 3142, in init
with ops.control_dependencies([self.outputs[0]]):
File "/home/bozkaya/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 5426, in control_dependencies
return get_default_graph().control_dependencies(control_inputs)
File "/home/bozkaya/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 4867, in control_dependencies
c = self.as_graph_element(c)
File "/home/bozkaya/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3796, in as_graph_element
return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
File "/home/bozkaya/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3875, in _as_graph_element_locked
raise ValueError("Tensor %s is not an element of this graph." % obj)
ValueError: Tensor Tensor("conv2d_19/Sigmoid:0", shape=(?, 64, 256, 3), dtype=float32) is not an element of this graph.
My code
#!/usr/bin/env python
-- coding: UTF-8 --
import rospy
import cv2
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
import sys
import filtre_2 as ft
import numpy as np
import time
from ackermann_msgs.msg import AckermannDriveStamped
model=ft.create_model()
model.load_weights("/home/bozkaya/catkin_ws/src/racecar-simulator/racecar_gazebo/scripts/weight3")
def hesapla(frame):
right = frame[226:,672:]
left = frame[226:,:672]
right=(right / 255.0).astype(np.float32)
left=(left / 255.0).astype(np.float32)
image_right=right[:,1:672]
right = cv2.resize(image_right, None, fx=(1.0/2.62), fy=(1.0/2.34), interpolation=cv2.INTER_AREA)
image_left=left[:,1:672]
left = cv2.resize(image_left, None, fx=(1.0/2.62), fy=(1.0/2.34), interpolation=cv2.INTER_AREA)
right.resize(1,64,256,3)
left.resize(1,64,256,3)
sag = model.predict(right)
sol = model.predict(left)
sag = np.reshape(sag,(64,256,3))
sol = np.reshape(sol,(64,256,3))
sag=(sag * 255.0).astype(np.uint8)
sol=(sol * 255.0).astype(np.uint8)
serit=np.zeros([64,512,3])
sag, sag_orta=nokta(sag)
sol, sol_orta=nokta(sol)
sag = cv2.resize(sag, (960, 540))
sol = cv2.resize(sol, (960, 540))
cv2.imshow("sag",sag)
cv2.imshow("sol",sol)
orta =(sag_orta+sol_orta)/2
return sag, orta
bridge ...