ValueError: Unknown graph. Aborting

This happens as soon as I try to load my Keras-retinanet model & can only be resolved after clearing the cache and reloading the page.

This happens every time I run my first prediction.

ValueError: Unknown graph. Aborting.

File “/home/linus/miniconda3/envs/license_plate/lib/python3.7/site-packages/streamlit/script_runner.py”, line 324, in _run_script
exec(code, module.dict)
File “/home/linus/Desktop/GitHub/Automatic-License-Plate-Recognition/app.py”, line 562, in
annotated_image, score, draw, b, crop_list = detector(IMAGE_PATH)
File “/home/linus/Desktop/GitHub/Automatic-License-Plate-Recognition/app.py”, line 226, in detector
boxes, scores, labels = inference(model, image, scale) # session
File “/home/linus/miniconda3/envs/license_plate/lib/python3.7/site-packages/streamlit/caching.py”, line 593, in wrapped_func
return get_or_create_cached_value()
File “/home/linus/miniconda3/envs/license_plate/lib/python3.7/site-packages/streamlit/caching.py”, line 573, in get_or_create_cached_value
return_value = func(*args, **kwargs)
File “/home/linus/Desktop/GitHub/Automatic-License-Plate-Recognition/app.py”, line 177, in inference
boxes, scores, labels = model.predict_on_batch(np.expand_dims(image, axis=0))
File “/home/linus/miniconda3/envs/license_plate/lib/python3.7/site-packages/keras/engine/training.py”, line 1579, in predict_on_batch
self._make_predict_function()
File “/home/linus/miniconda3/envs/license_plate/lib/python3.7/site-packages/keras/engine/training.py”, line 378, in _make_predict_function
**kwargs)
File “/home/linus/miniconda3/envs/license_plate/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py”, line 3009, in function
**kwargs)
File “/home/linus/miniconda3/envs/license_plate/lib/python3.7/site-packages/tensorflow/python/keras/backend.py”, line 3825, in function
return EagerExecutionFunction(inputs, outputs, updates=updates, name=name)
File “/home/linus/miniconda3/envs/license_plate/lib/python3.7/site-packages/tensorflow/python/keras/backend.py”, line 3709, in init
raise ValueError(‘Unknown graph. Aborting.’)

Instead of loading the model globally, it’s only loading when a sub-page is entered. This solved my problem.

1 Like