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:
parent
88acd0d60d
commit
3b5c4c8023
|
@ -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
32
iss/tools/tools.py
Normal 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
|
||||
|
||||
|
Loading…
Reference in a new issue