-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added common package, splitted common functions, updatd picture showi…
…ng, updated inpainting
- Loading branch information
1 parent
b530531
commit d1a6e85
Showing
9 changed files
with
124 additions
and
71 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
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
Empty file.
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,17 @@ | ||
def time_this(function: callable) -> callable: | ||
""" Print the execution time of the wrapped function. """ | ||
def wrapper(*args, **kwargs): | ||
from time import time | ||
time_begin = time() | ||
result = function(*args, **kwargs) | ||
time_end = time() | ||
time_total = time_end - time_begin | ||
second_or_seconds = "second" if (time_total < 1) else "seconds" | ||
print("Execution time for \"{}\": {} {}".format( | ||
function.__name__, time_total, second_or_seconds)) | ||
return result | ||
return wrapper | ||
|
||
|
||
if __name__ == "__main__": | ||
pass |
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,36 @@ | ||
from typing import List | ||
|
||
import numpy as np | ||
from matplotlib import pyplot as plt | ||
|
||
|
||
def show_pictures(pictures: iter, titles: List[str] = None, columns: int = 1): | ||
""" Display a list of images in a single figure with matplotlib. | ||
:param pictures: List of np.arrays compatible with plt.imshow | ||
:param titles: List of titles corresponding to each image. Must have the same length as titles. | ||
:param columns: Number of columns in figure (number of rows is set to np.ceil(n_images / float(cols))) | ||
Source : | ||
https://gist.github.com/soply/f3eec2e79c165e39c9d540e916142ae1 | ||
""" | ||
assert ((titles is None) or (len(pictures) == len(titles))) | ||
|
||
# Set default title names for each picture | ||
if titles is None: | ||
titles = ['Image (%d)' % i for i in range(1, len(pictures) + 1)] | ||
|
||
fig = plt.figure() | ||
for index_picture, (picture, title) in enumerate(zip(pictures, titles)): | ||
sub_figure = fig.add_subplot(columns, np.ceil(len(pictures) / float(columns)), index_picture + 1) | ||
if picture.ndim == 2: | ||
plt.gray() | ||
plt.imshow(picture) | ||
sub_figure.set_title(title) | ||
sub_figure.axis("off") | ||
fig.set_size_inches(np.array(fig.get_size_inches()) * len(pictures)) | ||
plt.show() | ||
|
||
|
||
if __name__ == "__main__": | ||
pass |
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
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