From 0a3a6528fcc62fc50e2054749d5734f37e573868 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 1 May 2018 18:45:18 +0200 Subject: [PATCH 1/9] Use Travis CI to run tests on all pull requests --- .travis.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..481752e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,27 @@ +group: travis_latest +language: python +cache: pip +python: + - 2.7 + - 3.6 + #- nightly + #- pypy + #- pypy3 +matrix: + allow_failures: + - python: nightly + - python: pypy + - python: pypy3 +install: + #- pip install -r requirements.txt + - pip install flake8 tensorflow # pytest # add another testing frameworks later +before_script: + # stop the build if there are Python syntax errors or undefined names + - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics +script: + - python run_basics.py #Can run only with python and tensorflow +notifications: + on_success: change + on_failure: change # `always` will be the setting once code changes slow down From 212548b8a558582d36d9e102a0dd8f59b5e9c623 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 1 May 2018 18:50:13 +0200 Subject: [PATCH 2/9] python run_basics.p --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 481752e..9d08d43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ before_script: # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics script: - - python run_basics.py #Can run only with python and tensorflow + - python run_basics.py # Can run only with python and tensorflow notifications: on_success: change on_failure: change # `always` will be the setting once code changes slow down From 0d20d09780e6168981a8069e88d0bd394b69dca5 Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 2 May 2018 14:42:27 +0200 Subject: [PATCH 3/9] Resolve undefined name 'image' in utils/render.py flake8 testing of https://github.com/YadiraF/PRNet on Python 3.6.3 $ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__ ``` ./utils/render.py:362:17: F821 undefined name 'image' [h, w, _] = image.shape ^ 1 F821 undefined name 'image' 1 ``` --- utils/render.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/utils/render.py b/utils/render.py index 86002d6..f2b5ea3 100644 --- a/utils/render.py +++ b/utils/render.py @@ -341,13 +341,13 @@ def vis_of_vertices(vertices, triangles, h, w, depth_buffer = None): return vertices_vis -## To be modified +# TODO: To be modified def triangle_buffer(vertices, triangles, h, w): ''' Args: vertices: 3 x nver triangles: 3 x ntri - h: height + h: height # [h, w, _] = image.shape w: width Returns: depth_buffer: height x width @@ -358,9 +358,6 @@ def triangle_buffer(vertices, triangles, h, w): # Each triangle has 3 vertices & Each vertex has 3 coordinates x, y, z. # Here, the bigger the z, the fronter the point. ''' - # initial - [h, w, _] = image.shape - depth_buffer = np.zeros([h, w]) + 999999. #+ np.min(vertices[2,:]) - 999999. # set the initial z to the farest position triangle_buffer = np.zeros_like(depth_buffer, dtype = np.int32) - 1 # if -1, the pixel has no triangle correspondance From 5272b9a6a5a04539f6514ce1d1c14bbaf7b14f67 Mon Sep 17 00:00:00 2001 From: Andi Li Date: Thu, 3 May 2018 10:38:49 -0400 Subject: [PATCH 4/9] Add files via upload --- demo.py | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/demo.py b/demo.py index 60ac52e..9bdbd4a 100644 --- a/demo.py +++ b/demo.py @@ -22,7 +22,7 @@ def main(args): # ---- init PRN os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu # GPU number, -1 for CPU - prn = PRN(is_dlib = args.isDlib) + prn = PRN(is_dlib = args.isDlib) # ------------- load data image_folder = args.inputDir @@ -37,18 +37,20 @@ def main(args): total_num = len(image_path_list) for i, image_path in enumerate(image_path_list): - + name = image_path.strip().split('/')[-1][:-4] - + # read image image = imread(image_path) [h, w, _] = image.shape - # the core: regress position map + # the core: regress position map if args.isDlib: - max_size = max(image.shape[0], image.shape[1]) + max_size = max(image.shape[0], image.shape[1]) if max_size> 1000: image = rescale(image, 1000./max_size) + image = image*256 + image = image.astype(np.uint8) pos = prn.process(image) # use dlib to detect face else: if image.shape[1] == image.shape[2]: @@ -62,7 +64,7 @@ def main(args): if pos is None: continue - if args.is3d or args.isMat or args.isPose or args.isShow: + if args.is3d or args.isMat or args.isPose or args.isShow: # 3D vertices vertices = prn.get_vertices(pos) if args.isFront: @@ -71,7 +73,7 @@ def main(args): save_vertices = vertices if args.isImage: - imsave(os.path.join(save_folder, name + '.jpg'), image) + imsave(os.path.join(save_folder, name + '.jpg'), image) if args.is3d: # corresponding colors @@ -88,8 +90,8 @@ def main(args): write_obj(os.path.join(save_folder, name + '.obj'), save_vertices, colors, prn.triangles) #save 3d face(can open with meshlab) if args.isDepth: - depth_image = get_depth_image(vertices, prn.triangles, h, w) - imsave(os.path.join(save_folder, name + '_depth.jpg'), depth_image) + depth_image = get_depth_image(vertices, prn.triangles, h, w) + imsave(os.path.join(save_folder, name + '_depth.jpg'), depth_image) if args.isMat: sio.savemat(os.path.join(save_folder, name + '_mesh.mat'), {'vertices': save_vertices, 'colors': colors, 'triangles': prn.triangles}) @@ -97,12 +99,12 @@ def main(args): if args.isKpt or args.isShow: # get landmarks kpt = prn.get_landmarks(pos) - np.savetxt(os.path.join(save_folder, name + '_kpt.txt'), kpt) - + np.savetxt(os.path.join(save_folder, name + '_kpt.txt'), kpt) + if args.isPose or args.isShow: # estimate pose camera_matrix, pose = estimate_pose(vertices) - np.savetxt(os.path.join(save_folder, name + '_pose.txt'), pose) + np.savetxt(os.path.join(save_folder, name + '_pose.txt'), pose) if args.isShow: # ---------- Plot @@ -118,34 +120,34 @@ def main(args): parser.add_argument('-i', '--inputDir', default='TestImages/', type=str, help='path to the input directory, where input images are stored.') - parser.add_argument('-o', '--outputDir', default='TestImages/results', type=str, + parser.add_argument('-o', '--outputDir', default='TestImages/results', type=str, help='path to the output directory, where results(obj,txt files) will be stored.') - parser.add_argument('--gpu', default='0', type=str, + parser.add_argument('--gpu', default='0', type=str, help='set gpu id, -1 for CPU') - parser.add_argument('--isDlib', default=True, type=ast.literal_eval, + parser.add_argument('--isDlib', default=True, type=ast.literal_eval, help='whether to use dlib for detecting face, default is True, if False, the input image should be cropped in advance') - parser.add_argument('--is3d', default=True, type=ast.literal_eval, + parser.add_argument('--is3d', default=True, type=ast.literal_eval, help='whether to output 3D face(.obj)') - parser.add_argument('--isMat', default=False, type=ast.literal_eval, + parser.add_argument('--isMat', default=False, type=ast.literal_eval, help='whether to save vertices,color,triangles as mat for matlab showing') - parser.add_argument('--isKpt', default=False, type=ast.literal_eval, + parser.add_argument('--isKpt', default=False, type=ast.literal_eval, help='whether to output key points(.txt)') - parser.add_argument('--isPose', default=False, type=ast.literal_eval, + parser.add_argument('--isPose', default=False, type=ast.literal_eval, help='whether to output estimated pose(.txt)') - parser.add_argument('--isShow', default=False, type=ast.literal_eval, + parser.add_argument('--isShow', default=False, type=ast.literal_eval, help='whether to show the results with opencv(need opencv)') - parser.add_argument('--isImage', default=False, type=ast.literal_eval, + parser.add_argument('--isImage', default=False, type=ast.literal_eval, help='whether to save input image') # update in 2017/4/10 - parser.add_argument('--isFront', default=False, type=ast.literal_eval, + parser.add_argument('--isFront', default=False, type=ast.literal_eval, help='whether to frontalize vertices(mesh)') # update in 2017/4/25 - parser.add_argument('--isDepth', default=False, type=ast.literal_eval, + parser.add_argument('--isDepth', default=False, type=ast.literal_eval, help='whether to output depth image') # update in 2017/4/27 - parser.add_argument('--isTexture', default=False, type=ast.literal_eval, + parser.add_argument('--isTexture', default=False, type=ast.literal_eval, help='whether to save texture in obj file') - parser.add_argument('--isMask', default=False, type=ast.literal_eval, + parser.add_argument('--isMask', default=False, type=ast.literal_eval, help='whether to set invisible pixels(due to self-occlusion) in texture as 0') - main(parser.parse_args()) \ No newline at end of file + main(parser.parse_args()) From b247fc14ca9eb8514182ed1e3b066a6d02e279ad Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 9 May 2018 09:12:49 +0200 Subject: [PATCH 5/9] Travis CI: pip install scipy --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9d08d43..11a4729 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: - python: pypy3 install: #- pip install -r requirements.txt - - pip install flake8 tensorflow # pytest # add another testing frameworks later + - pip install flake8 scipy tensorflow # pytest # add another testing frameworks later before_script: # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics From 7d3bbf519bf79a82a4cff3d2f7e6a1f61fb83401 Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 9 May 2018 09:35:44 +0200 Subject: [PATCH 6/9] pip install scikit-image scipy --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 11a4729..b2d9ff9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: - python: pypy3 install: #- pip install -r requirements.txt - - pip install flake8 scipy tensorflow # pytest # add another testing frameworks later + - pip install flake8 scikit-image scipy tensorflow # pytest # add another testing frameworks later before_script: # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics From f3cf37f39dbf802662ee0061071ff33cad8268c6 Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 9 May 2018 09:51:14 +0200 Subject: [PATCH 7/9] pip install numpy --upgrade --ignore-installed --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b2d9ff9..11e51dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ matrix: install: #- pip install -r requirements.txt - pip install flake8 scikit-image scipy tensorflow # pytest # add another testing frameworks later + - pip install numpy --upgrade --ignore-installed before_script: # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics From da449530a2dd997cdc12e7e5bd234fedaa0a0e16 Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 9 May 2018 10:07:13 +0200 Subject: [PATCH 8/9] Create requirements.txt --- requirements.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..5ba7442 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +numpy>=1.14.3 +scikit-image +scipy +tensorflow From 90512699e4d0f0648207404e9c9d84614edb7478 Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 9 May 2018 10:08:06 +0200 Subject: [PATCH 9/9] pip install -r requirements.txt --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 11e51dd..f3b4be7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,8 @@ matrix: - python: pypy - python: pypy3 install: - #- pip install -r requirements.txt - - pip install flake8 scikit-image scipy tensorflow # pytest # add another testing frameworks later - - pip install numpy --upgrade --ignore-installed + - pip install -r requirements.txt + - pip install flake8 # pytest # add another testing frameworks later before_script: # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics