Skip to content
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

tkinter causes CustomObjectDetection module import failure in Google Cloud Function #803

Open
LOActualControl opened this issue Mar 10, 2023 · 2 comments

Comments

@LOActualControl
Copy link

Good afternoon,

I'm trying to upload a trained Custom Object Detection model to Google Cloud Storage and run inference using a Cloud Function. However, when I upload my function to the Google Cloud Platform, importing the CustomObjectDetection module fails. I think this is because one of the required packages is tkinter, which might not work in a cloud/headless platform? But I can't figure out why tkinter/a GUI would be required for imageai. Any help toward resolving this would be greatly appreciated! My code and the full stack trace of my error is below:

`import numpy as np
from imageai.Detection.Custom import CustomObjectDetection

def predict(self):
return "hello world"`

Deployment failure:
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Traceback (most recent call last):
File "/layers/google.python.pip/pip/bin/functions-framework", line 8, in
sys.exit(_cli())
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/functions_framework/_cli.py", line 37, in _cli
app = create_app(target, source, signature_type)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/functions_framework/init.py", line 288, in create_app
spec.loader.exec_module(source_module)
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/workspace/main.py", line 2, in
from imageai.Detection.Custom import CustomObjectDetection
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/imageai/Detection/init.py", line 2, in
from tkinter import Image
File "/layers/google.python.runtime/python/lib/python3.9/tkinter/init.py", line 37, in
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libBLT.2.5.so.8.6: cannot open shared object file: No such file or directory
. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.

@EdwinAguirre92
Copy link

Good afternoon,

I'm also getting the same issue but with Azure cloud platform. However, I'm not sure why we need tkinter because of the following:
image
It seems like he is defining Image in line 2 but later he redefines Image in line 5 , so this leads me to believe that perhaps we do not need tkinter?
Thoughts ?

@LOActualControl
Copy link
Author

Yeah I noticed the same thing too @EdwinAguirre92 ! In fact, I assume the rest of the Image references in the functions/classes that follow are from the PIL import, rather than the tkinter import. Perhaps tkinter isn't necessary after all - I ended up actually using a different package than ImageAI for my current project, but removing tkinter could be helpful for future projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants