TLDR
I got this error and fixed it by modifying line 2 and 3 of app.Dockerfile.
Error: AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline'
To replicatedocker build -f docker/app.Dockerfile -t san_app .docker run -it --shm-size 4G -p 7860:7860 san_app
Fix
Change docker/app.Dockerfile to this:
RUN pip install 'git+https://github.com/facebookresearch/detectron2.git'
RUN pip install cython scipy shapely timm h5py submitit scikit-image wandb setuptools numpy Pillow pycocotools~=2.0.4 fvcore tabulate tqdm ftfy regex open_clip_torch cityscapesscripts tensorboard gradio
RUN useradd -m -u 1000 user
# Switch to the "user" user
USER user
# Set home to the user's home directory
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set the working directory to the user's home directory
WORKDIR $HOME
RUN git clone https://github.com/MendelXu/SAN app
WORKDIR $HOME/app
ENV GRADIO_SERVER_NAME=0.0.0.0
EXPOSE 7860
RUN echo "gradio app.py">>run.sh
CMD ["script","-c","sh run.sh","/dev/null"]
Discussion
I also tried messing around with opencv-python versions, but only ran into other cv2 or libGL errors. Eventually, I found this issue in https://github.com/opencv/opencv-python/issues/867, and noticed that detectron2 was also installing cv2. So I changed the dockerfile to install dectron2 first, and not install opencv-python after that. And it worked.
TLDR I got this error and fixed it by modifying line 2 and 3 of app.Dockerfile.
Error:
AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline'
To replicate
docker build -f docker/app.Dockerfile -t san_app .
docker run -it --shm-size 4G -p 7860:7860 san_app
Fix Change docker/app.Dockerfile to this:
Discussion I also tried messing around with opencv-python versions, but only ran into other cv2 or libGL errors. Eventually, I found this issue in https://github.com/opencv/opencv-python/issues/867, and noticed that detectron2 was also installing cv2. So I changed the dockerfile to install dectron2 first, and not install opencv-python after that. And it worked.