Skip to content

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

@LOActualControl

Description

@LOActualControl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions