一、去框:
打开"segment/predict.py",去除以下代码:
if save_img or save_crop or view_img: # Add bbox to image
c = int(cls) # integer class
label = None if hide_labels else (names[c] if hide_conf else f'{names[c]} {conf:.2f}')
annotator.box_label(xyxy, label, color=colors(c, True))
annotator.draw.polygon(segments[j], outline=colors(c, True), width=3)
二、调节mask透明度
打开”utils/plots.py”,找到以下代码,并修改alpha,alpha取值范围为0-1,越靠近1越不透明,越靠近0越透明。
def masks(self, masks, colors, im_gpu=None, alpha=0.5):
三、调节想要的颜色
打开“utils/plots.py",找到以下代码,修改hexs里面的代号就行;
class Colors:
# Ultralytics color palette https://ultralytics.com/
def __init__(self):
# hex = matplotlib.colors.TABLEAU_COLORS.values()
hexs = ('FF3838', 'FF9D97', 'FF701F', 'FFB21D', 'CFD231', '48F90A', '92CC17', '3DDB86', '1A9334', '00D4BB',
'2C99A8', '00C2FF', '344593', '6473FF', '0018EC', '8438FF', '520085', 'CB38FF', 'FF95C8', 'FF37C7')
self.palette = [self.hex2rgb(f'#{c}') for c in hexs]
self.n = len(self.palette)
def __call__(self, i, bgr=False):
c = self.palette[int(i) % self.n]
return (c[2], c[1], c[0]) if bgr else c
如果你只想要单一的颜色,则可以将该部分代码修改为:
(只需要将self.black = (0, 0, 0),中的rgb参数(0,0,0)进行修改即可)
class Colors:
def __init__(self):
self.black = (0, 0, 0) # 黑色
def __call__(self, i, bgr=False):
return self.black if not bgr else self.black[::-1]