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

Lycon issues #142

Closed
louis-marchant opened this issue Apr 26, 2019 · 12 comments
Closed

Lycon issues #142

louis-marchant opened this issue Apr 26, 2019 · 12 comments

Comments

@louis-marchant
Copy link

louis-marchant commented Apr 26, 2019

Been having problems all day with Lycon, it doesn't appear to work on my installation of MacOS (Mojave 10.14.4). I've tried two approaches, both leading to errors:

I installed the dependencies shown here https://github.com/ethereon/lycon using homebrew, and tried using MacOS inbuilt python3, but whenever lycon.load(file_path) is run, it returns None, causing an error in detect.py.

Alternatively I tried installing everything with Anaconda, and I get an (even worse) segmentation fault when trying to import Lycon.

Any idea what's going on?

Also, as mentioned in #102 there are several missing requirements in the requirements.txt as far as I can see, namely:

@eriklindernoren
Copy link
Owner

I'll see if I can find a better module. I wanted something that gives equal performance to OpenCV but without all the hassle of the OpenCV installation. Seems like multiple people have encountered issues installing Lycon though so I might have to go in that direction anyways. The speed-up over something like Pillow or scikit-image is significant so I don't like the idea using any of those for the dataloader. I'll make sure to update requirements.txt, thanks!

@eriklindernoren
Copy link
Owner

@k4kuz0 I just installed lycon successfully on my Mac (Mojave 10.14), by:
$ brew install cmake
$ pip3 install lycon

@louis-marchant
Copy link
Author

louis-marchant commented Apr 26, 2019

@eriklindernoren I had no issue installing Lycon, but if I tried loading any image in it would only return None, is this the case for you on your Mac? I installed Lycon in pretty much the same way using homebrew and pip3.

@eriklindernoren
Copy link
Owner

@k4kuz0 No it loads images just fine for me.

Eriks-MacBook-Pro-2:~ erik$ cd git/PyTorch-YOLOv3/
Eriks-MacBook-Pro-2:PyTorch-YOLOv3 erik$ python3
Python 3.7.3 (default, Apr  2 2019, 15:16:43) 
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lycon
>>> lycon.load("data/samples/dog.jpg").shape
(576, 768, 3)
>>> 

@dirtshell
Copy link

dirtshell commented Apr 27, 2019

I have a similar issue on Ubuntu 18.04 with lycon installed with pip.

I get a crash at util/datasets.py:89. It states that img is None. But if I load up a Python shell and import lycon and then attempt to load the same image that it crashed on, it loads up just fine and I get the correct dimensions.

Update: I just modified util/datasets.py to use cv2.imread(img_path) and I got the same error. Here is my traceback.

Traceback (most recent call last):
  File "train.py", line 91, in <module>
    for batch_i, (_, imgs, targets) in enumerate(dataloader):
  File "/home/jake/RIT/cmpe_685/final_project/PyTorch-YOLOv3/venv1/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 623, in __next__
    return self._process_next_batch(batch)
  File "/home/jake/RIT/cmpe_685/final_project/PyTorch-YOLOv3/venv1/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 658, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
AttributeError: Traceback (most recent call last):
  File "/home/jake/RIT/cmpe_685/final_project/PyTorch-YOLOv3/venv1/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 138, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/home/jake/RIT/cmpe_685/final_project/PyTorch-YOLOv3/venv1/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 138, in <listcomp>
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/home/jake/RIT/cmpe_685/final_project/PyTorch-YOLOv3/utils/datasets.py", line 90, in __getitem__
    if len(img.shape) != 3:
AttributeError: 'NoneType' object has no attribute 'shape'

@dirtshell
Copy link

After digging around in this issue a bit more, it really seems like a memory issue, where img is getting overwritten somehow, and becomes None. I can wrap the whole thing in a repeating loop with the entire function in a try clause, but that just means that you hit an issue with other functions that reference img. Something to do with the way numpy has these act as forks or something?

@eriklindernoren
Copy link
Owner

That is strange. It's also hard for me to debug this as I can't reproduce this issue. Does the same thing happen if you use PIL.Image, @dirtshell ?

@louis-marchant
Copy link
Author

@eriklindernoren PIL.Image works fine for me in loading the image, but Lycon produces None. I'm at a bit of a loss as to what I could have on my Mac that makes your installation work, but mine not. I tried downgrading my Python version to 3.5 as I noticed on the Lycon github page that they have only tested in macOS with Python 3.5, but to no avail.

@heatherlock
Copy link

I was experiencing the same error as @dirtshell When I pulled the latest from the repo, the error disappeared and everything ran smoothly.

@dirtshell
Copy link

dirtshell commented Apr 28, 2019

IDK what changed, but I did a pull like @heatherlock recommended and I am no longer having the issue when training with vanilla yolov3 and yolov3-tiny! I wonder if it has to do with the fact I am no longer able to use the downloaded weights?

@eriklindernoren
Copy link
Owner

I'm not sure what recent change fixed this either to be honest. @k4kuz0 Did this work for you as well?

@eriklindernoren
Copy link
Owner

I decided to revert to PIL.Image.open for loading images and torch.nn.functional.interpolate for image resizing. I benchmarked the two approaches and they were close enough to motivate the change.

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

4 participants