1
0
Fork 0
mirror of https://github.com/prise6/smart-iss-posts synced 2024-04-26 03:00:32 +02:00

tools class

This commit is contained in:
Francois 2019-03-09 22:42:05 +01:00
parent 88acd0d60d
commit 3b5c4c8023
2 changed files with 32 additions and 1 deletions

View file

@ -19,7 +19,6 @@ class Config:
yaml.add_implicit_resolver('!path', self.path_matcher, None, yaml.SafeLoader)
yaml.add_constructor('!path', self.path_constructor, yaml.SafeLoader)
print("ok")
with open(os.path.join(self.project_dir, 'config', 'config_%s.yaml' % (self.mode)), 'r') as ymlfile:
self.config = yaml.safe_load(ymlfile)

32
iss/tools/tools.py Normal file
View file

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
import PIL
import os
class Tools:
@staticmethod
def display_one_picture(array):
array = array.astype('uint8')
return PIL.Image.fromarray(array, 'RGB')
@staticmethod
def display_one_picture_scaled(array):
array = array * 255
return Tools.display_one_picture(array)
@staticmethod
def display_index_picture_scaled(array, index = 0):
return Tools.display_one_picture_scaled(array[index])
@staticmethod
def display_index_picture(array, index = 0):
return Tools.display_one_picture(array[index])
@staticmethod
def create_dir_if_not_exists(path):
if not os.path.exists(path):
os.makedirs(path)
return path