GithubHelp home page GithubHelp logo

Comments (11)

m3m3-chan avatar m3m3-chan commented on September 7, 2024 2

I solved this by changing the function! So instead of split() I use dirname() and change this line:
self.id_names += [image_path.split('/')[-2]] * len(face_patches)
to self.id_names += [os.path.dirname(image_path)[-1]] * len(face_patches)

I think it's an issue with the backslash coz when I print the img_path I get this output:
img_path=./ids/m\m2.png
though I'm still curious why it couldn't work well for me only :/

thanks anyway 👍
EDIT: dirname() only doesn't solve the problem! I haven't noticed that coz I named all my id folders with 1 letter which is why dirname()[-1] worked so far (it gave me the last letter of the folder name)
I used the split() with dirname() and it's working well (tested it with long names this time):
self.id_names += [ os.path.dirname(image_path).split('/')[-1]] * len(face_patches)

from facerecognition.

jiulian avatar jiulian commented on September 7, 2024

I try to run the script and it displayed exactly the folder name that I set.

python main.py 20170512-110547/20170512-110547.pb ./ids/

Matches in frame:
Hi Johnson! Distance: 0.5655
Matches in frame:
Hi Johnson! Distance: 0.5174
Couldn't find a face

from facerecognition.

habrman avatar habrman commented on September 7, 2024

I just tried to set it up from scratch and it works for me as well. Can you please provide your exact folder structure and the command you use to run it all?

from facerecognition.

m3m3-chan avatar m3m3-chan commented on September 7, 2024

Hi Habrman,
I followed the same folder structure you proposed. So in the code folder, I have the following:
/model
│ ├── model
/ids
│ ├── Adam
│ │ ├── Adam0.png
│ │ ├── Adam1.png
│ ├── Eve
│ │ ├── Eve0.png

the command I use to run it: python main.py ./model/model.pb ./ids/

from playing around the code, I concluded that the problem lies in this line:
self.id_names += [image_path.split('/')[-2]] * len(face_patches)
turns out that the split function splits the paths in a way that it takes " Adam/Adam0.png" as one part. the last (/) in the path is not split.
I tried setting [-2] to [-1] & I get "Adam/Adam0.png" & when I tried [-0] (though it might not make any sense) but it gave me "Adam0.png"

for more info, I am running the code on python 3.5 on Windows 10.

from facerecognition.

habrman avatar habrman commented on September 7, 2024

What system do you use?

from facerecognition.

m3m3-chan avatar m3m3-chan commented on September 7, 2024

Windows 10 and running python 3.5 Anaconda

from facerecognition.

habrman avatar habrman commented on September 7, 2024

That explains it. I'll update the code to handle this as well

from facerecognition.

m3m3-chan avatar m3m3-chan commented on September 7, 2024

FYI, turns out it doesn't work with dirname() as I thought!
I updated my comment above & added the split to make it work.

from facerecognition.

Ryiel avatar Ryiel commented on September 7, 2024

it doesn't work in pycharm

from facerecognition.

habrman avatar habrman commented on September 7, 2024

Status update: I haven't spent any time on this but I will, one rainy day when I have nothing to do. This is due to how I handle paths in the code. I assume that the directories are separated by '/' but Windows uses '' which breaks some logic. It's not a big fix that's required.

from facerecognition.

alex-o98 avatar alex-o98 commented on September 7, 2024

changing
self.id_names += [image_path.split('/')[-2]] * len(face_patches)
to

path = os.path.dirname(image_path)
self.id_names += [os.path.basename(path)] * len(face_patches)

fixes the problem. This takes the name of the parent directory, instead of taking the name of the file and removing the last one/two numbers. This is better if you have a lot of pictures and you don't want to rename them.

It also works on both Linux and Windows (Based on habrman's last post)

from facerecognition.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.