浏览代码

Update 'Events/src/myproject2.py'

SadhulaSaiKumar 1年前
父节点
当前提交
e790994142
共有 1 个文件被更改,包括 14 次插入112 次删除
  1. 14
    112
      Events/src/myproject2.py

+ 14
- 112
Events/src/myproject2.py 查看文件

@@ -10,36 +10,14 @@ app = Flask(__name__)
10 10
 app.config["IMAGE_UPLOADS"] = "C:/Users/Bizgaze/PycharmProjects/face_recogniction/People"
11 11
 #datasetPath = "/opt/bizgaze/events.bizgaze.app/wwwroot/_files/1/Gallery/"
12 12
 #peoplePath = "/opt/bizgaze/events.bizgaze.app/wwwroot/_files/People/"
13
-@app.route('/', methods=['GET'])
14
-def home():
15
-    return render_template('index.html')
16
-
17 13
 
18
-@app.route('/Display', methods=['GET', "POST"])
19
-def Display():
20
-    return render_template('Display.html')
21 14
 
22 15
 
23
-@app.route("/upload", methods=["GET", "POST"])
24
-def upload():
25
-    if request.method == "POST":
26
-
27
-        if request.files:
28
-
29
-            image = request.files["image"]
30
-            try:
31
-                image.save(os.path.join(
32
-                    app.config["IMAGE_UPLOADS"], image.filename))
33
-            except IsADirectoryError:
34
-                return render_template('index.html')
35
-            # image.save(os.path.join(
36
-            #     app.config["IMAGE_UPLOADS"], image.filename))
37
-
38
-            print("Image saved")
39 16
 
40
-            return redirect(request.url)
17
+@app.route('/', methods=['GET'])
18
+def home():
19
+    return render_template('index.html')
41 20
 
42
-    return 'ok'
43 21
 
44 22
 
45 23
 @app.route('/predict', methods=["GET", "POST"])
@@ -47,9 +25,11 @@ def predict():
47 25
     Dataset = request.get_json()
48 26
     a = Dataset
49 27
     peoplePath = a['People']
50
-    print(peoplePath)
28
+ 
29
+    #print(peoplePath1)
51 30
     datasetPath = a['Gallery']
52
-    print(datasetPath)
31
+  
32
+    #print(datasetPath)
53 33
    
54 34
     print('starting')
55 35
     def saveEncodings(encs, names, fname="encodings.pickle"):
@@ -200,7 +180,9 @@ def predict():
200 180
         if os.path.exists(path):
201 181
             pass
202 182
         else:
203
-            os.mkdir(path)
183
+            if not os.path.exists(path):
184
+                os.makedirs(path)
185
+            # os.mkdir(path,exist_ok=True)
204 186
         cv2.imwrite(path + "/" + imageName, image)
205 187
         x = []
206 188
         c = (path1 + "/" + imageName)
@@ -331,8 +313,8 @@ def predict():
331 313
 
332 314
         """
333 315
 
334
-        processKnownPeopleImages()
335
-        processDatasetImages()
316
+        processKnownPeopleImages(peoplePath)
317
+        processDatasetImages(datasetPath)
336 318
         # shutil.make_archive('./Images', 'zip','./output')
337 319
         # p='./Images.zip'
338 320
         # return send_file(p,as_attachment=True)
@@ -364,7 +346,6 @@ def predict():
364 346
         df.rename(columns={first_column_name: 'col'}, inplace=True)
365 347
         #print(df)
366 348
         z = df['col'].str.split('/', expand=True)
367
-
368 349
         z['ImagePath'] = z[3]
369 350
 
370 351
         result = z.drop([0,1,3], axis=1)
@@ -387,7 +368,7 @@ def predict():
387 368
         # Rename the first column
388 369
         df.rename(columns={first_column_name: 'col'}, inplace=True)
389 370
         print(df)
390
-        df1 = df['col'].str.split("/", expand=True)
371
+        df1 = df['col'].str.split("\\", expand=True)
391 372
         df1.rename({df1.columns[-2]: 'abc'}, axis=1, inplace=True)
392 373
         #print('this is df1')
393 374
         #print(df1)
@@ -400,7 +381,7 @@ def predict():
400 381
 
401 382
         merge.rename({merge.columns[-1]: 'Matched'}, axis=1, inplace=True)
402 383
         merge['EventName'] = merge['abc']
403
-        merge['Imagepath']="/_files/1/Gallery/"+merge['EventName']+'/'+ + merge['test']
384
+        merge['Imagepath']= datasetPath+merge['EventName']+'/'+ + merge['test']
404 385
 
405 386
         frames = [merge, mergesplit]
406 387
 
@@ -414,85 +395,6 @@ def predict():
414 395
 
415 396
 #############################################################################################
416 397
 
417
-
418
-
419
-       #  merge.rename({merge.columns[-3]: 'ImagePath'}, axis=1, inplace=True)
420
-       #
421
-       #  # print(merge)
422
-       #  merge1 = merge.iloc[:, -2]
423
-       #  merge12= merge.iloc[:, -3]
424
-       #
425
-       #  # merge1.rename({merge1.columns[-1]: 'abc'}, axis=1, inplace=True)
426
-       #  merge2 = merge.iloc[:, -1].str.split(".", expand=True)
427
-       #  merge2.rename({merge2.columns[-1]: 'drop'}, axis=1, inplace=True)
428
-       #  #merge2.rename({merge2.columns[-2]: 'ImageName'}, axis=1, inplace=True)
429
-       #  print('this is merge1')
430
-       #  print(merge1)
431
-       #  print('this is merge2')
432
-       #  print(merge2)
433
-       #  mergefinal = pd.concat([merge1, merge2], axis=1, join='inner')
434
-       #  # print(mergefinal)
435
-       #  # print('-----------------')
436
-       #
437
-       #  mergefinal.drop(columns=mergefinal.columns[-1], axis=1, inplace=True)
438
-       #  # print(mergefinal)
439
-       #  # print('--------------------------------------------------------------------------------')
440
-       # # mergefinal.rename({mergefinal.columns[-1]: 'ImageName'}, axis=1, inplace=True)
441
-       #  # print('this is filename')
442
-       #  # print(mergefinal)
443
-       #  #mergefinal.rename({mergefinal.columns[-2]: 'EventName'}, axis=1, inplace=True)
444
-       #  # print('this is foldername')
445
-       #  # print(mergefinal)
446
-       #
447
-       #  frames = [mergefinal, merge12]
448
-       #
449
-       #  r = pd.concat(frames, axis=1, join='inner')
450
-       #
451
-       #
452
-       #  r.to_csv('Imagepath1.csv', index=False)
453
-       #  r.to_json('Imagepath1.json', orient="records")
454
-       #  import shutil
455
-        # import os
456
-        # # import shutil module
457
-        # import shutil
458
-        #
459
-        # # import os module
460
-        # import os
461
-        # #################### move code#############
462
-        # # base path
463
-        # base_path = 'C:\\Users\\Bizgaze\\PycharmProjects\\face_recogniction\\move'
464
-        # import os
465
-        # dir_list = []
466
-        # rootdir = 'C:\\Users\\Bizgaze\\PycharmProjects\\face_recogniction\\Dataset'
467
-        # for file in os.listdir(rootdir):
468
-        #     d = os.path.join(rootdir, file)
469
-        #     if os.path.isdir(d):
470
-        #         dir_list.append(d)
471
-        #
472
-        # # list of directories we want to move.
473
-        # # dir_list = ['test2', 'test4', 'test5', 'does_not_exist']
474
-        #
475
-        # # path to destination directory
476
-        # # dest = os.path.join(base_path, 'dest')
477
-        #
478
-        # print("Before moving directories:")
479
-        # print(os.listdir(base_path))
480
-        #
481
-        # # traverse each directory in dir_list
482
-        # for dir_ in dir_list:
483
-        #
484
-        #     # create path to the directory in the
485
-        #     # dir_list.
486
-        #     source = os.path.join(base_path, dir_)
487
-        #
488
-        #     # check if it is an existing directory
489
-        #     if os.path.isdir(source):
490
-        #         # move to destination path
491
-        #         shutil.move(source, base_path)
492
-        #
493
-        # print("After moving directories:")
494
-        # print(os.listdir(base_path))
495
-
496 398
         print("Completed")
497 399
 
498 400
     if __name__ == "__main__":

正在加载...
取消
保存