Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
@@ -6,6 +6,7 @@ import random
|
|
6 |
class make_im():
|
7 |
|
8 |
def __init__(self):
|
|
|
9 |
self.c_maps=['Accent', 'Accent_r', 'Blues', 'Blues_r', 'BrBG', 'BrBG_r', 'BuGn', 'BuGn_r', 'BuPu', 'BuPu_r', 'CMRmap', 'CMRmap_r', 'Dark2', 'Dark2_r', 'GnBu', 'GnBu_r', 'Grays', 'Greens', 'Greens_r', 'Greys', 'Greys_r', 'OrRd', 'OrRd_r', 'Oranges', 'Oranges_r', 'PRGn', 'PRGn_r', 'Paired', 'Paired_r', 'Pastel1', 'Pastel1_r', 'Pastel2', 'Pastel2_r', 'PiYG', 'PiYG_r', 'PuBu', 'PuBuGn', 'PuBuGn_r', 'PuBu_r', 'PuOr', 'PuOr_r', 'PuRd', 'PuRd_r', 'Purples', 'Purples_r', 'RdBu', 'RdBu_r', 'RdGy', 'RdGy_r', 'RdPu', 'RdPu_r', 'RdYlBu', 'RdYlBu_r', 'RdYlGn', 'RdYlGn_r', 'Reds', 'Reds_r', 'Set1', 'Set1_r', 'Set2', 'Set2_r', 'Set3', 'Set3_r', 'Spectral', 'Spectral_r', 'Wistia', 'Wistia_r', 'YlGn', 'YlGnBu', 'YlGnBu_r', 'YlGn_r', 'YlOrBr', 'YlOrBr_r', 'YlOrRd', 'YlOrRd_r', 'afmhot', 'afmhot_r', 'autumn', 'autumn_r', 'binary', 'binary_r', 'bone', 'bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r', 'cividis', 'cividis_r', 'cool', 'cool_r', 'coolwarm', 'coolwarm_r', 'copper', 'copper_r', 'cubehelix', 'cubehelix_r', 'flag', 'flag_r', 'gist_earth', 'gist_earth_r', 'gist_gray', 'gist_gray_r', 'gist_grey', 'gist_heat', 'gist_heat_r', 'gist_ncar', 'gist_ncar_r', 'gist_rainbow', 'gist_rainbow_r', 'gist_stern', 'gist_stern_r', 'gist_yarg', 'gist_yarg_r', 'gist_yerg', 'gnuplot', 'gnuplot2', 'gnuplot2_r', 'gnuplot_r', 'gray', 'gray_r', 'grey', 'hot', 'hot_r', 'hsv', 'hsv_r', 'inferno', 'inferno_r', 'jet', 'jet_r', 'magma', 'magma_r', 'nipy_spectral', 'nipy_spectral_r', 'ocean', 'ocean_r', 'pink', 'pink_r', 'plasma', 'plasma_r', 'prism', 'prism_r', 'rainbow', 'rainbow_r', 'seismic', 'seismic_r', 'spring', 'spring_r', 'summer', 'summer_r', 'tab10', 'tab10_r', 'tab20', 'tab20_r', 'tab20b', 'tab20b_r', 'tab20c', 'tab20c_r', 'terrain', 'terrain_r', 'turbo', 'turbo_r', 'twilight', 'twilight_r', 'twilight_shifted', 'twilight_shifted_r', 'viridis', 'viridis_r', 'winter', 'winter_r']
|
10 |
self.img_size = (256,256)
|
11 |
|
@@ -23,12 +24,12 @@ class make_im():
|
|
23 |
cmap = ea
|
24 |
self.epwtimg = ColoredPath(self.epwtpath, self.mask.shape).get_colored_path(cmap)
|
25 |
self.pimg = ColoredPath(self.ppath, self.mask.shape).get_colored_path(cmap)
|
26 |
-
if not os.path.isdir(f"
|
27 |
-
os.mkdir(f'
|
28 |
else: pass
|
29 |
-
matplotlib.image.imsave(f"
|
30 |
-
matplotlib.image.imsave(f"
|
31 |
-
matplotlib.image.imsave(f"
|
32 |
|
33 |
def run_1(self,name='temp',img_size=[128,128],cmap='flag_r',key=0):
|
34 |
randvar = random.randint(2,10)
|
@@ -36,14 +37,14 @@ class make_im():
|
|
36 |
self.epwtpath = EPWTPath(self.mask).get_path()
|
37 |
self.ppath = ProbabilisticPath(self.mask).get_path()
|
38 |
|
39 |
-
if not os.path.isdir(f"
|
40 |
-
os.mkdir(f'
|
41 |
self.epwtimg = ColoredPath(self.epwtpath, self.mask.shape).get_colored_path(cmap)
|
42 |
self.pimg = ColoredPath(self.ppath, self.mask.shape).get_colored_path(cmap)
|
43 |
|
44 |
-
matplotlib.image.imsave(f"
|
45 |
-
matplotlib.image.imsave(f"
|
46 |
-
matplotlib.image.imsave(f"
|
47 |
return self.pimg
|
48 |
#img = get_random_image(img_size) #returns numpy array
|
49 |
#print(img)
|
|
|
6 |
class make_im():
|
7 |
|
8 |
def __init__(self):
|
9 |
+
self.root=os.getcwd()
|
10 |
self.c_maps=['Accent', 'Accent_r', 'Blues', 'Blues_r', 'BrBG', 'BrBG_r', 'BuGn', 'BuGn_r', 'BuPu', 'BuPu_r', 'CMRmap', 'CMRmap_r', 'Dark2', 'Dark2_r', 'GnBu', 'GnBu_r', 'Grays', 'Greens', 'Greens_r', 'Greys', 'Greys_r', 'OrRd', 'OrRd_r', 'Oranges', 'Oranges_r', 'PRGn', 'PRGn_r', 'Paired', 'Paired_r', 'Pastel1', 'Pastel1_r', 'Pastel2', 'Pastel2_r', 'PiYG', 'PiYG_r', 'PuBu', 'PuBuGn', 'PuBuGn_r', 'PuBu_r', 'PuOr', 'PuOr_r', 'PuRd', 'PuRd_r', 'Purples', 'Purples_r', 'RdBu', 'RdBu_r', 'RdGy', 'RdGy_r', 'RdPu', 'RdPu_r', 'RdYlBu', 'RdYlBu_r', 'RdYlGn', 'RdYlGn_r', 'Reds', 'Reds_r', 'Set1', 'Set1_r', 'Set2', 'Set2_r', 'Set3', 'Set3_r', 'Spectral', 'Spectral_r', 'Wistia', 'Wistia_r', 'YlGn', 'YlGnBu', 'YlGnBu_r', 'YlGn_r', 'YlOrBr', 'YlOrBr_r', 'YlOrRd', 'YlOrRd_r', 'afmhot', 'afmhot_r', 'autumn', 'autumn_r', 'binary', 'binary_r', 'bone', 'bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r', 'cividis', 'cividis_r', 'cool', 'cool_r', 'coolwarm', 'coolwarm_r', 'copper', 'copper_r', 'cubehelix', 'cubehelix_r', 'flag', 'flag_r', 'gist_earth', 'gist_earth_r', 'gist_gray', 'gist_gray_r', 'gist_grey', 'gist_heat', 'gist_heat_r', 'gist_ncar', 'gist_ncar_r', 'gist_rainbow', 'gist_rainbow_r', 'gist_stern', 'gist_stern_r', 'gist_yarg', 'gist_yarg_r', 'gist_yerg', 'gnuplot', 'gnuplot2', 'gnuplot2_r', 'gnuplot_r', 'gray', 'gray_r', 'grey', 'hot', 'hot_r', 'hsv', 'hsv_r', 'inferno', 'inferno_r', 'jet', 'jet_r', 'magma', 'magma_r', 'nipy_spectral', 'nipy_spectral_r', 'ocean', 'ocean_r', 'pink', 'pink_r', 'plasma', 'plasma_r', 'prism', 'prism_r', 'rainbow', 'rainbow_r', 'seismic', 'seismic_r', 'spring', 'spring_r', 'summer', 'summer_r', 'tab10', 'tab10_r', 'tab20', 'tab20_r', 'tab20b', 'tab20b_r', 'tab20c', 'tab20c_r', 'terrain', 'terrain_r', 'turbo', 'turbo_r', 'twilight', 'twilight_r', 'twilight_shifted', 'twilight_shifted_r', 'viridis', 'viridis_r', 'winter', 'winter_r']
|
11 |
self.img_size = (256,256)
|
12 |
|
|
|
24 |
cmap = ea
|
25 |
self.epwtimg = ColoredPath(self.epwtpath, self.mask.shape).get_colored_path(cmap)
|
26 |
self.pimg = ColoredPath(self.ppath, self.mask.shape).get_colored_path(cmap)
|
27 |
+
if not os.path.isdir(f"{self.root}/image_alls/{ea}"):
|
28 |
+
os.mkdir(f'{self.root}/images_all/{ea}')
|
29 |
else: pass
|
30 |
+
matplotlib.image.imsave(f"{self.root}/images_all/{ea}/{ea}_mask.png", self.mask, cmap='gray')
|
31 |
+
matplotlib.image.imsave(f"{self.root}/images_all/{ea}/{ea}_epwt.png", self.epwtimg)
|
32 |
+
matplotlib.image.imsave(f"{self.root}/images_all/{ea}/{ea}_prob.png", self.pimg)
|
33 |
|
34 |
def run_1(self,name='temp',img_size=[128,128],cmap='flag_r',key=0):
|
35 |
randvar = random.randint(2,10)
|
|
|
37 |
self.epwtpath = EPWTPath(self.mask).get_path()
|
38 |
self.ppath = ProbabilisticPath(self.mask).get_path()
|
39 |
|
40 |
+
if not os.path.isdir(f"{self.root}/images"):
|
41 |
+
os.mkdir(f'{self.root}/images')
|
42 |
self.epwtimg = ColoredPath(self.epwtpath, self.mask.shape).get_colored_path(cmap)
|
43 |
self.pimg = ColoredPath(self.ppath, self.mask.shape).get_colored_path(cmap)
|
44 |
|
45 |
+
matplotlib.image.imsave(f"{self.root}/images/{name}_mask.png", self.mask, cmap='gray')
|
46 |
+
matplotlib.image.imsave(f"{self.root}/images/{name}_epwt.png", self.epwtimg)
|
47 |
+
matplotlib.image.imsave(f"{self.root}/images/{name}_prob.png", self.pimg)
|
48 |
return self.pimg
|
49 |
#img = get_random_image(img_size) #returns numpy array
|
50 |
#print(img)
|