Fix tools import bugs

own
Bobholamovic 2 years ago
parent 92933a8d4a
commit 514331c52a
  1. 14
      tools/coco2mask.py
  2. 18
      tools/mask2geojson.py
  3. 20
      tools/mask2shape.py
  4. 24
      tools/match.py
  5. 14
      tools/oif.py
  6. 16
      tools/pca.py
  7. 21
      tools/split.py

@ -19,8 +19,9 @@ import json
import argparse
from collections import defaultdict
import cv2
import paddlers
import numpy as np
import cv2
import glob
from tqdm import tqdm
from PIL import Image
@ -101,12 +102,11 @@ def convert_data(raw_dir, end_dir):
lab_save_path)
parser = argparse.ArgumentParser()
parser.add_argument("--raw_dir", type=str, required=True, \
help="Directory that contains original data, where `images` stores the original image and `annotation.json` stores the corresponding annotation information.")
parser.add_argument("--save_dir", type=str, required=True, \
help="Directory to save the results, where `img` stores the image and `gt` stores the label.")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--raw_dir", type=str, required=True, \
help="Directory that contains original data, where `images` stores the original image and `annotation.json` stores the corresponding annotation information.")
parser.add_argument("--save_dir", type=str, required=True, \
help="Directory to save the results, where `img` stores the image and `gt` stores the label.")
args = parser.parse_args()
convert_data(args.raw_dir, args.save_dir)

@ -14,11 +14,14 @@
import os
import codecs
import cv2
import numpy as np
import argparse
import paddlers
import numpy as np
import cv2
import geojson
from tqdm import tqdm
from utils import Raster, save_geotiff, translate_vector, time_it
@ -60,12 +63,11 @@ def convert_data(image_path, geojson_path):
os.remove(temp_geojson_path)
parser = argparse.ArgumentParser()
parser.add_argument("--mask_path", type=str, required=True, \
help="Path of mask data.")
parser.add_argument("--save_path", type=str, required=True, \
help="Path to store the GeoJSON file (the coordinate system is WGS84).")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--mask_path", type=str, required=True, \
help="Path of mask data.")
parser.add_argument("--save_path", type=str, required=True, \
help="Path to store the GeoJSON file (the coordinate system is WGS84).")
args = parser.parse_args()
convert_data(args.raster_path, args.geojson_path)

@ -16,6 +16,7 @@ import os
import os.path as osp
import argparse
import paddlers
import numpy as np
from PIL import Image
try:
@ -89,17 +90,16 @@ def mask2shape(srcimg_path, mask_path, save_path, ignore_index=255):
vec_ext)
parser = argparse.ArgumentParser()
parser.add_argument("--mask_path", type=str, required=True, \
help="Path of mask data.")
parser.add_argument("--save_path", type=str, required=True, \
help="Path to save the shape file (the extension is .json/geojson or .shp).")
parser.add_argument("--srcimg_path", type=str, default="", \
help="Path of original data with geoinfo. Default to empty.")
parser.add_argument("--ignore_index", type=int, default=255, \
help="The ignored index will not be converted to a value in the shape file. Default value is 255.")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--mask_path", type=str, required=True, \
help="Path of mask data.")
parser.add_argument("--save_path", type=str, required=True, \
help="Path to save the shape file (the extension is .json/geojson or .shp).")
parser.add_argument("--srcimg_path", type=str, default="", \
help="Path of original data with geoinfo. Default to empty.")
parser.add_argument("--ignore_index", type=int, default=255, \
help="The ignored index will not be converted to a value in the shape file. Default value is 255.")
args = parser.parse_args()
mask2shape(args.srcimg_path, args.mask_path, args.save_path,
args.ignore_index)

@ -14,6 +14,7 @@
import argparse
import paddlers
import numpy as np
import cv2
@ -78,19 +79,18 @@ def match(im1_path,
im1_ras.datatype)
parser = argparse.ArgumentParser(description="input parameters")
parser.add_argument('--im1_path', type=str, required=True, \
help="Path of time1 image (with geoinfo).")
parser.add_argument('--im2_path', type=str, required=True, \
help="Path of time2 image.")
parser.add_argument('--save_path', type=str, required=True, \
help="Path to save matching result.")
parser.add_argument('--im1_bands', type=int, nargs="+", default=[1, 2, 3], \
help="Bands of im1 to be used for matching, RGB or monochrome. The default value is [1, 2, 3].")
parser.add_argument('--im2_bands', type=int, nargs="+", default=[1, 2, 3], \
help="Bands of im2 to be used for matching, RGB or monochrome. The default value is [1, 2, 3].")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="input parameters")
parser.add_argument('--im1_path', type=str, required=True, \
help="Path of time1 image (with geoinfo).")
parser.add_argument('--im2_path', type=str, required=True, \
help="Path of time2 image.")
parser.add_argument('--save_path', type=str, required=True, \
help="Path to save matching result.")
parser.add_argument('--im1_bands', type=int, nargs="+", default=[1, 2, 3], \
help="Bands of im1 to be used for matching, RGB or monochrome. The default value is [1, 2, 3].")
parser.add_argument('--im2_bands', type=int, nargs="+", default=[1, 2, 3], \
help="Bands of im2 to be used for matching, RGB or monochrome. The default value is [1, 2, 3].")
args = parser.parse_args()
match(args.im1_path, args.im2_path, args.save_path, args.im1_bands,
args.im2_bands)

@ -14,10 +14,11 @@
import itertools
import argparse
from easydict import EasyDict as edict
import paddlers
import numpy as np
import pandas as pd
from easydict import EasyDict as edict
from utils import Raster, time_it
@ -55,12 +56,11 @@ def oif(img_path, topk=5):
print("Bands: {0}, OIF value: {1}.".format(k, v))
parser = argparse.ArgumentParser()
parser.add_argument("--im_path", type=str, required=True, \
help="Path of HSIs image.")
parser.add_argument("--topk", type=int, default=5, \
help="Number of top results. The default value is 5.")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--im_path", type=str, required=True, \
help="Path of HSIs image.")
parser.add_argument("--topk", type=int, default=5, \
help="Number of top results. The default value is 5.")
args = parser.parse_args()
oif(args.im_path, args.topk)

@ -17,6 +17,7 @@ import os.path as osp
import numpy as np
import argparse
import paddlers
from sklearn.decomposition import PCA
from joblib import dump
@ -43,14 +44,13 @@ def pca_train(img_path, save_dir="output", dim=3):
save_dir))
parser = argparse.ArgumentParser()
parser.add_argument("--im_path", type=str, required=True, \
help="Path of HSIs image.")
parser.add_argument("--save_dir", type=str, default="output", \
help="Directory to save PCA params(*.joblib). Default: output.")
parser.add_argument("--dim", type=int, default=3, \
help="Dimension to reduce to. Default: 3.")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--im_path", type=str, required=True, \
help="Path of HSIs image.")
parser.add_argument("--save_dir", type=str, default="output", \
help="Directory to save PCA params(*.joblib). Default: output.")
parser.add_argument("--dim", type=int, default=3, \
help="Dimension to reduce to. Default: 3.")
args = parser.parse_args()
pca_train(args.im_path, args.save_dir, args.dim)

@ -16,6 +16,8 @@ import os
import os.path as osp
import argparse
from math import ceil
import paddlers
from tqdm import tqdm
from utils import Raster, save_geotiff, time_it
@ -67,16 +69,15 @@ def split_data(image_path, mask_path, block_size, save_dir):
pbar.update(1)
parser = argparse.ArgumentParser(description="input parameters")
parser.add_argument("--image_path", type=str, required=True, \
help="Path of input image.")
parser.add_argument("--mask_path", type=str, default=None, \
help="Path of input labels.")
parser.add_argument("--block_size", type=int, default=512, \
help="Size of image block. Default value is 512.")
parser.add_argument("--save_dir", type=str, default="dataset", \
help="Directory to save the results. Default value is 'dataset'.")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="input parameters")
parser.add_argument("--image_path", type=str, required=True, \
help="Path of input image.")
parser.add_argument("--mask_path", type=str, default=None, \
help="Path of input labels.")
parser.add_argument("--block_size", type=int, default=512, \
help="Size of image block. Default value is 512.")
parser.add_argument("--save_dir", type=str, default="dataset", \
help="Directory to save the results. Default value is 'dataset'.")
args = parser.parse_args()
split_data(args.image_path, args.mask_path, args.block_size, args.save_dir)

Loading…
Cancel
Save