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

Missing ReadMe info? #1

Open
ProGamerGov opened this issue Dec 6, 2017 · 12 comments
Open

Missing ReadMe info? #1

ProGamerGov opened this issue Dec 6, 2017 · 12 comments

Comments

@ProGamerGov
Copy link

What do I need to change in order to use my own data set? What are the requirements? What order do I run the scripts? And what do I need to do in order to make each script work?

@ProGamerGov
Copy link
Author

ProGamerGov commented Dec 7, 2017

So starting with a folder containing a bunch of images with faces, it looks like the script is not that clear. Do I need to use a CSV file? Or was that just for stats relating to different players?

Combine.py needs the: '../Pictures/Difference/' directory, and writes to the ../Pictures/Result/Difference.png, and ../Pictures/CDifference/Output directories with what I think is the final output image?

Fill.py needs the: '../Pictures/Worked/' directory, and it writes images to the '../Pictures/Worked/' directory.

Plotter.py just puts the final output image on a plot.

Reshape.py needs the '../Pictures/Worked/' directory, and writes images to the: "../Pictures/Worked/" directory.

Size.py needs the ../Pictures/Left/, ../Pictures/Right/, and ../Pictures/Resize/ directories, and writes images to the ../Pictures/Resize/ directory.


So it looks like I have to first sort the images into right and left folders, before running Size.py and Reshape.py? Quality wise, I would think that Reshape.py should be done first, but Idk how to get the folders for Size.py?

Size.py requires ../Pictures/Resize/ , which Reshape.py creates, so Reshape.py comes before Size.py.

@ProGamerGov
Copy link
Author

ProGamerGov commented Dec 7, 2017

Should I be using OpenCV2 or ‎OpenCV3? Which version of Python do the scripts use?

@ProGamerGov
Copy link
Author

Ok, I installed OpenCV3, Dlibm and OpenBLAS via:

https://www.learnopencv.com/install-opencv3-on-ubuntu/

https://www.learnopencv.com/install-dlib-on-ubuntu/

sudo apt-get install libopenblas-dev

Trying to run your code results in:

ubuntu@ip-Address:~/Golfer-face-analysis$ python Image_processing/Reshape.py
Traceback (most recent call last):
  File "Image_processing/Reshape.py", line 2, in <module>
    import dlib
  File "/usr/local/lib/python2.7/dist-packages/dlib-19.6.0-py2.7-linux-x86_64.egg/dlib/__init__.py", line 1, in <module>
    from .dlib import *
ImportError: /usr/local/cuda-9.0/lib64/libcusolver.so.9.0: undefined symbol: GOMP_critical_end
ubuntu@ip-Address:~/Golfer-face-analysis$ 

@ProGamerGov
Copy link
Author

ProGamerGov commented Dec 7, 2017

Python3 versus Python2.7:

ubuntu@ip-Address:~/Golfer-face-analysis$ python3 Image_processing/meansd.py
Traceback (most recent call last):
  File "Image_processing/meansd.py", line 7, in <module>
    images                      = os.listdir(base)
FileNotFoundError: [Errno 2] No such file or directory: '../Pictures/Worked/'
ubuntu@ip-Address:~/Golfer-face-analysis$
ubuntu@ip-Address:~/Golfer-face-analysis$ python Image_processing/meansd.py
Traceback (most recent call last):
  File "Image_processing/meansd.py", line 4, in <module>
    import pandas as pd
ImportError: No module named pandas
ubuntu@ip-Address:~/Golfer-face-analysis$

Unsure of how to fix this error:

ubuntu@ip-Address:~/Golfer-face-analysis$ python3 Image_processing/Reshape.py
Traceback (most recent call last):
  File "Image_processing/Reshape.py", line 81, in <module>
    predictor   = dlib.shape_predictor('dlibcascades/shape_predictor_68_face_landmarks.dat')
RuntimeError: Unable to open dlibcascades/shape_predictor_68_face_landmarks.dat
ubuntu@ip-Address:~/Golfer-face-analysis$

Edit:

That error was caused by my renaming of the Image processing directory, to Image_processing. I did that because Ubuntu 16.04 Linux doesn't like spaces in directory names. Or at least spaces make things more difficult.

Or maybe the issues is related to a different directory structure?

@ProGamerGov
Copy link
Author

ProGamerGov commented Dec 7, 2017

So OpenCV3 and Python3 seem to work for the Reshape script, once I changed the directory names to match where I put the images.

So Reshape.py appears to have made my images completely black. Not sure why it did this, if this is intentional, or if it's something I need to fix?

@ProGamerGov
Copy link
Author

ProGamerGov commented Dec 7, 2017

Running Combine.py on the unmodified Images:

ubuntu@ip-Address:~/Golfer-face-analysis/Image_processing$ python3 Combine.py
OpenCV Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array') in arithm_op, file /home/ubuntu/opencv/modules/core/src/arithm.cpp, line 659
Traceback (most recent call last):
  File "Combine.py", line 13, in <module>
    cv2.addWeighted(image1, 1.0/(end - k) , output, 1.0/(end - k), 0, output)
cv2.error: /home/ubuntu/opencv/modules/core/src/arithm.cpp:659: error: (-209) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function arithm_op

ubuntu@ip-Addess:~/Golfer-face-analysis/Image_processing$

To run Fill.py, I needed to do sudo pip3 install python-resize-image.

Running Fill.py on unmodified images doesn't seem to do anything. Line number 1 of the Fill.py script needed to be commented out, for the script to work.


So I somehow need to Resize the images with Size.py, but that script has confusing "left" and "right" directories.

@ProGamerGov
Copy link
Author

ProGamerGov commented Dec 7, 2017

So Size.py requires 3 folders. I think that maybe the "Left" folder and "Right" Folder are for images that a flipped horizontally or something like that? Though when running that, only the Left side image got modified, and it sort of weirdly cropped out the background?

The Resize folder just has it's images resized. But the resizing does not take anything into account, so I think that might not work until some other step.

@ProGamerGov
Copy link
Author

ProGamerGov commented Dec 7, 2017

Using Reshape.py with the provided example images located at: https://github.com/SoumitraAgarwal/Golfer-face-analysis/tree/master/Pictures/Right, outputs the images with the faces and everything properly aligned, with a blocky cropping that removed most of the background. All the example input images are the same size, so I don't know if it resizes images as well.

I assume that once Reshape.py has been run, then Combine.py can be run on the outputs to create the final averaged image?

What are all the other scripts for?

@ProGamerGov
Copy link
Author

ProGamerGov commented Dec 7, 2017

So after using Reshape.py, I then used Combine.py on all the centered images. This created the final averaged output!

Though Combine.py did have some weird error:

ubuntu@ip-Address:~/Golfer-face-analysis/Image_processing$ python3 Combine.py
0
110
220
330
440
550
Traceback (most recent call last):
  File "Combine.py", line 26, in <module>
    output      = cv2.imread(base + images[0])
IndexError: list index out of range
ubuntu@ip-Address:~/Golfer-face-analysis/Image_processing$

Though that error does not appear to have caused the script to fail. The outputs were created, and they were created correctly.

@ProGamerGov
Copy link
Author

ProGamerGov commented Dec 7, 2017

Every custom image that I try with Reshape.py ends up either completely black, or with some random cropped/zoomed in section.

@ProGamerGov
Copy link
Author

It looks like these lines of code: https://github.com/SoumitraAgarwal/Golfer-face-analysis/blob/master/Image%20processing/Reshape.py#L199-L202, are responsible for the black images. Changing the values to match the ones output to the terminal while running Reshape.py, creates the images correctly, at least somewhat?

Do I have to run my entire data set through, and then average the values for replacing these values?

l_eyes = [1331, 601];
r_eyes = [1523, 577];
mouth  = [1432, 833];
nose   = [1406, 684];

@ProGamerGov
Copy link
Author

This project works really well for aligning faces: https://github.com/roblourens/facealign

You can also use SNFaceCrop to extract faces from images, but SNFaceCrop does not align the faces.

After you have your aligned faces, Combine.py is all you really need.

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

1 participant