Upload files to 'Events/src'
Este commit está contenido en:
@@ -487,7 +487,7 @@ def eventwise():
|
|||||||
with multiprocessing.Pool(processes=10) as pool:
|
with multiprocessing.Pool(processes=10) as pool:
|
||||||
results = pool.map(download,url_list)
|
results = pool.map(download,url_list)
|
||||||
pool.close()
|
pool.close()
|
||||||
return "none"
|
return "Done"
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host="0.0.0.0",port=8081)
|
app.run(host="0.0.0.0",port=8081)
|
||||||
+65
-48
@@ -8,8 +8,8 @@ import cv2
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config["IMAGE_UPLOADS"] = "C:/Users/Bizgaze/PycharmProjects/face_recogniction/People"
|
app.config["IMAGE_UPLOADS"] = "C:/Users/Bizgaze/PycharmProjects/face_recogniction/People"
|
||||||
datasetPath = "./Gallery/"
|
datasetPath = "/opt/bizgaze/events.bizgaze.app/wwwroot/_files/1/Gallery/"
|
||||||
peoplePath = "./guestimage/"
|
peoplePath = "/opt/bizgaze/events.bizgaze.app/wwwroot/_files/People/"
|
||||||
@app.route('/', methods=['GET'])
|
@app.route('/', methods=['GET'])
|
||||||
def home():
|
def home():
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
@@ -44,7 +44,9 @@ def upload():
|
|||||||
|
|
||||||
@app.route('/predict', methods=["GET", "POST"])
|
@app.route('/predict', methods=["GET", "POST"])
|
||||||
def predict():
|
def predict():
|
||||||
|
print('starting')
|
||||||
def saveEncodings(encs, names, fname="encodings.pickle"):
|
def saveEncodings(encs, names, fname="encodings.pickle"):
|
||||||
|
print('encoding')
|
||||||
"""
|
"""
|
||||||
Save encodings in a pickle file to be used in future.
|
Save encodings in a pickle file to be used in future.
|
||||||
|
|
||||||
@@ -153,7 +155,7 @@ def predict():
|
|||||||
"""
|
"""
|
||||||
duplicateName = ""
|
duplicateName = ""
|
||||||
distance = 0.0
|
distance = 0.0
|
||||||
matches = face_recognition.compare_faces(known_encodings, unknown_encoding, tolerance=0.5)
|
matches = face_recognition.compare_faces(known_encodings, unknown_encoding, tolerance=0.47)
|
||||||
face_distances = face_recognition.face_distance(known_encodings, unknown_encoding)
|
face_distances = face_recognition.face_distance(known_encodings, unknown_encoding)
|
||||||
best_match_index = np.argmin(face_distances)
|
best_match_index = np.argmin(face_distances)
|
||||||
distance = face_distances[best_match_index]
|
distance = face_distances[best_match_index]
|
||||||
@@ -324,9 +326,9 @@ def predict():
|
|||||||
|
|
||||||
processKnownPeopleImages()
|
processKnownPeopleImages()
|
||||||
processDatasetImages()
|
processDatasetImages()
|
||||||
shutil.make_archive('./Images', 'zip','./output')
|
# shutil.make_archive('./Images', 'zip','./output')
|
||||||
p='./Images.zip'
|
# p='./Images.zip'
|
||||||
return send_file(p,as_attachment=True)
|
# return send_file(p,as_attachment=True)
|
||||||
|
|
||||||
|
|
||||||
# import pandas as pd
|
# import pandas as pd
|
||||||
@@ -343,52 +345,65 @@ def predict():
|
|||||||
|
|
||||||
|
|
||||||
##############################csv creation code ##############################
|
##############################csv creation code ##############################
|
||||||
# import pandas as pd
|
import pandas as pd
|
||||||
# q = pd.DataFrame(p)
|
q = pd.DataFrame(p)
|
||||||
# m = q
|
m = q
|
||||||
# print(m)
|
#print(m)
|
||||||
# # x.drop(x.columns[Unnam], axis=1, inplace=True)
|
# x.drop(x.columns[Unnam], axis=1, inplace=True)
|
||||||
# df = m.groupby([0], as_index=False).count()
|
df = m.groupby([0], as_index=False).count()
|
||||||
# z = df[0].str.split('/', expand=True)
|
first_column_name = df.columns[0]
|
||||||
|
|
||||||
# z['ImagePath'] = z[3]
|
# Rename the first column
|
||||||
|
df.rename(columns={first_column_name: 'col'}, inplace=True)
|
||||||
|
#print(df)
|
||||||
|
z = df['col'].str.split('/', expand=True)
|
||||||
|
|
||||||
# result = z.drop([0,1,3], axis=1)
|
z['ImagePath'] = z[3]
|
||||||
# result.rename({result.columns[-1]: 'test'}, axis=1, inplace=True)
|
|
||||||
# # print(result)
|
|
||||||
# result.to_csv('results1.csv')
|
|
||||||
# import pandas as pd
|
|
||||||
# import os
|
|
||||||
# c = []
|
|
||||||
# for root, dirs, files in os.walk("./Dataset", topdown=False):
|
|
||||||
# for name in files:
|
|
||||||
# # print(name)
|
|
||||||
# L = os.path.join(root, name)
|
|
||||||
# c.append(L)
|
|
||||||
# df = pd.DataFrame(c)
|
|
||||||
|
|
||||||
# df1 = df[0].str.split("/", expand=True)
|
result = z.drop([0,1,3], axis=1)
|
||||||
# df1.rename({df1.columns[-2]: 'abc'}, axis=1, inplace=True)
|
result.rename({result.columns[-1]: 'test'}, axis=1, inplace=True)
|
||||||
# print('this is df1')
|
# print(result)
|
||||||
# print(df1)
|
result.to_csv('results1.csv')
|
||||||
# df1.rename({df1.columns[-1]: 'test'}, axis=1, inplace=True)
|
import pandas as pd
|
||||||
# merge = pd.merge(df1, result, on='test', how='left')
|
import os
|
||||||
# merge.to_csv('merge.csv')
|
c = []
|
||||||
# mergesplit = merge.loc[:,'test'].str.split(".", expand=True)
|
for root, dirs, files in os.walk(datasetPath, topdown=False):
|
||||||
# mergesplit.rename({mergesplit.columns[-2]: 'ImageName'}, axis=1, inplace=True)
|
for name in files:
|
||||||
# mergesplit = mergesplit.loc[:,'ImageName' ]
|
# print(name)
|
||||||
|
L = os.path.join(root, name)
|
||||||
|
c.append(L)
|
||||||
|
df = pd.DataFrame(c)
|
||||||
|
#print('seconfdf')
|
||||||
|
|
||||||
# merge.rename({merge.columns[-1]: 'Matched'}, axis=1, inplace=True)
|
first_column_name = df.columns[0]
|
||||||
# merge['EventName'] = merge['abc']
|
|
||||||
# merge['Imagepath']="/_files/1/Gallery/"+merge['EventName']+'/'+ + merge['test']
|
|
||||||
|
|
||||||
# frames = [merge, mergesplit]
|
# Rename the first column
|
||||||
|
df.rename(columns={first_column_name: 'col'}, inplace=True)
|
||||||
|
print(df)
|
||||||
|
df1 = df['col'].str.split("/", expand=True)
|
||||||
|
df1.rename({df1.columns[-2]: 'abc'}, axis=1, inplace=True)
|
||||||
|
#print('this is df1')
|
||||||
|
#print(df1)
|
||||||
|
df1.rename({df1.columns[-1]: 'test'}, axis=1, inplace=True)
|
||||||
|
merge = pd.merge(df1, result, on='test', how='left')
|
||||||
|
merge.to_csv('merge.csv')
|
||||||
|
mergesplit = merge.loc[:,'test'].str.split(".", expand=True)
|
||||||
|
mergesplit.rename({mergesplit.columns[-2]: 'ImageName'}, axis=1, inplace=True)
|
||||||
|
mergesplit = mergesplit.loc[:,'ImageName' ]
|
||||||
|
|
||||||
# r = pd.concat(frames, axis=1, join='inner')
|
merge.rename({merge.columns[-1]: 'Matched'}, axis=1, inplace=True)
|
||||||
# r=r.iloc[:,3:]
|
merge['EventName'] = merge['abc']
|
||||||
# print(r)
|
merge['Imagepath']="/_files/1/Gallery/"+merge['EventName']+'/'+ + merge['test']
|
||||||
# r.to_csv('path.csv', index=False)
|
|
||||||
# r.to_json(r'./matched.json', orient="records")
|
frames = [merge, mergesplit]
|
||||||
|
|
||||||
|
r = pd.concat(frames, axis=1, join='inner')
|
||||||
|
r=r.iloc[:,3:]
|
||||||
|
#print(r)
|
||||||
|
r.to_csv('path.csv', index=False)
|
||||||
|
#r.to_json(r'./matched.json', orient="records")
|
||||||
|
column_list = ['Matched','Imagepath', 'ImageName', 'EventName']
|
||||||
|
r[column_list].to_json('matched.json', orient="records")
|
||||||
|
|
||||||
#############################################################################################
|
#############################################################################################
|
||||||
|
|
||||||
@@ -477,8 +492,10 @@ def predict():
|
|||||||
main()
|
main()
|
||||||
|
|
||||||
# return render_template('index.html')
|
# return render_template('index.html')
|
||||||
|
p = './matched.json'
|
||||||
|
return send_file(p,as_attachment=True)
|
||||||
|
|
||||||
return 'ALL IMAGES MATCHED'
|
# return 'ALL IMAGES MATCHED'
|
||||||
|
|
||||||
|
|
||||||
@app.route('/json')
|
@app.route('/json')
|
||||||
@@ -488,6 +505,6 @@ def json():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host="0.0.0.0",port=8081,debug=True)
|
app.run(host="0.0.0.0",port=8081)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Referencia en una nueva incidencia
Block a user