当前位置: 首页 > news >正文

分割模型 语言转分割CLIPSeg - MKT

 

CLIPSeg 

 

 

 

联合项目

 

https://github.com/loki-keroro/SAMbase_segmentation?tab=readme-ov-file

image

 

image

 

自定义提示

模型会根据不同的提示文本,生成不同的掩码,可修改main.py中的category_cfg变量,自定义提示文本。

  • landcover_prompts 为地物分类的提示,在全景图中场景下一般用于分割区域连续或新增的类别
  • cityobject_prompts 作为实例分割的提示,在全景图中场景下一般用于图像内区域不连续的对象类别
  • landcover_prompts_cn和cityobject_prompts_cn为每个类别的中文含义
category_cfg = {"landcover_prompts": ['building', 'low vegetation', 'tree', 'river', 'shed', 'road', 'lake', 'bare soil'],"landcover_prompts_cn": ['建筑', '低矮植被', '树木', '河流', '棚屋', '道路', '湖泊', '裸土'],"cityobject_prompts": ['car', 'truck', 'bus', 'train', 'ship', 'boat'],"cityobject_prompts_cn": ['轿车', '卡车', '巴士', '列车', '船(舰)', '船(舶)']
}

  

 

from inference import PSAM# 模型配置文件和权重文件
model_cfg = {"DINO_WEIGHT_PATH": "weights/GSA_weights/groundingdino_swinb_cogcoor.pth","DINO_CFG_PATH": "groundingdino/config/GroundingDINO_SwinB.py","SAM_WEIGHT_PATH": "weights/GSA_weights/sam_vit_h_4b8939.pth","CLIP_WEIGHT_DIR": "weights/CLIP_weights/"
}# prompts提示,可自定义类别列表
# 模型会根据不同的prompts提示,生成不同的掩码
# category_cfg = {
#     "landcover_prompts": ['building', 'low vegetation', 'tree', 'water', 'shed', 'road', 'lake', 'bare soil',],
#     "landcover_prompts_cn": ['建筑', '低矮植被', '树木', '水体', '棚屋', '道路', '湖泊', '裸土'],
#     "cityobject_prompts": ['car', 'truck', 'bus', 'train', 'ship', 'boat'],
#     "cityobject_prompts_cn": ['轿车', '卡车', '巴士', '列车', '船(舰)', '船(舶)']
# }
category_cfg = {"landcover_prompts": [ 'building', 'water', 'tree', 'road','shed', 'cropland','grassland', 'Agricultural Fields','bare soil'],"landcover_prompts_cn": ['建筑', '水体', '树木', '道路', '棚屋', '农田', '草地', '农用地','裸土'],"cityobject_prompts": ['car', 'truck','train'],"cityobject_prompts_cn": ['轿车', '货车','火车']
}gpus = ["1"]# matplotlib使用中文绘制
cn_style = False # 是否使用中文
font_style_path = '/usr/share/fonts/wqy-microhei/wqy-microhei.ttc' # 中文字体路径,可通过fc-list命令查看系统中所安装的字体if __name__ == "__main__":psam = PSAM(model_cfg, category_cfg, gpus)# img_path = "/home/piesat/data/无人机全景图/panorama01-04/match_imgs/CD_dataset/01->03/A_B/A/100_right_0_1_hw(2701,672).png"# img_path = "/home/piesat/media/ljh/pycharm_project__ljh/panorama_sam/photos/c1.png"file_path = '/home/piesat/data/无人机全景图/panorama01-04/match_imgs/CD_dataset/cwptys_tmp/A'save_path = '/home/piesat/media/ljh/pycharm_project__ljh/panorama_sam/photos/croplands/'import osfiles = []for root, dirs, filenames in os.walk(file_path):for filename in filenames:in_img_path = os.path.join(root, filename)out_img_path = os.path.join(save_path, filename)psam.load_image(in_img_path)panoptic_inds = psam.generate_panoptic_mask()psam.plt_draw_image(cn_style, font_style_path, out_img_path)print(panoptic_inds.shape) # panoptic_inds:单通道掩码图像

  

http://www.hskmm.com/?act=detail&tid=36243

相关文章:

  • C# Avalonia 16- Animation- SampleViewer - FollowExample
  • 五节课掌握 Python 面向对象(以“人狗大战”为例)
  • 联邦学习与AI公平性研究新进展
  • ESP32 Arduino核心框架:全面支持多款ESP32芯片的开发平台
  • 图像分割 3D-Box-Segment-Anything(5)如何加速 - MKT
  • 静态方法(`@staticmethod`)和类方法(`@classmethod`)的应用场景及选择原则
  • 数据集 - MKT
  • 专门针对无人机分割的预训练模型​ - MKT
  • 为什么一般教材在讲解python的多态概念时,不用抽象基类及其相关内容讲解呢?
  • [Bash] bash scripting common pitfalls
  • [Bash]让人头晕的if条件
  • 鸭子类型(Duck Typing)中的“类型”,指的是什么的类型?为什么很多人认为“Python 没有真正实现多态”?多态的核心目的是什么?鸭子类型如何实现多态?
  • tryhackme-预安全-windows基础-windows 基础知识1-16
  • YOLO11深度学习的遥感视角地面房屋建筑检测分割与分析系统 - MKT
  • 鸭子类型(Duck Typing)中的“类型”,指的是什么的类型?为什么很多人认为“Python 没有真正实现多态”
  • OAK-D-SR近红外相机 - MKT
  • 图像分割 Segment Anything(1-2)第二代 - MKT
  • 对比c++中的多态和python的多态
  • 结对项目-自动生成小学四则运算题目命令行程序
  • tryhackme-预安全-linux 基础-Linux 基础知识(第二部分)-14
  • tryhackme-预安全-linux 基础-Linux 基础知识(第一部分)-13
  • 我测试了七个主流后端框架的性能-结果让我重新思考了技术选型
  • tryhackme-预安全-网络如何工作-总结-12
  • 目标检测 Grounding DINO 用语言指定要检测的目标 - MKT
  • 图像分割 Segment Anything(3)分割2D到3D点云分割 rgb-d相机 - MKT
  • 图像分割 3D-Box-Segment-Anything(3)分割2D到3D点云分割 rgb相机 - MKT
  • 图像分割 Segment Anything(3)分割2D到3D点云分割 rgb相机 - MKT
  • Python 包管理工具推荐:uv
  • 3D框预测 VoxelNeXt - MKT
  • 【神器】如何查看api域名内容