Update 'Events/src/myproject2.py'
This commit is contained in:
+15
-113
@@ -10,46 +10,26 @@ 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 = "/opt/bizgaze/events.bizgaze.app/wwwroot/_files/1/Gallery/"
|
#datasetPath = "/opt/bizgaze/events.bizgaze.app/wwwroot/_files/1/Gallery/"
|
||||||
#peoplePath = "/opt/bizgaze/events.bizgaze.app/wwwroot/_files/People/"
|
#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')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/Display', methods=['GET', "POST"])
|
|
||||||
def Display():
|
|
||||||
return render_template('Display.html')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/upload", methods=["GET", "POST"])
|
|
||||||
def upload():
|
|
||||||
if request.method == "POST":
|
|
||||||
|
|
||||||
if request.files:
|
|
||||||
|
|
||||||
image = request.files["image"]
|
|
||||||
try:
|
|
||||||
image.save(os.path.join(
|
|
||||||
app.config["IMAGE_UPLOADS"], image.filename))
|
|
||||||
except IsADirectoryError:
|
|
||||||
return render_template('index.html')
|
|
||||||
# image.save(os.path.join(
|
|
||||||
# app.config["IMAGE_UPLOADS"], image.filename))
|
|
||||||
|
|
||||||
print("Image saved")
|
|
||||||
|
|
||||||
return redirect(request.url)
|
|
||||||
|
|
||||||
return 'ok'
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/predict', methods=["GET", "POST"])
|
@app.route('/predict', methods=["GET", "POST"])
|
||||||
def predict():
|
def predict():
|
||||||
Dataset = request.get_json()
|
Dataset = request.get_json()
|
||||||
a = Dataset
|
a = Dataset
|
||||||
peoplePath = a['People']
|
peoplePath = a['People']
|
||||||
print(peoplePath)
|
|
||||||
|
#print(peoplePath1)
|
||||||
datasetPath = a['Gallery']
|
datasetPath = a['Gallery']
|
||||||
print(datasetPath)
|
|
||||||
|
#print(datasetPath)
|
||||||
|
|
||||||
print('starting')
|
print('starting')
|
||||||
def saveEncodings(encs, names, fname="encodings.pickle"):
|
def saveEncodings(encs, names, fname="encodings.pickle"):
|
||||||
@@ -200,7 +180,9 @@ def predict():
|
|||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
os.mkdir(path)
|
if not os.path.exists(path):
|
||||||
|
os.makedirs(path)
|
||||||
|
# os.mkdir(path,exist_ok=True)
|
||||||
cv2.imwrite(path + "/" + imageName, image)
|
cv2.imwrite(path + "/" + imageName, image)
|
||||||
x = []
|
x = []
|
||||||
c = (path1 + "/" + imageName)
|
c = (path1 + "/" + imageName)
|
||||||
@@ -331,8 +313,8 @@ def predict():
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
processKnownPeopleImages()
|
processKnownPeopleImages(peoplePath)
|
||||||
processDatasetImages()
|
processDatasetImages(datasetPath)
|
||||||
# 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)
|
||||||
@@ -364,7 +346,6 @@ def predict():
|
|||||||
df.rename(columns={first_column_name: 'col'}, inplace=True)
|
df.rename(columns={first_column_name: 'col'}, inplace=True)
|
||||||
#print(df)
|
#print(df)
|
||||||
z = df['col'].str.split('/', expand=True)
|
z = df['col'].str.split('/', expand=True)
|
||||||
|
|
||||||
z['ImagePath'] = z[3]
|
z['ImagePath'] = z[3]
|
||||||
|
|
||||||
result = z.drop([0,1,3], axis=1)
|
result = z.drop([0,1,3], axis=1)
|
||||||
@@ -387,7 +368,7 @@ def predict():
|
|||||||
# Rename the first column
|
# Rename the first column
|
||||||
df.rename(columns={first_column_name: 'col'}, inplace=True)
|
df.rename(columns={first_column_name: 'col'}, inplace=True)
|
||||||
print(df)
|
print(df)
|
||||||
df1 = df['col'].str.split("/", expand=True)
|
df1 = df['col'].str.split("\\", expand=True)
|
||||||
df1.rename({df1.columns[-2]: 'abc'}, axis=1, inplace=True)
|
df1.rename({df1.columns[-2]: 'abc'}, axis=1, inplace=True)
|
||||||
#print('this is df1')
|
#print('this is df1')
|
||||||
#print(df1)
|
#print(df1)
|
||||||
@@ -400,7 +381,7 @@ def predict():
|
|||||||
|
|
||||||
merge.rename({merge.columns[-1]: 'Matched'}, axis=1, inplace=True)
|
merge.rename({merge.columns[-1]: 'Matched'}, axis=1, inplace=True)
|
||||||
merge['EventName'] = merge['abc']
|
merge['EventName'] = merge['abc']
|
||||||
merge['Imagepath']="/_files/1/Gallery/"+merge['EventName']+'/'+ + merge['test']
|
merge['Imagepath']= datasetPath+merge['EventName']+'/'+ + merge['test']
|
||||||
|
|
||||||
frames = [merge, mergesplit]
|
frames = [merge, mergesplit]
|
||||||
|
|
||||||
@@ -414,85 +395,6 @@ def predict():
|
|||||||
|
|
||||||
#############################################################################################
|
#############################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# merge.rename({merge.columns[-3]: 'ImagePath'}, axis=1, inplace=True)
|
|
||||||
#
|
|
||||||
# # print(merge)
|
|
||||||
# merge1 = merge.iloc[:, -2]
|
|
||||||
# merge12= merge.iloc[:, -3]
|
|
||||||
#
|
|
||||||
# # merge1.rename({merge1.columns[-1]: 'abc'}, axis=1, inplace=True)
|
|
||||||
# merge2 = merge.iloc[:, -1].str.split(".", expand=True)
|
|
||||||
# merge2.rename({merge2.columns[-1]: 'drop'}, axis=1, inplace=True)
|
|
||||||
# #merge2.rename({merge2.columns[-2]: 'ImageName'}, axis=1, inplace=True)
|
|
||||||
# print('this is merge1')
|
|
||||||
# print(merge1)
|
|
||||||
# print('this is merge2')
|
|
||||||
# print(merge2)
|
|
||||||
# mergefinal = pd.concat([merge1, merge2], axis=1, join='inner')
|
|
||||||
# # print(mergefinal)
|
|
||||||
# # print('-----------------')
|
|
||||||
#
|
|
||||||
# mergefinal.drop(columns=mergefinal.columns[-1], axis=1, inplace=True)
|
|
||||||
# # print(mergefinal)
|
|
||||||
# # print('--------------------------------------------------------------------------------')
|
|
||||||
# # mergefinal.rename({mergefinal.columns[-1]: 'ImageName'}, axis=1, inplace=True)
|
|
||||||
# # print('this is filename')
|
|
||||||
# # print(mergefinal)
|
|
||||||
# #mergefinal.rename({mergefinal.columns[-2]: 'EventName'}, axis=1, inplace=True)
|
|
||||||
# # print('this is foldername')
|
|
||||||
# # print(mergefinal)
|
|
||||||
#
|
|
||||||
# frames = [mergefinal, merge12]
|
|
||||||
#
|
|
||||||
# r = pd.concat(frames, axis=1, join='inner')
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# r.to_csv('Imagepath1.csv', index=False)
|
|
||||||
# r.to_json('Imagepath1.json', orient="records")
|
|
||||||
# import shutil
|
|
||||||
# import os
|
|
||||||
# # import shutil module
|
|
||||||
# import shutil
|
|
||||||
#
|
|
||||||
# # import os module
|
|
||||||
# import os
|
|
||||||
# #################### move code#############
|
|
||||||
# # base path
|
|
||||||
# base_path = 'C:\\Users\\Bizgaze\\PycharmProjects\\face_recogniction\\move'
|
|
||||||
# import os
|
|
||||||
# dir_list = []
|
|
||||||
# rootdir = 'C:\\Users\\Bizgaze\\PycharmProjects\\face_recogniction\\Dataset'
|
|
||||||
# for file in os.listdir(rootdir):
|
|
||||||
# d = os.path.join(rootdir, file)
|
|
||||||
# if os.path.isdir(d):
|
|
||||||
# dir_list.append(d)
|
|
||||||
#
|
|
||||||
# # list of directories we want to move.
|
|
||||||
# # dir_list = ['test2', 'test4', 'test5', 'does_not_exist']
|
|
||||||
#
|
|
||||||
# # path to destination directory
|
|
||||||
# # dest = os.path.join(base_path, 'dest')
|
|
||||||
#
|
|
||||||
# print("Before moving directories:")
|
|
||||||
# print(os.listdir(base_path))
|
|
||||||
#
|
|
||||||
# # traverse each directory in dir_list
|
|
||||||
# for dir_ in dir_list:
|
|
||||||
#
|
|
||||||
# # create path to the directory in the
|
|
||||||
# # dir_list.
|
|
||||||
# source = os.path.join(base_path, dir_)
|
|
||||||
#
|
|
||||||
# # check if it is an existing directory
|
|
||||||
# if os.path.isdir(source):
|
|
||||||
# # move to destination path
|
|
||||||
# shutil.move(source, base_path)
|
|
||||||
#
|
|
||||||
# print("After moving directories:")
|
|
||||||
# print(os.listdir(base_path))
|
|
||||||
|
|
||||||
print("Completed")
|
print("Completed")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user