Fetching metadata from the HF Docker repository...
-
Update app.py
-
Upload 7 files
-
Update app.py
-
Update app.py
-
Update sam_segment.py
-
Create sam_segment.py
-
Upload 2 files
-
Create requirements.txt
-
sam_segment.py
import gradio as gr
import cv2
import numpy as np
from sam_segment import segment_image_with_prompt
# 预定义分割颜色组
SEGMENT_COLORS = [
((255, 99, 71), (255, 99, 71)), # 红橙色
((65, 105, 225), (65, 105, 225)), # 皇家蓝
((50, 205, 50), (50, 205, 50)), # 酸橙绿
((255, 215, 0), (255, 215, 0)), # 金色
((238, 130, 238), (238, 130, 238)), # 紫罗兰
((0, 191, 255), (0, 191, 255)), # 深天蓝
((255, 165, 0), (255, 165, 0)), # 橙色
((106, 90, 205), (106, 90, 205)), # 石板蓝
]
def segment_image(input_image, model_size, conf_threshold, iou_threshold):
"""
使用FastSAM模型对输入图片进行分割
"""
try:
# 进行预测
results = segment_image_with_prompt(
image=input_image,
model_size=model_size,
conf=conf_threshold,
iou=iou_threshold,
)
# 创建输出图像的副本
output_image = input_image.copy()
# 获取图像尺寸
h, w = output_image.shape[:2]
# 创建一个总的遮罩层和一个累积掩码
fin… -
initial commit