-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chore): Change train_test to ghout dir, add ghout to .gitignore'
- Loading branch information
Showing
128 changed files
with
169 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,7 @@ dmypy.json | |
# Honeybee/Ladybug data | ||
/run | ||
/models | ||
/ghout | ||
*.sql | ||
|
||
|
Binary file not shown.
This file was deleted.
Oops, something went wrong.
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Diff not rendered.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""Preprocess raw outputs from GH for train/test dataset.""" | ||
import os | ||
import numpy as np | ||
|
||
import cv2 | ||
|
||
import deeprad.utils as utils | ||
import deeprad.image2vec as i2v | ||
|
||
DEEPRAD_GHOUT_DIR = utils.DEEPRAD_GHOUT_DIR | ||
DEEPRAD_TRAINTEST_DIR = utils.DEEPRAD_TRAINTEST_DIR | ||
|
||
|
||
def load_img_gray(img_fpath): | ||
return cv2.imread(img_fpath, cv2.) | ||
|
||
|
||
def preprocess_img(img_fpath): | ||
pass | ||
|
||
|
||
def main(): | ||
"""Preproces main.""" | ||
|
||
# load all directories in train/test | ||
data_num, floorplan_ids = \ | ||
utils.extract_floorplan_ids(1e6, DEEPRAD_TRAINTEST_DIR, verbose=False) | ||
|
||
# for i, floorplan_id in enumerate(floorplan_ids): | ||
i = 0 | ||
floorplan_id = floorplan_ids[0] | ||
|
||
in_dir = os.path.join(DEEPRAD_GHOUT_DIR, floorplan_id, 'in_data') | ||
out_dir = os.path.join(DEEPRAD_GHOUT_DIR, floorplan_id, 'out_label') | ||
|
||
# Preprocess labels | ||
label_fpaths = [os.path.join(out_dir, out) for out in os.listdir(out_dir)] | ||
label_imgs = [preprocess_img(fpath) for fpath in label_fpaths] | ||
#[save_img(img) for img in label_imgs] | ||
|
||
# Preprocess input images | ||
# add as channels | ||
|
||
# save new images | ||
# delete all raw images | ||
|
||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
"""Utility functions for deeprad.""" | ||
import sys | ||
import os | ||
import json | ||
from pathlib import Path | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
# Path to all models in deep_rad | ||
DEEPRAD_MODELS_DIR = os.path.abspath(os.path.join( | ||
os.getcwd(), '..', 'deeprad/data/models/')) | ||
DEEPRAD_GHOUT_DIR = os.path.abspath(os.path.join( | ||
os.getcwd(), '..', 'deeprad/data/ghout/')) | ||
DEEPRAD_TRAINTEST_DIR = os.path.abspath(os.path.join( | ||
os.getcwd(), '..', 'deeprad/data/traintest/')) | ||
|
||
|
||
def to_poly_sh(xy_arr): | ||
"""Shapely polygon from list of two arrays of x, y coordinates. | ||
Args: | ||
xy_arr: [x_arr, y_arr] | ||
Example: | ||
to_poly_sh(to_poly_np(poly_sh)) | ||
to_poly_np(to_poly_sh(poly_np)) | ||
""" | ||
return geom.Polygon([(x, y) for x, y in zip(*xy_arr)]) | ||
|
||
|
||
def to_poly_np(poly_sh): | ||
"""Two arrays of x, y coordinates from shapely polygon. | ||
Example: | ||
to_poly_sh(to_poly_np(poly_sh)) | ||
to_poly_np(to_poly_sh(poly_np)) | ||
""" | ||
return np.array(poly_sh.exterior.xy) | ||
|
||
|
||
def extract_floorplan_ids(data_num, target_data_dir=None, verbose=True): | ||
"""Safely extract root model directories for polygon extraction.""" | ||
|
||
if target_data_dir is None: | ||
target_data_dir = DEEPRAD_MODELS_DIR | ||
|
||
# Load all model directories | ||
floorplan_id_arr = os.listdir(target_data_dir) | ||
n_ids = len(floorplan_id_arr) | ||
|
||
if n_ids == 0: | ||
raise Exception('No image files. Add images and try again.') | ||
|
||
if data_num > n_ids: | ||
if verbose: | ||
print('Note: data_num {} is too high. Resetting to n_ids {}.'.format( | ||
data_num, n_ids)) | ||
data_num = n_ids | ||
|
||
return data_num, floorplan_id_arr | ||
|
||
|
||
def load_json(json_fpath): | ||
with open(json_fpath, 'r') as fp: | ||
val_dict = json.load(fp) | ||
|
||
return val_dict | ||
|
||
|
||
def load_floorplan_data(targ_id_dirs, data_num): | ||
"""Load floorplan data.""" | ||
|
||
src_img_arr = [0] * data_num | ||
label_img_arr = [0] * data_num | ||
hdict_arr = [0] * data_num | ||
targ_id_dir_arr = [0] * data_num | ||
|
||
i = -1 | ||
idx = -1 | ||
total_i = 0 | ||
null_lst = [] | ||
|
||
while (idx + 1) < data_num: | ||
i += 1 | ||
targ_id_dir = os.path.join( | ||
DEEPRAD_MODELS_DIR, targ_id_dirs[i], 'data') | ||
targ_src_fpath = os.path.join(targ_id_dir, 'src.jpg') | ||
targ_label_fpath = os.path.join(targ_id_dir, 'label.jpg') | ||
targ_json_fpath = os.path.join(targ_id_dir, 'door_vecs.json') | ||
|
||
hdict = load_json(targ_json_fpath) | ||
|
||
if hdict['scale'] < 0.4: | ||
print('Skip {} b/c scale at {}. Total skipped={}.'.format( | ||
targ_id_dirs[i], hdict['scale'], total_i)) | ||
total_i += 1 | ||
continue | ||
|
||
idx += 1 | ||
hdict_arr[idx] = hdict | ||
src_img_arr[idx] = cv2.imread(targ_src_fpath, cv2.COLOR_BGR2RGB) | ||
label_img_arr[idx] = cv2.imread(targ_label_fpath, cv2.IMREAD_GRAYSCALE) | ||
targ_id_dir_arr[idx] = targ_id_dir | ||
null_lst.append(targ_id_dirs[i] + '\n') | ||
|
||
# Write to null list | ||
null_fpath = os.path.join(DEEPRAD_MODELS_DIR, '_null.txt') | ||
with open(null_fpath, 'w') as fp: | ||
#[fp.writeline(null_) for null_ in null_lst] | ||
fp.writelines(null_lst) | ||
return hdict_arr, src_img_arr, label_img_arr, targ_id_dir_arr | ||
|
||
|
||
def make_dir_safely(dest_dir): | ||
Path(dest_dir).mkdir(parents=True, exist_ok=True) |