Comments (2)
Hi,
I found that GUI but I do not know how should I extract this information. So I write a python script for extracting this information, where output file have format
path x y w h
Maybe someone will want to use it.
import sqlite3
list_annotation = list()
# Format for saving: path x y w h
ann_format = "{}/{} {} {} {} {}"
conn = sqlite3.connect('aflw.sqlite')
print "Opened database successfully"
# Get all Face ID
fidQuery = 'SELECT face_id FROM Faces'
faceIDs = conn.execute(fidQuery)
for idx in faceIDs:
# Get ImgID connected to face
fidQuery = 'SELECT file_id FROM Faces WHERE face_id = {}'.format(idx[0])
imgID = conn.execute(fidQuery)
imgID = [id for id in imgID]
# Get image name and DB ID
imgDataQuery = "SELECT db_id,filepath,width,height FROM FaceImages WHERE file_id = '{}'".format(imgID[0][0])
fileID = conn.execute(imgDataQuery)
fileID = [id for id in fileID]
db_id = fileID[0][0]
filepath = fileID[0][1]
# Get Face Rect
faceRectQuery = 'SELECT x,y,w,h FROM FaceRect WHERE face_id = {}'.format(idx[0])
faceRect = conn.execute(faceRectQuery)
faceRect = [id for id in faceRect]
x,y,w,h = faceRect[0]
list_annotation.append(ann_format.format(db_id,filepath,x,y,w,h))
with open("AFLW_ann.txt",'w') as f:
f.writelines("%s\n" % line for line in list_annotation)
and this is changed aflw.py for a new format.
import numpy as np
import cv2
import os
data_base_dir = "/media/blcv/drive_2TB/Face/AFLW/aflw/data/" # file containing pictures
save_dir = "/media/blcv/drive_2TB/CODE/Face_Detection/CNN_face_detection/Data/positive" # file to save cropped male faces
read_file_name_faces = "AFLW_ann.txt" # file with path to image and rect
faceID_fileName_dict = {} # dictionary of str to str
if not os.path.isdir(save_dir): os.makedirs(save_dir)
# =========== read face file ===============
with open(read_file_name_faces, "r") as ins:
for line in ins:
path,x,y,w,h = line.strip().split(" ")
id_image = os.path.basename(path).split(".")[0]
faceID_fileName_dict[id_image] = (path,int(x),int(y),int(w),int(h))
# =========== Start processing ===============
i = 0
for key,value in faceID_fileName_dict.iteritems():
if i % 10 == 0:
print "Processing rect number " + str(i)
path,x,y,w,h = value
x = max(0, x)
y = max(0, y)
read_img_name = os.path.join(data_base_dir, path)
if not os.path.exists(read_img_name): # check if file exists
continue
img = cv2.imread(read_img_name) # read image
cropped_img = img[y : y + h, x : x + w]
file_name = os.path.join(save_dir ,str(key).zfill(6) + ".jpg")
cv2.imwrite(file_name, cropped_img)
i += 1
from cnn_face_detection.
Hi, I remember I used a GUI interface (Qt?) to connect to the SQLITE database.
Well, I just wanted to see if it was able to do gender recognition at the same time.
The accuracy was pretty high, but I didn't really need it so I didn't use it.
If you need it, you can just modify the labels to be 3 bins instead of binary classfication.
from cnn_face_detection.
Related Issues (20)
- approximate Threshold T1 and T2 HOT 4
- About the result after running HOT 4
- Number of face detected in 2002/07/19/big/img_352.jpg HOT 1
- About the training step HOT 4
- A question about the cascade cnn HOT 2
- About the face size in create_face_12c.sh HOT 6
- How to train calibration nets?
- 3000 images without any faces (negative images) HOT 2
- How to implement the Multi-resolution net structure HOT 5
- Speed Problem HOT 1
- AFLW new website can't find AFLW_Faces.txt HOT 1
- create negative_py HOT 9
- train_val.prototxt about FCN HOT 3
- many false face HOT 1
- calibration_AFLW.py new code HOT 5
- Resize images when creatiing LMDB file HOT 2
- About the training step HOT 1
- About the test result HOT 1
- How to get the file face12c_full_conv.caffemodel HOT 2
- How to python caffe to test the model
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 cnn_face_detection.