説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

main_application.py 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. import os
  2. import click
  3. from flask import Flask, render_template, request, redirect, send_file
  4. import shutil
  5. import glob
  6. app = Flask(__name__)
  7. @app.route('/', methods=['GET'])
  8. def home():
  9. return render_template('index.html')
  10. import datetime
  11. # def crop_Alluq():
  12. # import os
  13. # cmd = "python .\\sepration_crop.py"
  14. # os.system(cmd)
  15. #
  16. # import os
  17. # cmd = "python .\\front_face.py"
  18. # os.system(cmd)
  19. #
  20. # import os
  21. # cmd = "python .\\sepration_cluster.py"
  22. # os.system(cmd)
  23. #
  24. # import os
  25. # cmd = "python .\\unique_1.py"
  26. # os.system(cmd)
  27. #
  28. # import os
  29. # cmd = "python .\\unique_Allunq.py"
  30. # os.system(cmd)
  31. #
  32. # # import os
  33. # # cmd = "python .\\Allunq_copy_gallery.py"
  34. # # os.system(cmd)
  35. #
  36. # import os
  37. # cmd = "python .\\remove.py"
  38. # os.system(cmd)
  39. #
  40. #
  41. # def sync_Alluq_people():
  42. # import os
  43. # cmd = "python .\\Allunq_People.py"
  44. # os.system(cmd)
  45. def crop_Alluq(eventid,original_working_directory):
  46. print("started with images")
  47. import os
  48. cmd = "python "+original_working_directory+"\\sepration_crop.py"+" "+str(eventid)
  49. os.system(cmd)
  50. import os
  51. cmd = "python "+original_working_directory+"\\front_face.py"+" "+str(eventid)
  52. os.system(cmd)
  53. import os
  54. cmd = "python "+original_working_directory+"\\sepration_cluster.py"+" "+str(eventid)
  55. os.system(cmd)
  56. import os
  57. cmd = "python "+original_working_directory+"\\unique_1.py"+" "+str(eventid)
  58. os.system(cmd)
  59. #eventid="789456123"
  60. import os
  61. cmd = "python "+original_working_directory+"\\is_existALLUNQ.py"+" "+str(eventid)
  62. os.system(cmd)
  63. import os
  64. cmd = "python "+original_working_directory+"\\Allunq_copy_gallery.py"+" "+str(eventid)
  65. os.system(cmd)
  66. import os
  67. cmd = "python "+original_working_directory+"\\Allunq_People.py"+" "+str(eventid)
  68. os.system(cmd)
  69. return "ended with images"
  70. # import os
  71. # cmd = "python .\\remove.py"
  72. # os.system(cmd)
  73. def sync_Alluq_people(eventid,original_working_directory):
  74. import os
  75. cmd = "python "+original_working_directory+"\\Allunq_People.py"+" "+str(eventid)
  76. os.system(cmd)
  77. return "ended with images"
  78. def create_dir(eventid,original_working_directory):
  79. # original_working_directory = os.getcwd()
  80. # new_networked_directory = r'\\192.168.88.99\\Bizgaze\\port6003\\wwwroot\\_files\\'
  81. # # change to the networked directory
  82. # os.chdir(new_networked_directory)
  83. print(original_working_directory)
  84. from pathlib import Path
  85. Path(original_working_directory+'\\front_face\\' + eventid).mkdir(exist_ok=True)
  86. Path(original_working_directory+'/sepration_cluster/'+eventid).mkdir(exist_ok=True)
  87. Path(original_working_directory+'/sepration_crop/' + eventid).mkdir(exist_ok=True)
  88. Path(original_working_directory+'/unique_1/' + eventid).mkdir(exist_ok=True)
  89. Path('ALL_UNQ/' + eventid).mkdir(exist_ok=True)
  90. Path(original_working_directory+'/output_unique_ALLUNQ/' + eventid).mkdir(exist_ok=True)
  91. Path(original_working_directory+'/people_Allunq_zero_maingallery/' + eventid).mkdir(exist_ok=True)
  92. Path(original_working_directory+'/Allunq_People/' + eventid).mkdir(exist_ok=True)
  93. Path(original_working_directory+'/Allunq_CopyGallery/' + eventid).mkdir(exist_ok=True)
  94. @app.route('/eventwise', methods=["GET", "POST"])
  95. def eventwise():
  96. import os
  97. original_working_directory = os.getcwd()
  98. new_networked_directory = r'\\192.168.88.99\\Bizgaze\\port6003\\wwwroot\\_files'
  99. # change to the networked directory
  100. os.chdir(new_networked_directory)
  101. eventid= request.args.get('Dataset')
  102. # Id.append(Events)
  103. create_dir(eventid,original_working_directory)
  104. import pathlib
  105. file = pathlib.Path(new_networked_directory+"/"+eventid+"/"+"Thumbs.db")
  106. if file.exists ():
  107. os.remove(new_networked_directory+"/"+eventid+"/"+'Thumbs.db')
  108. else:
  109. pass
  110. x = datetime.datetime.now()
  111. print('Execution Started at:', x)
  112. import os
  113. # path of the directory
  114. for dirpath, dirnames, files in os.walk('1/CopyGallery/' + eventid + '/'):
  115. if os.listdir(dirpath)==[]:
  116. #f = os.path.join(root, name)
  117. # Checking the length of list
  118. #if len((f)) == 0:
  119. print("No files found in the directory.")
  120. print("working on sync_Alluq_people.........")
  121. sync_Alluq_people(eventid,original_working_directory)
  122. else:
  123. print("Some files found in the directory.")
  124. print("working on crop_Alluq.........")
  125. crop_Alluq(eventid,original_working_directory)
  126. return "ended with images"
  127. #
  128. #
  129. # import os
  130. # cmd = "python .\\people_Allunq_zero_maingallery.py"
  131. # os.system(cmd)
  132. # import os
  133. # cmd = "python .\\remove.py"
  134. # os.system(cmd)
  135. # import requests
  136. # import json
  137. # with open('C:\\Users\\Bizgaze\\Desktop\\AI\\AI_Events\\csv\\EventXtream.json', 'r') as json_file:
  138. # json_load = json.load(json_file)
  139. # url = "http://localhost:3088/apis/v4/bizgaze/integrations/json/save"
  140. # payload1 = json.dumps(json_load).replace("]", "").replace("[", "")
  141. # print('--------------------------------------------------------------------------')
  142. # print(payload1)
  143. # headers = {
  144. # 'Authorization': 'Stat a528db7c512f494eab8bfef012c220e0',
  145. # 'Content-Type': 'application/json'
  146. # }
  147. # response = requests.request("POST", url, headers=headers, data=payload1)
  148. # print("##############################################################")
  149. # print(response.text)
  150. # y = datetime.datetime.now()
  151. # print('Completed at:', y)
  152. # z = y - x
  153. # print('Time Taken:', z)
  154. # return render_template('index.html')
  155. # # return 'ALL IMAGES MATCHED'
  156. @app.route('/json')
  157. def json():
  158. p = './path.json'
  159. return send_file(p, as_attachment=True)
  160. if __name__ == "__main__":
  161. app.run(host="0.0.0.0",port=5001,debug=True)