Dlib: AttributeError: 'module' object has no attribute 'image_window'

Created on 24 Oct 2016  Â·  17Comments  Â·  Source: davisking/dlib

I followed these instructions:

git clone [email protected]:davisking/dlib.git

cd dlib

python setup.py install --yes DLIB_JPEG_SUPPORT

python python_examples/face_detector.py examples/faces/2007_007763.jpg

However, I get the error:

Traceback (most recent call last):
File "python_examples/face_detector.py", line 52, in
win = dlib.image_window()
AttributeError: 'module' object has no attribute 'image_window'

Most helpful comment

What I did..
step 1: installed cmake
step 2: installed dlib
step 3: got the same error
step 4: installed x11
step 5: still got the same error
after that...
step 6: uninstalled dlib "sudo pip3 uninstall dlib"
step 7: installed dlib again
now it is working fine

problem might be while installing dlib we need to have x11 installed.

All 17 comments

You almost certainly should have gotten a message about dlib not enabling the GUI components when you built it. It should also have said something about how you need to install X11 to use the GUi.

I had a try ,but it doesn't work also.The shell show that the same error.

Install X11

In fact, one of the messages output by cmake tell you to do this. If you are on Ubuntu it literally tells you what to type to install X11. On Mac it gives you a URL where you can download an X11 installer. Are you guys not seeing these messages?

For example, on Ubuntu, this message is output by cmake:

*****************************************************************************
*** DLIB GUI SUPPORT DISABLED BECAUSE X11 DEVELOPMENT LIBRARIES NOT FOUND ***
*** Make sure libx11-dev is installed if you want GUI support.            ***
*** On Ubuntu run: sudo apt-get install libx11-dev                        ***
*****************************************************************************

It's even surrounded by a huge ASCII art box. I'm at a loss for how I could make this more obvious.

Hi David,
I was getting a similar error while running an object detector code. I however have x11 installed on my system.
The code I have written is:
import os
import glob
import ipdb
import dlib
from skimage import io
import ipdb
images_folder = '/home/charul/kaggle_conservatory/train/ALT'
path_images = '/home/charul/dlib/tools/imglab/build'
options = dlib.simple_object_detector_training_options()
options.add_left_right_image_flips = True
options.C = 5
options.num_threads = 4
options.be_verbose = True
ipdb.set_trace()
training_xml_path = os.path.join(path_images, "new_train.xml")
dlib.train_simple_object_detector(training_xml_path, "detector.svm", options)
detector = dlib.simple_object_detector("detector.svm")
win_det = dlib.image_window()
win_det.set_image(detector)
print("Showing detections on the images in the faces folder...")
win = dlib.image_window()
for f in glob.glob(os.path.join(images_folder, "*.jpg")):
print("Processing file: {}".format(f))
img = io.imread(f)
dets = detector(img)
print("Number of faces detected: {}".format(len(dets)))
for k, d in enumerate(dets):
print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(
k, d.left(), d.top(), d.right(), d.bottom()))

win.clear_overlay()
win.set_image(img)
win.add_overlay(dets)
dlib.hit_enter_to_continue()

And I am getting an error on the line: win_det = dlib.image_window()
Error is : AttributeError: "'module' object has no attribute 'image_window'"

Any guidance would be really appreciated.

Thanks,
Charul

My answer to this is the same. You need to compile against X11. CMake
outputs messages describing what is happening and if it doesn't find X11 it
says so, and even includes instructions telling you what to do.

Hi Davis,
Thank you for all your time.
I get this output when I try to install x11.

charul@ubuntu:~$ sudo apt-get install libx11-dev
[sudo] password for charul:
Reading package lists... Done
Building dependency tree
Reading state information... Done
libx11-dev is already the newest version (2:1.6.3-1ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 196 not upgraded.

This shows that x11 is in place. I dont know what the difficulty is in that
case.

Thanks,
Charul

On Tue, Dec 13, 2016 at 7:22 PM, Davis E. King notifications@github.com
wrote:

My answer to this is the same. You need to compile against X11. CMake
outputs messages describing what is happening and if it doesn't find X11 it
says so, and even includes instructions telling you what to do.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/davisking/dlib/issues/302#issuecomment-266743470, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AXJZwPXRwoGzra0ceU6nS0fHEjhAhE2rks5rHqMdgaJpZM4KfErR
.

--
Thanks & Regards,

Charul Agrawal
Associate
PwC
+91-8860148925 | charul.r.[email protected]


The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries.

Try reinstalling dlib from the conda-forge channel: "conda install -c conda-forge dlib"

Hi guys,
I also installed x11 but its not working for me. Plz if someone have another solution. Tell me.

Output:
Found 1 faces in the image file ci.jpg
Traceback (most recent call last):
File "affine_df.py", line 36, in
dlib.image_window.set_image(image)
AttributeError: 'module' object has no attribute 'image_window'

Thanks

installing xquartz fixed issue in mac

What I did..
step 1: installed cmake
step 2: installed dlib
step 3: got the same error
step 4: installed x11
step 5: still got the same error
after that...
step 6: uninstalled dlib "sudo pip3 uninstall dlib"
step 7: installed dlib again
now it is working fine

problem might be while installing dlib we need to have x11 installed.

Yes, you definitely need to install X11 first.

Dlib installation gives error later on when installed using:
conda install -c menpo dlib
or
conda install -c conda-forge dlib

installing it inside the conda environment when done from source is when it worked finally and above error didnt came.

steps i used:
conda install cmake

git clone https://github.com/davisking/dlib.git
cd dlib/
python setup.py install --yes USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA

boost-python is not needed or used. You also don't need to run cmake before running setup.py. That doesn't do anything related to using dlib in python.

Have installed dlib via conda install -y -c menpo dlib==19.9.0

On this https://github.com/davisking/dlib/blob/master/python_examples/face_landmark_detection.py example it gives AttributeError: module 'dlib' has no attribute 'image_window'

Any pip install or conda install version that work?

I have installed x11 from https://www.xquartz.org/ based on message from dlib and recompiled dlib by running command
python setup.py install
I logged out and logged back in
and ran my python code
I still get same error File "train_detector.py", line 61, in
win = dlib.image_window()
AttributeError: module 'dlib' has no attribute 'image_window'

I am on MAC OS 10.14.6 and installed dlib 19.19.99

Was this page helpful?
0 / 5 - 0 ratings