123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- import os
-
- import click
- from flask import Flask, render_template, request, redirect, send_file
- import shutil
- import glob
-
-
-
- app = Flask(__name__)
-
- @app.route('/', methods=['GET'])
- def home():
- return render_template('index.html')
-
-
- import datetime
-
- # def crop_Alluq():
- # import os
- # cmd = "python .\\sepration_crop.py"
- # os.system(cmd)
- #
- # import os
- # cmd = "python .\\front_face.py"
- # os.system(cmd)
- #
- # import os
- # cmd = "python .\\sepration_cluster.py"
- # os.system(cmd)
- #
- # import os
- # cmd = "python .\\unique_1.py"
- # os.system(cmd)
- #
- # import os
- # cmd = "python .\\unique_Allunq.py"
- # os.system(cmd)
- #
- # # import os
- # # cmd = "python .\\Allunq_copy_gallery.py"
- # # os.system(cmd)
- #
- # import os
- # cmd = "python .\\remove.py"
- # os.system(cmd)
- #
- #
- # def sync_Alluq_people():
- # import os
- # cmd = "python .\\Allunq_People.py"
- # os.system(cmd)
-
-
-
- def crop_Alluq(eventid,original_working_directory):
-
-
- print("started with images")
- import os
- cmd = "python "+original_working_directory+"\\sepration_crop.py"+" "+str(eventid)
- os.system(cmd)
-
- import os
- cmd = "python "+original_working_directory+"\\front_face.py"+" "+str(eventid)
- os.system(cmd)
-
- import os
- cmd = "python "+original_working_directory+"\\sepration_cluster.py"+" "+str(eventid)
- os.system(cmd)
-
- import os
- cmd = "python "+original_working_directory+"\\unique_1.py"+" "+str(eventid)
- os.system(cmd)
-
- #eventid="789456123"
- import os
- cmd = "python "+original_working_directory+"\\is_existALLUNQ.py"+" "+str(eventid)
- os.system(cmd)
-
-
- import os
- cmd = "python "+original_working_directory+"\\Allunq_copy_gallery.py"+" "+str(eventid)
- os.system(cmd)
-
-
- import os
- cmd = "python "+original_working_directory+"\\Allunq_People.py"+" "+str(eventid)
- os.system(cmd)
-
- return "ended with images"
-
- # import os
- # cmd = "python .\\remove.py"
- # os.system(cmd)
-
-
-
- def sync_Alluq_people(eventid,original_working_directory):
-
-
- import os
- cmd = "python "+original_working_directory+"\\Allunq_People.py"+" "+str(eventid)
- os.system(cmd)
-
- return "ended with images"
-
-
- def create_dir(eventid,original_working_directory):
-
- # original_working_directory = os.getcwd()
- # new_networked_directory = r'\\192.168.88.99\\Bizgaze\\port6003\\wwwroot\\_files\\'
- # # change to the networked directory
- # os.chdir(new_networked_directory)
- print(original_working_directory)
-
- from pathlib import Path
- Path(original_working_directory+'\\front_face\\' + eventid).mkdir(exist_ok=True)
- Path(original_working_directory+'/sepration_cluster/'+eventid).mkdir(exist_ok=True)
- Path(original_working_directory+'/sepration_crop/' + eventid).mkdir(exist_ok=True)
- Path(original_working_directory+'/unique_1/' + eventid).mkdir(exist_ok=True)
- Path('ALL_UNQ/' + eventid).mkdir(exist_ok=True)
- Path(original_working_directory+'/output_unique_ALLUNQ/' + eventid).mkdir(exist_ok=True)
- Path(original_working_directory+'/people_Allunq_zero_maingallery/' + eventid).mkdir(exist_ok=True)
- Path(original_working_directory+'/Allunq_People/' + eventid).mkdir(exist_ok=True)
- Path(original_working_directory+'/Allunq_CopyGallery/' + eventid).mkdir(exist_ok=True)
-
-
-
-
- @app.route('/eventwise', methods=["GET", "POST"])
-
- def eventwise():
- import os
- original_working_directory = os.getcwd()
- new_networked_directory = r'\\192.168.88.99\\Bizgaze\\port6003\\wwwroot\\_files'
- # change to the networked directory
- os.chdir(new_networked_directory)
-
- eventid= request.args.get('Dataset')
- # Id.append(Events)
-
-
- create_dir(eventid,original_working_directory)
-
- import pathlib
- file = pathlib.Path(new_networked_directory+"/"+eventid+"/"+"Thumbs.db")
- if file.exists ():
- os.remove(new_networked_directory+"/"+eventid+"/"+'Thumbs.db')
- else:
- pass
-
- x = datetime.datetime.now()
- print('Execution Started at:', x)
- import os
-
-
- # path of the directory
-
- for dirpath, dirnames, files in os.walk('1/CopyGallery/' + eventid + '/'):
- if os.listdir(dirpath)==[]:
- #f = os.path.join(root, name)
- # Checking the length of list
- #if len((f)) == 0:
- print("No files found in the directory.")
- print("working on sync_Alluq_people.........")
- sync_Alluq_people(eventid,original_working_directory)
-
-
-
- else:
- print("Some files found in the directory.")
- print("working on crop_Alluq.........")
- crop_Alluq(eventid,original_working_directory)
-
-
- return "ended with images"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #
- #
-
-
- # import os
- # cmd = "python .\\people_Allunq_zero_maingallery.py"
- # os.system(cmd)
-
- # import os
- # cmd = "python .\\remove.py"
- # os.system(cmd)
- # import requests
- # import json
-
- # with open('C:\\Users\\Bizgaze\\Desktop\\AI\\AI_Events\\csv\\EventXtream.json', 'r') as json_file:
- # json_load = json.load(json_file)
- # url = "http://localhost:3088/apis/v4/bizgaze/integrations/json/save"
-
- # payload1 = json.dumps(json_load).replace("]", "").replace("[", "")
- # print('--------------------------------------------------------------------------')
- # print(payload1)
- # headers = {
- # 'Authorization': 'Stat a528db7c512f494eab8bfef012c220e0',
- # 'Content-Type': 'application/json'
- # }
- # response = requests.request("POST", url, headers=headers, data=payload1)
- # print("##############################################################")
- # print(response.text)
-
-
- # y = datetime.datetime.now()
- # print('Completed at:', y)
- # z = y - x
- # print('Time Taken:', z)
-
- # return render_template('index.html')
- # # return 'ALL IMAGES MATCHED'
-
-
- @app.route('/json')
- def json():
- p = './path.json'
- return send_file(p, as_attachment=True)
-
- if __name__ == "__main__":
- app.run(host="0.0.0.0",port=5001,debug=True)
|