提交 2b8a3dfb 编写于 作者: D Dang Qingqing

Merge branch 'develop' of https://github.com/PaddlePaddle/models into ssd_pl_exe

...@@ -85,8 +85,7 @@ def satisfy_sample_constraint(sampler, sample_bbox, bbox_labels): ...@@ -85,8 +85,7 @@ def satisfy_sample_constraint(sampler, sample_bbox, bbox_labels):
return False return False
def generate_batch_samples(batch_sampler, bbox_labels, image_width, def generate_batch_samples(batch_sampler, bbox_labels):
image_height):
sampled_bbox = [] sampled_bbox = []
index = [] index = []
c = 0 c = 0
...@@ -217,8 +216,8 @@ def distort_image(img, settings): ...@@ -217,8 +216,8 @@ def distort_image(img, settings):
def expand_image(img, bbox_labels, img_width, img_height, settings): def expand_image(img, bbox_labels, img_width, img_height, settings):
prob = random.uniform(0, 1) prob = random.uniform(0, 1)
if prob < settings._expand_prob: if prob < settings._expand_prob:
expand_ratio = random.uniform(1, settings._expand_max_ratio) if _expand_max_ratio - 1 >= 0.01:
if expand_ratio - 1 >= 0.01: expand_ratio = random.uniform(1, settings._expand_max_ratio)
height = int(img_height * expand_ratio) height = int(img_height * expand_ratio)
width = int(img_width * expand_ratio) width = int(img_width * expand_ratio)
h_off = math.floor(random.uniform(0, height - img_height)) h_off = math.floor(random.uniform(0, height - img_height))
...@@ -231,5 +230,5 @@ def expand_image(img, bbox_labels, img_width, img_height, settings): ...@@ -231,5 +230,5 @@ def expand_image(img, bbox_labels, img_width, img_height, settings):
expand_img = Image.fromarray(expand_img) expand_img = Image.fromarray(expand_img)
expand_img.paste(img, (int(w_off), int(h_off))) expand_img.paste(img, (int(w_off), int(h_off)))
bbox_labels = transform_labels(bbox_labels, expand_bbox) bbox_labels = transform_labels(bbox_labels, expand_bbox)
return expand_img, bbox_labels return expand_img, bbox_labels, width, height
return img, bbox_labels return img, bbox_labels, img_width, img_height
...@@ -193,7 +193,7 @@ def _reader_creator(settings, file_list, mode, shuffle): ...@@ -193,7 +193,7 @@ def _reader_creator(settings, file_list, mode, shuffle):
if settings._apply_distort: if settings._apply_distort:
img = image_util.distort_image(img, settings) img = image_util.distort_image(img, settings)
if settings._apply_expand: if settings._apply_expand:
img, bbox_labels = image_util.expand_image( img, bbox_labels, img_width, img_height = image_util.expand_image(
img, bbox_labels, img_width, img_height, settings) img, bbox_labels, img_width, img_height, settings)
batch_sampler = [] batch_sampler = []
# hard-code here # hard-code here
...@@ -236,7 +236,6 @@ def _reader_creator(settings, file_list, mode, shuffle): ...@@ -236,7 +236,6 @@ def _reader_creator(settings, file_list, mode, shuffle):
sample_labels[i][1] = 1 - sample_labels[i][3] sample_labels[i][1] = 1 - sample_labels[i][3]
sample_labels[i][3] = 1 - tmp sample_labels[i][3] = 1 - tmp
#draw_bounding_box_on_image(img, sample_labels, image_name, category_names, normalized=True)
# HWC to CHW # HWC to CHW
if len(img.shape) == 3: if len(img.shape) == 3:
img = np.swapaxes(img, 1, 2) img = np.swapaxes(img, 1, 2)
...@@ -287,7 +286,6 @@ def draw_bounding_box_on_image(image, ...@@ -287,7 +286,6 @@ def draw_bounding_box_on_image(image,
(left, top)], (left, top)],
width=thickness, width=thickness,
fill=color) fill=color)
#draw.rectangle([xmin, ymin, xmax, ymax], outline=color)
if with_text: if with_text:
if image.mode == 'RGB': if image.mode == 'RGB':
draw.text((left, top), category_name, (255, 255, 0)) draw.text((left, top), category_name, (255, 255, 0))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册