wko-on-cloud-n/setup.py
Maciej Sobkowiak 59fe53fa40 adsdfasdga
2022-02-17 03:04:00 +01:00

28 lines
1.2 KiB
Python

import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import time
import sys
import random
import cv2
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
if __name__ == "__main__":
dirs = os.listdir(FEATURES)
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)
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)
elif(sys.argv[1] == '--show'):
img_names = [random.choice(os.listdir(dp)) for _ in range(3)]
plot_image_grid(img_names)