From 2040eca7bcb58700cb6eb250e5b2623ff3993ec9 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 7 Mar 2025 14:29:09 +0800 Subject: [PATCH 1/2] solve error of _3D & fixed wine facewarp.exe in linux & update README.md --- README.md | 11 +++++++++++ main_end2end.py | 2 +- main_end2end_cartoon.py | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 803f89d..4fedd52 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,17 @@ sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ xenial ma sudo apt update sudo apt install --install-recommends winehq-stable ``` +- Tested on Ubuntu 22.04 (Linux Mint 21.x) & Using a virtual display in a headless server environment. +``` +sudo dpkg --add-architecture i386 +wget -nc https://dl.winehq.org/wine-builds/winehq.key +sudo apt-key add winehq.key +sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ jammy main' +sudo apt update + +sudo apt install --install-recommends winehq-stable +nohup xvfb-run winecfg > winecfg.log 2>&1 & +``` ## Pre-trained Models diff --git a/main_end2end.py b/main_end2end.py index 64d09ef..56d6ae3 100644 --- a/main_end2end.py +++ b/main_end2end.py @@ -68,7 +68,7 @@ ''' STEP 1: preprocess input single image ''' img =cv2.imread('examples/' + opt_parser.jpg) -predictor = face_alignment.FaceAlignment(face_alignment.LandmarksType._3D, device='cuda', flip_input=True) +predictor = face_alignment.FaceAlignment(face_alignment.LandmarksType.Three_D, device='cuda', flip_input=True) shapes = predictor.get_landmarks(img) if (not shapes or len(shapes) != 1): print('Cannot detect face landmarks. Exit.') diff --git a/main_end2end_cartoon.py b/main_end2end_cartoon.py index 792262d..9a8449f 100644 --- a/main_end2end_cartoon.py +++ b/main_end2end_cartoon.py @@ -218,7 +218,7 @@ '-novsync -dump')) else: ''' linux ''' - os.system('wine {} {} {} {} {} {}'.format( + os.system('xvfb-run -a wine {} {} {} {} {} {}'.format( warp_exe, os.path.join(cur_dir, '..', '..', opt_parser.jpg), os.path.join(cur_dir, '..', 'triangulation.txt'), From c5cc887596be46c5483a4b19b26eab8c5d258b42 Mon Sep 17 00:00:00 2001 From: a Date: Tue, 11 Mar 2025 17:00:02 +0800 Subject: [PATCH 2/2] jumped visualize --- facewarp/gen_puppet_utils.py | 23 ++++++++++++----------- main_gen_new_puppet.py | 19 ++++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/facewarp/gen_puppet_utils.py b/facewarp/gen_puppet_utils.py index ce6374d..617ebe2 100644 --- a/facewarp/gen_puppet_utils.py +++ b/facewarp/gen_puppet_utils.py @@ -101,7 +101,7 @@ def draw_curve(shape, idx_list, loop=False, x_offset=0.0, c=None): if (show_now): plt.show() - vis_landmark_on_plt(std_face_id, show_now=show) + # vis_landmark_on_plt(std_face_id, show_now=show) @@ -162,11 +162,12 @@ def draw_voronoi(img, subdiv): def delauney_tri(ROOT_DIR, test_data, INNER_ONLY=False): # Define window names win_delaunay = "Delaunay Triangulation" - cv2.namedWindow(win_delaunay, cv2.WINDOW_NORMAL) + # cv2.namedWindow(win_delaunay, cv2.WINDOW_NORMAL) win_voronoi = "Voronoi Diagram" # Turn on animation while drawing triangles - animate = True + # animate = True + animate = False # Define colors for drawing. delaunay_color = (255, 255, 255) @@ -234,8 +235,8 @@ def delauney_tri(ROOT_DIR, test_data, INNER_ONLY=False): cv2.imshow(win_delaunay, img_copy) cv2.waitKey(100) - # Draw delaunay triangles - draw_delaunay(img, subdiv, (255, 255, 0)) + # # Draw delaunay triangles + # draw_delaunay(img, subdiv, (255, 255, 0)) triangleList = subdiv.getTriangleList() p_dict = {} # Initialize empty dictionary. @@ -249,13 +250,13 @@ def delauney_tri(ROOT_DIR, test_data, INNER_ONLY=False): # Allocate space for voronoi Diagram img_voronoi = np.zeros(img.shape, dtype=img.dtype) - # Draw voronoi diagram - draw_voronoi(img_voronoi, subdiv) + # # Draw voronoi diagram + # draw_voronoi(img_voronoi, subdiv) - # Show results - cv2.imshow(win_delaunay, img) - print("Press any key to quit...") - cv2.waitKey(0) + # # Show results + # cv2.imshow(win_delaunay, img) + # print("Press any key to quit...") + # cv2.waitKey(0) new_tri = []; diff --git a/main_gen_new_puppet.py b/main_gen_new_puppet.py index fa5f5fc..90ffc79 100644 --- a/main_gen_new_puppet.py +++ b/main_gen_new_puppet.py @@ -148,15 +148,15 @@ def update_img(node, button_up=False): draw_landmarks(img, pts) -cv2.namedWindow("img", cv2.WINDOW_NORMAL) -cv2.setMouseCallback("img", click_adjust_wireframe) +# cv2.namedWindow("img", cv2.WINDOW_NORMAL) +# cv2.setMouseCallback("img", click_adjust_wireframe) -while(True): - cv2.imshow('img', img) - key = cv2.waitKey(1) - if key == ord("q"): - break -cv2.destroyAllWindows() +# while(True): +# cv2.imshow('img', img) +# key = cv2.waitKey(1) +# if key == ord("q"): +# break +# cv2.destroyAllWindows() print('vis and refine landmark Done!') pts = np.concatenate([pts, np.ones((68, 1))], axis=1) @@ -180,7 +180,8 @@ def update_img(node, button_up=False): ================================================================= ''' -norm_anno(data_dir, CH, param=[0.7, 0.4, 0.5, 0.5], show=True) +# norm_anno(data_dir, CH, param=[0.7, 0.4, 0.5, 0.5], show=True) +norm_anno(data_dir, CH, param=[0.7, 0.4, 0.5, 0.5], show=False) ''' =================================================================