Comments (11)
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.
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.
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.
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.
What system do you use?
from facerecognition.
Windows 10 and running python 3.5 Anaconda
from facerecognition.
That explains it. I'll update the code to handle this as well
from facerecognition.
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.
it doesn't work in pycharm
from facerecognition.
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.
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)
- Memory lack! with Tensorflow oom on GPU HOT 1
- Wrong Recognition of Faces HOT 5
- Doesn't run on OSX Mojave 10.14.2 HOT 2
- Low FPS HOT 1
- No module name CV2 HOT 2
- Save and load embeddings HOT 2
- how to train pic to match face id and use mtcnn which features to detect HOT 6
- How do add new person image in model runtime. HOT 3
- Add video source input
- Can we use for large scale Video Surveillance? HOT 1
- Recognize a person's profile HOT 8
- How to load model and images in this project HOT 2
- Remove padding HOT 1
- Dataset used to train mtcnn HOT 1
- What algorithm did you use in this project? HOT 13
- Where does code be used to recognition in file detect_facese_real_time.py ? HOT 1
- How to add UNknown label for untrained images HOT 10
- Error Running Code
- Name not showing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facerecognition.