-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3afd75
commit 4c0f52e
Showing
2 changed files
with
71 additions
and
1 deletion.
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
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,39 @@ | ||
import cv2 | ||
import click | ||
|
||
from colorization import Colorizer, IterativeColorizer | ||
|
||
|
||
@click.command() | ||
@click.option('--original_image', help='Original Image Path') | ||
@click.option('--visual_clue', help='Visual Clue Image Path') | ||
@click.option('--result_path', default='./result', help='Colorized Image Path (without file extensions)') | ||
@click.option('--use_itercative', '-i', is_flag=True, help='Use Iterative Mode') | ||
@click.option('--epochs', default=500, help='Number of epochs for Iterative Mode') | ||
@click.option('--log_intervals', default=100, help='Log Interval') | ||
def colorize(original_image, visual_clue, result_path, use_itercative, epochs, log_intervals): | ||
if use_itercative: | ||
colorizer = Colorizer( | ||
gray_image_file=original_image, | ||
visual_clues_file=visual_clue | ||
) | ||
colorizer.plot_inputs() | ||
result = colorizer.colorize() | ||
colorizer.plot_results(result) | ||
cv2.imwrite(result_path + '.png', result) | ||
else: | ||
colorizer = IterativeColorizer( | ||
original_image=original_image, | ||
visual_clues=visual_clue | ||
) | ||
colorizer.plot_inputs() | ||
colorizer.colorize( | ||
epochs=epochs, log_interval=log_intervals | ||
) | ||
colorizer.plot_results(log_intervals=log_intervals) | ||
for i, result in enumerate(colorizer.result_history): | ||
cv2.imwrite(result_path + '{}.png'.format(i + 1), result) | ||
|
||
|
||
if __name__ == '__main__': | ||
colorize() |