-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.py
45 lines (34 loc) · 886 Bytes
/
common.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""This file holds common functions."""
import os
# Class of images
COVID_CLASS = 'COVID'
NON_COVID_CLASS = 'NON_COVID'
# Name of the folders of images
COVID_FOLDER = '/COVID'
NON_COVID_FOLDER = '/NON_COVID'
def create_folder(foldername):
"""
If there is no folder with the input folder name, then create it.
Parameters
----------
foldername : str
The name of the folder to be created.
"""
if not os.path.isdir(foldername):
os.mkdir(foldername)
def get_class(filename):
"""
Return the class of the input image through its filename.
Parameters
----------
filename : str
Input image filename.
Returns
-------
out : str
The class of the input image.
"""
if COVID_FOLDER in filename:
return COVID_CLASS
if NON_COVID_FOLDER in filename:
return NON_COVID_CLASS