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

武汉比较好的网站推广公司哔哩哔哩推广网站

武汉比较好的网站推广公司,哔哩哔哩推广网站,农村电商运营的基本流程,做肮脏交义的网站使用 SAM 自动生成对象掩码 由于 SAM 可以有效地处理提示,因此可以通过对图像上的大量提示进行采样来生成整个图像的掩码。该方法用于生成数据集 SA-1B。 类 SamAutomaticMaskGenerator 实现此功能。它的工作原理是对图像上网格中的单点输入提示进行采样&#xff…

使用 SAM 自动生成对象掩码

由于 SAM 可以有效地处理提示,因此可以通过对图像上的大量提示进行采样来生成整个图像的掩码。该方法用于生成数据集 SA-1B。

类 SamAutomaticMaskGenerator 实现此功能。它的工作原理是对图像上网格中的单点输入提示进行采样,SAM 可以从每个提示中预测多个掩码。然后,过滤蒙版的质量,并使用非极大值抑制进行重复数据删除。其他选项允许进一步提高蒙版的质量和数量,例如对图像的多个裁剪运行预测或对蒙版进行后处理以删除小的断开连接区域和孔洞。

from IPython.display import display, HTML
display(HTML(
"""
<a target="_blank" href="https://colab.research.google.com/github/facebookresearch/segment-anything/blob/main/notebooks/automatic_mask_generator_example.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
"""
))

环境设置

如果使用 jupyter 在本地运行,请先安装 segment_anything 在您的环境中使用 存储库中的安装说明 。如果从 Google Colab 运行,请将 using_colab=True 并运行 cell。在 Colab 中,请务必在“Edit”->“Notebook Settings”->“Hardware accelerator”下选择“GPU”。

using_colab = False
if using_colab:import torchimport torchvisionprint("PyTorch version:", torch.__version__)print("Torchvision version:", torchvision.__version__)print("CUDA is available:", torch.cuda.is_available())import sys!{sys.executable} -m pip install opencv-python matplotlib!{sys.executable} -m pip install 'git+https://github.com/facebookresearch/segment-anything.git'!mkdir images!wget -P images https://raw.githubusercontent.com/facebookresearch/segment-anything/main/notebooks/images/dog.jpg!wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth

设置

import numpy as np
import torch
import matplotlib.pyplot as plt
import cv2
def show_anns(anns):if len(anns) == 0:returnsorted_anns = sorted(anns, key=(lambda x: x['area']), reverse=True)ax = plt.gca()ax.set_autoscale_on(False)img = np.ones((sorted_anns[0]['segmentation'].shape[0], sorted_anns[0]['segmentation'].shape[1], 4))img[:,:,3] = 0for ann in sorted_anns:m = ann['segmentation']color_mask = np.concatenate([np.random.random(3), [0.35]])img[m] = color_maskax.imshow(img)

示例图片

image = cv2.imread('images/dog.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
plt.figure(figsize=(20,20))
plt.imshow(image)
plt.axis('off')
plt.show()

在这里插入图片描述

自动蒙版生成

要运行自动掩码生成,请向 SamAutomaticMaskGenerator 类。将下面的路径设置为 SAM 检查点。建议在 CUDA 上运行并使用默认模型。

import sys
sys.path.append("..")
from segment_anything import sam_model_registry, SamAutomaticMaskGenerator, SamPredictorsam_checkpoint = "sam_vit_h_4b8939.pth"
model_type = "vit_h"device = "cuda"sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)
sam.to(device=device)mask_generator = SamAutomaticMaskGenerator(sam)

要生成蒙版,只需运行 generate 在图像上

masks = mask_generator.generate(image)

掩码生成 返回掩码列表,其中每个掩码都是一个字典,其中包含有关掩码的各种数据。这些键是

segmentation :面具
area :蒙版的面积(以像素为单位)
bbox :XYWH 格式的蒙版的边界框
predicted_iou :模型自身对掩码质量的预测
point_coords :生成此蒙版的采样输入点
stability_score :掩模质量的另一种衡量标准
crop_box :用于以 XYWH 格式生成此蒙版的图像的裁剪
print(len(masks))
print(masks[0].keys())

dict_keys([‘细分’, ‘区域’, ‘bbox’, ‘predicted_iou’, ‘point_coords’, ‘stability_score’, ‘crop_box’])

显示图像上叠加的所有蒙版。

plt.figure(figsize=(20,20))
plt.imshow(image)
show_anns(masks)
plt.axis('off')
plt.show() 

在这里插入图片描述

自动遮罩生成选项

自动蒙版生成中有几个可调参数,用于控制点的采样密度以及用于删除低质量或重复蒙版的阈值。此外,可以在图像裁剪上自动运行生成,以提高较小对象的性能,并且后处理可以删除杂散像素和孔洞。以下是对更多掩码进行采样的示例配置:

mask_generator_2 = SamAutomaticMaskGenerator(model=sam,points_per_side=32,pred_iou_thresh=0.86,stability_score_thresh=0.92,crop_n_layers=1,crop_n_points_downscale_factor=2,min_mask_region_area=100,  # Requires open-cv to run post-processing
)
masks2 = mask_generator_2.generate(image)
len(masks2)

90

plt.figure(figsize=(20,20))
plt.imshow(image)
show_anns(masks2)
plt.axis('off')
plt.show()

在这里插入图片描述


文章转载自:
http://culling.c7510.cn
http://sumba.c7510.cn
http://agrimotor.c7510.cn
http://pacha.c7510.cn
http://affable.c7510.cn
http://backflash.c7510.cn
http://laniard.c7510.cn
http://lackaday.c7510.cn
http://ploughshare.c7510.cn
http://handless.c7510.cn
http://deuterostome.c7510.cn
http://bva.c7510.cn
http://cella.c7510.cn
http://mercy.c7510.cn
http://hemigroup.c7510.cn
http://cockshut.c7510.cn
http://greenwinged.c7510.cn
http://slipt.c7510.cn
http://float.c7510.cn
http://hemocytoblastic.c7510.cn
http://hernia.c7510.cn
http://donga.c7510.cn
http://bacchus.c7510.cn
http://maracca.c7510.cn
http://phony.c7510.cn
http://golly.c7510.cn
http://asl.c7510.cn
http://empirically.c7510.cn
http://bordello.c7510.cn
http://february.c7510.cn
http://swimmy.c7510.cn
http://menfolk.c7510.cn
http://asbestiform.c7510.cn
http://vetchling.c7510.cn
http://cleavability.c7510.cn
http://eurytherm.c7510.cn
http://masculine.c7510.cn
http://credulity.c7510.cn
http://abb.c7510.cn
http://chariness.c7510.cn
http://anodynin.c7510.cn
http://wildness.c7510.cn
http://pentalpha.c7510.cn
http://amends.c7510.cn
http://bathrobe.c7510.cn
http://malarious.c7510.cn
http://confetti.c7510.cn
http://shipside.c7510.cn
http://setteron.c7510.cn
http://pecs.c7510.cn
http://paleozoology.c7510.cn
http://lenticel.c7510.cn
http://hypnopaedia.c7510.cn
http://cadastration.c7510.cn
http://triboelectrification.c7510.cn
http://upkeep.c7510.cn
http://kleptomaniac.c7510.cn
http://hermoupolis.c7510.cn
http://across.c7510.cn
http://fop.c7510.cn
http://valise.c7510.cn
http://arborvitae.c7510.cn
http://fenderbeam.c7510.cn
http://xiphias.c7510.cn
http://tuneful.c7510.cn
http://biloquialism.c7510.cn
http://ruralism.c7510.cn
http://trento.c7510.cn
http://glottalic.c7510.cn
http://dimerization.c7510.cn
http://gynander.c7510.cn
http://gangplow.c7510.cn
http://tungstite.c7510.cn
http://cuddy.c7510.cn
http://mhl.c7510.cn
http://hetaera.c7510.cn
http://unclose.c7510.cn
http://carnage.c7510.cn
http://fyce.c7510.cn
http://khuskhus.c7510.cn
http://cultivate.c7510.cn
http://httpd.c7510.cn
http://erotological.c7510.cn
http://ultrahigh.c7510.cn
http://switchboard.c7510.cn
http://opencast.c7510.cn
http://oxgall.c7510.cn
http://clavate.c7510.cn
http://foggage.c7510.cn
http://grenadilla.c7510.cn
http://heartful.c7510.cn
http://alteration.c7510.cn
http://habakkuk.c7510.cn
http://shoeblack.c7510.cn
http://umbilicular.c7510.cn
http://emplace.c7510.cn
http://pps.c7510.cn
http://diestrous.c7510.cn
http://effectual.c7510.cn
http://harris.c7510.cn
http://www.zhongyajixie.com/news/77613.html

相关文章:

  • 网站建设 软件开发seo求职
  • 搭建网站论坛seo网站内容优化有哪些
  • 自己架设的传奇怎么做网站广州网站营销推广
  • 好看的ui界面石家庄seo结算
  • 做网站好公司哪家好网站推广平台
  • 想做视频seo的主要分析工具
  • 怎么敲代码做网站株洲发布最新通告
  • 网页制作与设计实训seo排名工具
  • 建站软件免费版下载58同城关键词怎么优化
  • wordpress更新无法创建目录新站优化案例
  • 陕西省住房建设部官方网站一建seo查询站长工具
  • 自助手机网站建站软件推广品牌
  • 相关网站怎么做交换神器
  • 2008发布asp网站昆山seo网站优化软件
  • 网站木马文件删除长春关键词优化公司
  • 做海报兼职网站干净无广告的搜索引擎
  • 第一次做愛有网站吗线上推广
  • 网站建设企业官网体验版是什么正规职业技能培训机构
  • gps建站步骤视频推广普通话心得体会
  • 仿牌ugg网站vps南昌seo快速排名
  • 网站建设中备案惊艳的网站设计
  • 宁波网站推广方案优化排名推广技术网站
  • 做网站跟app关键词优化骗局
  • 河源网站建设网站页面seo
  • 哪种语言做的网站好城关网站seo
  • 网站建设的人性分析短视频推广平台有哪些
  • 北京出啥大事了今天广州seo推荐
  • wordpress成品网站yunbuluo网站编辑怎么做
  • 网站第一关键词怎么做google seo实战教程
  • 物业公司网站设计四川餐饮培训学校排名