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
<configuration> | |
<property> | |
<name>mapreduce.framework.name</name> | |
<value>yarn</value> | |
</property> | |
<property> | |
<name>yarn.app.mapreduce.am.env</name> | |
<value>HADOOP_MAPRED_HOME=/opt/hadoop-3.2.2</value> | |
</property> | |
<property> |
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
<configuration> | |
<property> | |
<name>yarn.resourcemanager.hostname</name> | |
<value>your_hostname</value> | |
</property> | |
<property> | |
<name>yarn.nodemanager.aux-services</name> | |
<value>mapreduce_shuffle</value> | |
</property> | |
<property> |
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
class EntirePalette: | |
# ... omitted | |
def recolor(self, image): | |
image_shape = image.shape | |
image = self._preprocess(image) | |
image_colors = np.unique(image, axis=0) | |
self_da = da.from_array( | |
self.source_pixels.astype(np.long), chunks=(self.chunk_size, 3) |
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
typedef struct { | |
unsigned char r, g, b; | |
} RGB; | |
double ColourDistance(RGB e1, RGB e2) | |
{ | |
long rmean = ( (long)e1.r + (long)e2.r ) / 2; | |
long r = (long)e1.r - (long)e2.r; | |
long g = (long)e1.g - (long)e2.g; | |
long b = (long)e1.b - (long)e2.b; |
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
src = np.array(imread('carles-rabada-DD1fSz2HF1s-unsplash-small.png'))[:, :, :3] | |
trn = np.array(imread('olia-gozha-9A_peGrSbZc-unsplash-small.png'))[:, :, :3] | |
src = np.unique(src.reshape(-1, 3), axis=0) | |
trn = np.unique(trn.reshape(-1, 3), axis=0) | |
self_da = da.from_array(src.astype(np.long), chunks=(1024, 3)) | |
other_da = da.from_array(trn.reshape(-1, 1, 3).astype(np.long), | |
chunks=(1024, 1, 3)) | |
rgb_da = self_da - other_da | |
display(self_da) | |
display(other_da) |
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
class EntirePalette: | |
def __init__(self, chunk_size=1024): | |
self.chunk_size = chunk_size | |
self.source_pixels = None | |
def _preprocess(self, image): | |
# ... omitted, same as KMeansReducedPalette | |
def fit(self, image): | |
self.source_pixels = np.unique(self._preprocess(image), axis=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
class KMeansReducedPalette: | |
# ... omitted | |
def random_neighborhood_walk_recolor(self, image, max_steps): | |
original_shape = image.shape | |
image = self._preprocess(image) | |
recolor = image.copy() | |
centroid_idxs = self.kmeans.predict(image) | |
for ci in range(self.num_colors): |
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
class KMeansReducedPalette: | |
# ... omitted | |
def fit(self, image): | |
image_cpy = image.copy() | |
self.source_pixels = self._preprocess(image_cpy) | |
self.kmeans.fit(self.source_pixels) | |
self.centroid_nearest_pixels = [] |
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
class KMeansReducedPalette: | |
# ... omitted | |
def random_walk_recolor(self, image, max_steps): | |
original_shape = image.shape | |
image = self._preprocess(image) | |
centroids = self.kmeans.predict(image) | |
start = np.round(self.kmeans.cluster_centers_[centroids]) | |
diff = np.zeros(image.shape) |
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
class UniqueKMeansReducedPalette(KMeansReducedPalette): | |
def __init__(self, num_colors): | |
super().__init__(num_colors) | |
def fit(self, image): | |
image_cpy = image.copy() | |
pixels = self._preprocess(image_cpy) | |
super().fit(np.unique(pixels, axis=0)) |
NewerOlder