-
Notifications
You must be signed in to change notification settings - Fork 719
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
Error con la deteccion de objetos #5
Comments
Parece estar relacionado con el modo "eager" de Keras.
¿puedes probar a deshabilitarlo al principio de todo?
Es distinto según la versión de Tensorflow/Keras que uses.
En este enlace de StackOverflow comentan diversas formas de hacerlo:
https://stackoverflow.com/questions/53429896/how-do-i-disable-tensorflows-eager-execution
El mié, 13 sept 2023 a las 11:20, StillOnIt ***@***.***>)
escribió:
… Cuando uso el código obtengo el siguiente error:
------------------------------
RuntimeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_9920/3701537150.py in
1 # instanciamos al modelo
----> 2
*yolo = YOLO(input_size = tamanio, 3 labels = labels, 4 max_box_per_image
= 30,#poner numero de elementos max que se pueden encontrar en una imagen 5
anchors = anchors)*
~\AppData\Local\Temp/ipykernel_9920/3061781346.py in *init*(self,
input_size, labels, max_box_per_image, anchors)
21 self.feature_extractor = FullYoloFeature(self.input_size)
22
---> 23 print(self.feature_extractor.get_output_shape())
24 self.grid_h, self.grid_w = self.feature_extractor.get_output_shape()
25 features = self.feature_extractor.extract(input_image)
~\AppData\Local\Temp/ipykernel_9920/1111685552.py in get_output_shape(self)
22
23 def get_output_shape(self):
---> 24 print(self.feature_extractor.get_output_shape_at(-1)[1:3])
25 return self.feature_extractor.get_output_shape_at(-1)[1:3]
26
~\anaconda3\lib\site-packages\keras\engine\base_layer.py in
get_output_shape_at(self, node_index)
2091 RuntimeError: If called in Eager mode.
2092 """
-> 2093 return self._get_node_attribute_at_index(node_index,
'output_shapes',
2094 'output shape')
2095
~\anaconda3\lib\site-packages\keras\engine\base_layer.py in
_get_node_attribute_at_index(self, node_index, attr, attr_name)
2699 """
2700 if not self._inbound_nodes:
-> 2701 raise RuntimeError(f'The layer {self.name} has never been called '
2702 'and thus has no defined {attr_name}.')
2703 if not len(self._inbound_nodes) > node_index:
RuntimeError: The layer model_24 has never been called and thus has no
defined {attr_name}.
Para poder usar el código he tenido que adaptar la función
"leer_annotations" para que en vez de xml leyera el json de cada imagen.
—
Reply to this email directly, view it on GitHub
<#5>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEJCUPJYL5WXFO5FIJ7BT63X2F3GLANCNFSM6AAAAAA4WDG6DE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Me sigue dando error, pero esta vez el error es el siguiente: RuntimeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_14212/3061781346.py in init(self, input_size, labels, max_box_per_image, anchors) ~\AppData\Local\Temp/ipykernel_14212/1252490487.py in get_output_shape(self) ~\anaconda3\lib\site-packages\keras\engine\base_layer_v1.py in get_output_shape_at(self, node_index) ~\anaconda3\lib\site-packages\keras\engine\base_layer_v1.py in _get_node_attribute_at_index(self, node_index, attr, attr_name) RuntimeError: The layer has never been called and thus has no defined output shape. |
En principio no me doy cuenta de la causa del fallo. Veo que surge al
querer hacer un "print".
¿Que pasa si comentas esa línea? ¿Sigue dando error?
El mié, 13 sept 2023 a las 12:05, StillOnIt ***@***.***>)
escribió:
… Me sigue dando error, pero esta vez el error es el siguiente:
RuntimeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_14212/3701537150.py in
1 # instanciamos al modelo
----> 2 yolo = YOLO(input_size = tamanio,
3 labels = labels,
4 max_box_per_image = 30,#poner numero de elementos max que se pueden
encontrar en una imagen
5 anchors = anchors)
~\AppData\Local\Temp/ipykernel_14212/3061781346.py in *init*(self,
input_size, labels, max_box_per_image, anchors)
21 self.feature_extractor = FullYoloFeature(self.input_size)
22
---> 23 print(self.feature_extractor.get_output_shape())
24 self.grid_h, self.grid_w = self.feature_extractor.get_output_shape()
25 features = self.feature_extractor.extract(input_image)
~\AppData\Local\Temp/ipykernel_14212/1252490487.py in
get_output_shape(self)
25
26 def get_output_shape(self):
---> 27 return self.feature_extractor.get_output_shape_at(-1)[1:3]
28
29 def extract(self, input_image):
~\anaconda3\lib\site-packages\keras\engine\base_layer_v1.py in
get_output_shape_at(self, node_index)
1483 RuntimeError: If called in Eager mode.
1484 """
-> 1485 return self._get_node_attribute_at_index(node_index,
'output_shapes',
1486 'output shape')
1487
~\anaconda3\lib\site-packages\keras\engine\base_layer_v1.py in
_get_node_attribute_at_index(self, node_index, attr, attr_name)
2038 """
2039 if not self._inbound_nodes:
-> 2040 raise RuntimeError('The layer has never been called '
2041 'and thus has no defined ' + attr_name + '.')
2042 if not len(self._inbound_nodes) > node_index:
RuntimeError: The layer has never been called and thus has no defined
output shape.
—
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEJCUPL2G4QRAOXZT56A56TX2GAQPANCNFSM6AAAAAA4WDG6DE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Si, el error se sigue dando por el siguiente paso self.grid_h, self.grid_w = self.feature_extractor.get_output_shape() |
Tienes descargados los pesos de la darknet?
Se cargan en la línea
self.feature_extractor.load_weights(FULL_YOLO_BACKEND_PATH)
Puedes comprobar que tienes bien la ruta.
Se descarga desde
https://drive.google.com/file/d/1tZj4KZx2ItnAAvPI-ftKT8Yl4y0tQC6q/view?usp=sharing
y lo copias al mismo directorio del proyecto, se declara al principio con
FULL_YOLO_BACKEND_PATH = "full_yolo_backend.h5"
El mié, 13 sept 2023 a las 13:28, StillOnIt ***@***.***>)
escribió:
… Si, el error se sigue dando por el siguiente paso self.grid_h, self.grid_w
= self.feature_extractor.get_output_shape()
—
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEJCUPOFGS6MK3OURJVT23LX2GKFNANCNFSM6AAAAAA4WDG6DE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Cuando uso el código obtengo el siguiente error:
RuntimeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_9920/3701537150.py in
1 # instanciamos al modelo
----> 2 yolo = YOLO(input_size = tamanio,
3 labels = labels,
4 max_box_per_image = 30,#poner numero de elementos max que se pueden encontrar en una imagen
5 anchors = anchors)
~\AppData\Local\Temp/ipykernel_9920/3061781346.py in init(self, input_size, labels, max_box_per_image, anchors)
21 self.feature_extractor = FullYoloFeature(self.input_size)
22
---> 23 print(self.feature_extractor.get_output_shape())
24 self.grid_h, self.grid_w = self.feature_extractor.get_output_shape()
25 features = self.feature_extractor.extract(input_image)
~\AppData\Local\Temp/ipykernel_9920/1111685552.py in get_output_shape(self)
22
23 def get_output_shape(self):
---> 24 print(self.feature_extractor.get_output_shape_at(-1)[1:3])
25 return self.feature_extractor.get_output_shape_at(-1)[1:3]
26
~\anaconda3\lib\site-packages\keras\engine\base_layer.py in get_output_shape_at(self, node_index)
2091 RuntimeError: If called in Eager mode.
2092 """
-> 2093 return self._get_node_attribute_at_index(node_index, 'output_shapes',
2094 'output shape')
2095
~\anaconda3\lib\site-packages\keras\engine\base_layer.py in _get_node_attribute_at_index(self, node_index, attr, attr_name)
2699 """
2700 if not self._inbound_nodes:
-> 2701 raise RuntimeError(f'The layer {self.name} has never been called '
2702 'and thus has no defined {attr_name}.')
2703 if not len(self._inbound_nodes) > node_index:
RuntimeError: The layer model_24 has never been called and thus has no defined {attr_name}.
Para poder usar el código he tenido que adaptar la función "leer_annotations" para que en vez de xml leyera el json de cada imagen.
The text was updated successfully, but these errors were encountered: