wko-on-cloud-n/setup.py

28 lines
1.2 KiB
Python
Raw Normal View History

2022-02-15 04:03:45 +01:00
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import time
2022-02-16 19:22:34 +01:00
import sys
import random
2022-02-15 04:03:45 +01:00
import cv2
2022-02-17 03:04:00 +01:00
from src.consts import SEED, JPG_IMAGES, FC_DIR, FEATURES, MASK_DIR, LABELS, RGB_DIR
from src.helpers import create_folder, convert_tif_to_jpg, progress_bar
from src.utils import plot_image_grid
2022-02-16 19:22:34 +01:00
2022-02-15 04:03:45 +01:00
if __name__ == "__main__":
2022-02-15 19:04:21 +01:00
dirs = os.listdir(FEATURES)
2022-02-16 19:22:34 +01:00
dp = create_folder(RGB_DIR, JPG_IMAGES)
fc = create_folder(FC_DIR, JPG_IMAGES)
mk = create_folder(MASK_DIR, JPG_IMAGES)
if(len(sys.argv) <= 1):
progress_bar(0, len(dirs), prefix = 'Converting TIF to JPG:', suffix = 'Complete', length = 50)
for i, d in enumerate(dirs):
progress_bar(i, len(dirs), prefix = 'Converting TIF to JPG:', suffix = 'Complete', length = 50)
2022-02-16 19:35:24 +01:00
if(not os.path.exists(os.path.join(dp, d +'.jpeg')) or not os.path.exists(os.path.join(fc, d +'.jpeg')) or not os.path.exists(os.path.join(mk, d +'.jpeg'))):
convert_tif_to_jpg(os.path.join(FEATURES, d), os.path.join(LABELS, d + ".tif"), dp, fc, mk)
2022-02-16 19:22:34 +01:00
elif(sys.argv[1] == '--show'):
img_names = [random.choice(os.listdir(dp)) for _ in range(3)]
plot_image_grid(img_names)