forked from basujindal/stable-diffusion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
31 lines (26 loc) · 1.02 KB
/
utils.py
File metadata and controls
31 lines (26 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import configparser
import os
from PIL import Image
from colorama import Fore
def read_config():
config = configparser.ConfigParser()
config.read('config.ini')
try:
HEIGHT = config['SETTINGS'].getint('image_height')
WIDTH = config['SETTINGS'].getint('image_width')
N_ITER = config['SETTINGS'].getint('number_of_iterations')
N_SAMPLES = config['SETTINGS'].getint('number_of_images_per_iteration')
USE_SEED = config['SETTINGS'].getboolean('use_seed')
SEED = config['SETTINGS'].getint('seed')
except:
print(Fore.YELLOW +'Your configuration file seems to be invalid.'+ Fore.WHITE)
exit()
return HEIGHT, WIDTH, N_ITER, N_SAMPLES, USE_SEED, SEED
def check_init_img_path(path):
if(os.path.isfile(path)):
try:
Image.open(path)
return path
except:
raise Exception(Fore.YELLOW +'Incompatible file format.'+ Fore.WHITE)
raise Exception(Fore.YELLOW +'The specified file does not exist.'+ Fore.WHITE)