Skip to content

Commit

Permalink
[bugfix] lut颜色随机生成 (#48)
Browse files Browse the repository at this point in the history
* lut颜色随机生成

* lut颜色随机生成

* 简化代码

* 指定最大类别数
  • Loading branch information
jscslld authored Oct 31, 2022
1 parent a9e1b00 commit db6e6da
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions backend/applications/interface/semantic_segmentation.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
import os.path as osp
from collections import Counter

import cv2
import numpy as np
import paddlers as pdrs
from paddlers.tasks.utils.visualize import get_color_map_list
from skimage.io import imsave

from applications.common.path_global import md5_name, generate_url


def get_lut():
lut = np.zeros((256, 3), dtype=np.uint8)
lut[0] = [255, 0, 0] # 红
lut[1] = [30, 255, 142] # 浅绿
lut[2] = [60, 0, 255] # 蓝
lut[3] = [255, 222, 0] # 橙黄
lut[4] = [255, 0, 255] # 粉
return lut


def execute(model_path, data_path, out_dir, test_names):
image_list = [osp.join(data_path, name) for name in test_names]
predictor = pdrs.deploy.Predictor(model_path, use_gpu=True)
pred = predictor.predict(image_list)
ims = [i['label_map'] for i in pred]
lut = get_lut()
temps = list()
lut = np.array(get_color_map_list(256))
for idx, im in zip(range(len(image_list)), ims):
im = lut[im]
new_name = md5_name(test_names[idx])
Expand Down

0 comments on commit db6e6da

Please sign in to comment.