-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement new renderers and utilitary methods
- Loading branch information
Showing
25 changed files
with
1,475 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.h5 filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.vscode/settings.json | ||
__pycache__/* | ||
output/* | ||
input/* | ||
baselMorphableModel/* | ||
faceNext/* | ||
drjit/* | ||
mitsuba/* | ||
*.pyc | ||
ext/* | ||
chi2_data.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Generate" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Reconstruction of a face from a single image ( Vertex / Redner / Mitsuba)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"! py -u ./optimizer.py --input input/test/s1.png --output output/test/mitsuba_blank_text" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Batch reconstruction of a faces from a folder ( Vertex / Redner)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"! py ./optimizer.py --input input/test/ --output output/test/all_images/vertex_reg " | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Batch reconstruction of faces in loop (Mitsuba)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"py ./optimizer.py --input input/test/s1.png --output output/test/mitsuba_rednermat_clip\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import os\n", | ||
"import subprocess\n", | ||
"# Directory path containing all images\n", | ||
"imageFolderPath = './input/test/'\n", | ||
"\n", | ||
"outputDir = './output/test/mitsuba_rednermat_clip'\n", | ||
"#setup\n", | ||
"if not os.path.exists(outputDir):\n", | ||
" os.makedirs(outputDir) # Create the output directory if it doesn't exist\n", | ||
"# Get the names of all files in the specified directory\n", | ||
"image_names = [f for f in os.listdir(imageFolderPath) if os.path.isfile(os.path.join(imageFolderPath, f))]\n", | ||
"\n", | ||
"# Filter only image files by extensions (if required)\n", | ||
"image_paths = [os.path.join(imageFolderPath, image_name) for image_name in image_names if image_name.endswith(('.png', '.jpg', '.jpeg'))]\n", | ||
"\n", | ||
"# Print the command for each image\n", | ||
"for image_path in image_paths:\n", | ||
" # Removing the './' from the image path\n", | ||
" image_path = image_path.replace('./', '')\n", | ||
" outputDir = outputDir.replace('./', '')\n", | ||
" command = f'py ./optimizer.py --input {image_path} --output {outputDir}'\n", | ||
" print(command)\n", | ||
" # Execute the command using os.system(command) if desired\n", | ||
" # os.system(command)\n", | ||
" result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\n", | ||
" print(result.stdout.decode())\n", | ||
" " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"^C\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"! py ./optimizer.py --input input/test/s3.png --output output/test/mitsuba_rednermat_clip" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Display images" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from PIL import Image\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"def display_images_in_folder(folder_path):\n", | ||
" # Iterate through the folder and subfolders\n", | ||
" for root, dirs, files in os.walk(folder_path):\n", | ||
" # Look for the file \"render0.png\" in the current directory\n", | ||
" if \"render_0.png\" in files:\n", | ||
" image_path = os.path.join(root, \"render_0.png\")\n", | ||
" # Open the image using PIL\n", | ||
" image = Image.open(image_path)\n", | ||
" # Display the image\n", | ||
" # Plot and display the image using Matplotlib\n", | ||
" plt.imshow(image)\n", | ||
" plt.axis('off') # Turn off axis\n", | ||
" plt.title(f\"Image from: {root}\")\n", | ||
" plt.show()\n", | ||
"\n", | ||
"# Path to the output directory\n", | ||
"output_folder_path = outputDir\n", | ||
"\n", | ||
"# Call the function to find and display the images\n", | ||
"display_images_in_folder(output_folder_path)\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"accelerator": "GPU", | ||
"colab": { | ||
"name": "demo.ipynb", | ||
"provenance": [] | ||
}, | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.