2022-02-15 04:03:45 +01:00
|
|
|
import os
|
|
|
|
import numpy as np
|
|
|
|
import pandas as pd
|
|
|
|
import random
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import time
|
|
|
|
|
|
|
|
#progess bar
|
|
|
|
from tqdm import tqdm
|
|
|
|
|
|
|
|
import cv2
|
|
|
|
import warnings
|
|
|
|
#deep learning
|
|
|
|
|
2022-02-15 19:04:21 +01:00
|
|
|
from consts import SEED, JPG_IMAGES, FC_DIR, FEATURES, MASK_DIR, LABELS
|
|
|
|
from helpers import create_folder, convert_tif_to_jpg, progress_bar
|
2022-02-15 04:03:45 +01:00
|
|
|
|
|
|
|
warnings.filterwarnings('ignore')
|
|
|
|
|
|
|
|
def transform_photo(tif_dir):
|
|
|
|
dp = create_folder(tif_dir, JPG_IMAGES)
|
|
|
|
fc = create_folder(FC_DIR, dp)
|
2022-02-15 19:04:21 +01:00
|
|
|
mk = create_folder(MASK_DIR, dp)
|
|
|
|
convert_tif_to_jpg(os.path.join(FEATURES, tif_dir), os.path.join(LABELS, tif_dir + ".tif"), dp, fc, mk)
|
2022-02-16 15:05:05 +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)
|
|
|
|
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 15:05:05 +01:00
|
|
|
if d != ".DS_Store":
|
|
|
|
transform_photo(d)
|