房地产新闻最新消息今天/潍坊seo推广

房地产新闻最新消息今天,潍坊seo推广,b2b商场网站建设,上海的网站开发公司电话1. 在图像中裁剪人脸区域 import face_alignment import skimage.io import numpy from argparse import ArgumentParser from skimage import img_as_ubyte from skimage.transform import resize from tqdm import tqdm import os import numpy as np import warnings warni…

1. 在图像中裁剪人脸区域

import face_alignment
import skimage.io
import numpy
from argparse import ArgumentParser
from skimage import img_as_ubyte
from skimage.transform import resize
from tqdm import tqdm
import os
import numpy as np
import warnings
warnings.filterwarnings("ignore")# =================================================================================================
# Kun(20250306): 输出裁剪图像的命令
# =================================================================================================def extract_bbox(frame, fa):if max(frame.shape[0], frame.shape[1]) > 640:scale_factor =  max(frame.shape[0], frame.shape[1]) / 640.0frame = resize(frame, (int(frame.shape[0] / scale_factor), int(frame.shape[1] / scale_factor)))frame = img_as_ubyte(frame)else:scale_factor = 1frame = frame[..., :3]bboxes = fa.face_detector.detect_from_image(frame[..., ::-1])if len(bboxes) == 0:return []return np.array(bboxes)[:, :-1] * scale_factordef bb_intersection_over_union(boxA, boxB):xA = max(boxA[0], boxB[0])yA = max(boxA[1], boxB[1])xB = min(boxA[2], boxB[2])yB = min(boxA[3], boxB[3])interArea = max(0, xB - xA + 1) * max(0, yB - yA + 1)boxAArea = (boxA[2] - boxA[0] + 1) * (boxA[3] - boxA[1] + 1)boxBArea = (boxB[2] - boxB[0] + 1) * (boxB[3] - boxB[1] + 1)iou = interArea / float(boxAArea + boxBArea - interArea)return ioudef join(tube_bbox, bbox):xA = min(tube_bbox[0], bbox[0])yA = min(tube_bbox[1], bbox[1])xB = max(tube_bbox[2], bbox[2])yB = max(tube_bbox[3], bbox[3])return (xA, yA, xB, yB)def compute_bbox(tube_bbox, frame_shape, inp, image_shape, increase_area=0.1):left, top, right, bot = tube_bboxwidth = right - leftheight = bot - top#Computing aspect preserving bboxwidth_increase = max(increase_area, ((1 + 2 * increase_area) * height - width) / (2 * width))height_increase = max(increase_area, ((1 + 2 * increase_area) * width - height) / (2 * height))left = int(left - width_increase * width)top = int(top - height_increase * height)right = int(right + width_increase * width)bot = int(bot + height_increase * height)top, bot, left, right = max(0, top), min(bot, frame_shape[0]), max(0, left), min(right, frame_shape[1])h, w = bot - top, right - leftscale = f'{image_shape[0]}:{image_shape[1]}'return f'ffmpeg -i {inp} -filter:v "crop={w}:{h}:{left}:{top}, scale={scale}" crop.png'def process_image(args):device = 'cpu' if args.cpu else 'cuda'fa = face_alignment.FaceAlignment(face_alignment.LandmarksType.TWO_D, flip_input=False, device=device)frame = skimage.io.imread(args.inp)frame_shape = frame.shapebboxes = extract_bbox(frame, fa)if len(bboxes) == 0:print("No faces detected.")return []tube_bbox = bboxes[0]  # Assuming we take the first detected facecommand = compute_bbox(tube_bbox, frame_shape, inp=args.inp, image_shape=args.image_shape, increase_area=args.increase)return [command]if __name__ == "__main__":parser = ArgumentParser()parser.add_argument("--image_shape", default=(256, 256), type=lambda x: tuple(map(int, x.split(','))),help="Image shape")parser.add_argument("--increase", default=0.1, type=float, help='Increase bbox by this amount')parser.add_argument("--iou_with_initial", type=float, default=0.25, help="The minimal allowed iou with inital bbox")parser.add_argument("--inp", required=True, help='Input image')parser.add_argument("--cpu", dest="cpu", action="store_true", help="cpu mode.")args = parser.parse_args()commands = process_image(args)for command in commands:print(command)

2. 在视频中裁剪人脸区域

import face_alignment
import skimage.io
import numpy
from argparse import ArgumentParser
from skimage import img_as_ubyte
from skimage.transform import resize
from tqdm import tqdm
import os
import imageio
import numpy as np
import warnings
warnings.filterwarnings("ignore")# =================================================================================================
# Kun(20250306): 输出裁剪视频的命令
# =================================================================================================def extract_bbox(frame, fa):if max(frame.shape[0], frame.shape[1]) > 640:scale_factor =  max(frame.shape[0], frame.shape[1]) / 640.0frame = resize(frame, (int(frame.shape[0] / scale_factor), int(frame.shape[1] / scale_factor)))frame = img_as_ubyte(frame)else:scale_factor = 1frame = frame[..., :3]bboxes = fa.face_detector.detect_from_image(frame[..., ::-1])if len(bboxes) == 0:return []return np.array(bboxes)[:, :-1] * scale_factordef bb_intersection_over_union(boxA, boxB):xA = max(boxA[0], boxB[0])yA = max(boxA[1], boxB[1])xB = min(boxA[2], boxB[2])yB = min(boxA[3], boxB[3])interArea = max(0, xB - xA + 1) * max(0, yB - yA + 1)boxAArea = (boxA[2] - boxA[0] + 1) * (boxA[3] - boxA[1] + 1)boxBArea = (boxB[2] - boxB[0] + 1) * (boxB[3] - boxB[1] + 1)iou = interArea / float(boxAArea + boxBArea - interArea)return ioudef join(tube_bbox, bbox):xA = min(tube_bbox[0], bbox[0])yA = min(tube_bbox[1], bbox[1])xB = max(tube_bbox[2], bbox[2])yB = max(tube_bbox[3], bbox[3])return (xA, yA, xB, yB)def compute_bbox(start, end, fps, tube_bbox, frame_shape, inp, image_shape, increase_area=0.1):left, top, right, bot = tube_bboxwidth = right - leftheight = bot - top#Computing aspect preserving bboxwidth_increase = max(increase_area, ((1 + 2 * increase_area) * height - width) / (2 * width))height_increase = max(increase_area, ((1 + 2 * increase_area) * width - height) / (2 * height))left = int(left - width_increase * width)top = int(top - height_increase * height)right = int(right + width_increase * width)bot = int(bot + height_increase * height)top, bot, left, right = max(0, top), min(bot, frame_shape[0]), max(0, left), min(right, frame_shape[1])h, w = bot - top, right - leftstart = start / fpsend = end / fpstime = end - startscale = f'{image_shape[0]}:{image_shape[1]}'return f'ffmpeg -i {inp} -ss {start} -t {time} -filter:v "crop={w}:{h}:{left}:{top}, scale={scale}" crop.mp4'def compute_bbox_trajectories(trajectories, fps, frame_shape, args):commands = []for i, (bbox, tube_bbox, start, end) in enumerate(trajectories):if (end - start) > args.min_frames:command = compute_bbox(start, end, fps, tube_bbox, frame_shape, inp=args.inp, image_shape=args.image_shape, increase_area=args.increase)commands.append(command)return commandsdef process_video(args):device = 'cpu' if args.cpu else 'cuda'fa = face_alignment.FaceAlignment(face_alignment.LandmarksType.TWO_D, flip_input=False, device=device)video = imageio.get_reader(args.inp)trajectories = []previous_frame = Nonefps = video.get_meta_data()['fps']commands = []try:for i, frame in tqdm(enumerate(video)):frame_shape = frame.shapebboxes =  extract_bbox(frame, fa)## For each trajectory check the criterionnot_valid_trajectories = []valid_trajectories = []for trajectory in trajectories:tube_bbox = trajectory[0]intersection = 0for bbox in bboxes:intersection = max(intersection, bb_intersection_over_union(tube_bbox, bbox))if intersection > args.iou_with_initial:valid_trajectories.append(trajectory)else:not_valid_trajectories.append(trajectory)commands += compute_bbox_trajectories(not_valid_trajectories, fps, frame_shape, args)trajectories = valid_trajectories## Assign bbox to trajectories, create new trajectoriesfor bbox in bboxes:intersection = 0current_trajectory = Nonefor trajectory in trajectories:tube_bbox = trajectory[0]current_intersection = bb_intersection_over_union(tube_bbox, bbox)if intersection < current_intersection and current_intersection > args.iou_with_initial:intersection = bb_intersection_over_union(tube_bbox, bbox)current_trajectory = trajectory## Create new trajectoryif current_trajectory is None:trajectories.append([bbox, bbox, i, i])else:current_trajectory[3] = icurrent_trajectory[1] = join(current_trajectory[1], bbox)except IndexError as e:raise (e)commands += compute_bbox_trajectories(trajectories, fps, frame_shape, args)return commandsif __name__ == "__main__":parser = ArgumentParser()parser.add_argument("--image_shape", default=(256, 256), type=lambda x: tuple(map(int, x.split(','))),help="Image shape")parser.add_argument("--increase", default=0.1, type=float, help='Increase bbox by this amount')parser.add_argument("--iou_with_initial", type=float, default=0.25, help="The minimal allowed iou with inital bbox")parser.add_argument("--inp", required=True, help='Input image or video')parser.add_argument("--min_frames", type=int, default=150,  help='Minimum number of frames')parser.add_argument("--cpu", dest="cpu", action="store_true", help="cpu mode.")args = parser.parse_args()commands = process_video(args)for command in commands:print (command)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/898316.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【软考-架构】11.3、设计模式-新

✨资料&文章更新✨ GitHub地址&#xff1a;https://github.com/tyronczt/system_architect 文章目录 项目中的应用设计模式创建型设计模式结构型设计模式行为型设计模式 &#x1f4af;考试真题题外话 项目中的应用 在实际项目中&#xff0c;我应用过多种设计模式来解决不同…

Linux的Shell编程

一、什么是Shell 1、为什么要学习Shell Linux运维工程师在进行服务器集群管理时&#xff0c;需要编写Shell程序来进行服务器管理。 对于JavaEE和Python程序员来说&#xff0c;工作的需要。Boss会要求你编写一些Shell脚本进行程序或者是服务器的维护&#xff0c;比如编写一个…

论文阅读笔记:Deep Unsupervised Learning using Nonequilibrium Thermodynamics

1、来源 论文连接1&#xff1a;http://ganguli-gang.stanford.edu/pdf/DeepUnsupDiffusion.pdf 论文连接2(带appendix)&#xff1a;https://arxiv.org/pdf/1503.03585v7 代码链接&#xff1a;https://github.com/Sohl-Dickstein/Diffusion-Probabilistic-Models 代码的环境配置…

Linux 查看及测试网络命令

使用 ifconfig 命令查看网络接口地址 查看指定的网络接口信息 执行 ifconfig ens33 命令可以只查看网卡 ens33 的配置信息

ABAP语言的动态编程(4) - 综合案例:管理费用明细表

本篇来实现一个综合案例&#xff1a;管理费用明细表。报表在实际项目中&#xff0c;也有一定的参考意义&#xff0c;一方面展示类似的报表&#xff0c;比如管理费用、研发费用等费用的明细&#xff0c;使用业务比较习惯的展示格式&#xff1b;另一方面正好综合运用前面学习的动…

【Redis】Redis的数据删除(过期)策略,数据淘汰策略。

如果问到&#xff1a;假如Redis的key过期之后&#xff0c;会立即删除吗&#xff1f; 其实就是想问数据删除(过期)策略。 如果面试官问到&#xff1a;如果缓存过多&#xff0c;内存是有限的&#xff0c;内存被占满了怎么办&#xff1f; 其实就是问&#xff1a;数据的淘汰策略。…

Linux配置yum仓库,服务控制,防火墙

一、yum仓库 1.在安装软件时&#xff0c;首先第一步就是要考虑软件的版本的问题&#xff01; 2.软件的安装&#xff1a;最安全可靠的方法就是去软件对应的官网上查看安装手册&#xff08;包括的软件的下载&#xff09; 红帽系软件安装的常见的3种方式 &#xff08;1&#x…

设计模式(创建型)-抽象工厂模式

摘要 在软件开发的复杂世界中,设计模式作为解决常见问题的最佳实践方案,一直扮演着至关重要的角色。抽象工厂模式,作为一种强大的创建型设计模式,在处理创建一系列或相关依赖对象的场景时,展现出了独特的优势和灵活性。它通过提供一个创建对象的接口,让开发者能够在不指定…

【JavaEE】-- SpringBoot快速上手

文章目录 1. Maven1.1 什么是Maven1.2 为什么要学Maven1.3 创建一个Maven项目1.4 Maven核心功能1.4.1 项目创建1.4.2 依赖管理1.4.3 Maven Help插件 1.5 Maven仓库1.5.1 本地仓库1.5.2 中央仓库1.5.3 私有服务器&#xff08;私服&#xff09; 1.6 Maven设置国内源1.6.1 配置当前…

TCP/IP 协议精讲-精华总结版本

序言 本文旨在介绍一下TCP/IP涉及得所有基础知识&#xff0c;为大家从宏观上俯瞰TCP/IP提供一个基石&#xff0c;文档属于《TCP/IP图解&#xff08;第五版&#xff09;》的精简版本。 专业术语 缩写 全称 WAN Wide area network广域网 LAN Local area network局域网 TC…

C语言——结构体、联合、枚举

C语言中自定义类型 结构体结构体变量的创建和初始化结构体传参结构体内存对齐(如何存储) 联合体(共用体)联合体创建和初始化联合体大小(如何存储) 枚举类型枚举类型创建枚举类型初始化枚举的优点(相较于define) 前言 C语言中有内置类型和自定义类型&#xff0c;内置类型就像int…

【Linux操作系统——学习笔记二】Linux简单导航命令操作

一、前言 学习Linux&#xff0c;本质上是学习在命令行下熟练使用Linux的各类命令。 命令行&#xff1a;是一种通过输入命令和参数与计算机系统进行交互的方式&#xff0c;可以使用各种字符化命令对系统发出操作指令&#xff0c;打开Linux终端&#xff0c;进入命令行界面。 …

新安装的cursor安装不了插件

我安装的cursor版本0.47.5 直接说解决办法 找到安装路径cursor\resources\app下的product.json 修改https://marketplace.cursorapi.com为https://marketplace.visualstudio.com

HTML5扫雷游戏开发实战

HTML5扫雷游戏开发实战 这里写目录标题 HTML5扫雷游戏开发实战项目介绍技术栈项目架构1. 游戏界面设计2. 核心类设计 核心功能实现1. 游戏初始化2. 地雷布置算法3. 数字计算逻辑4. 扫雷功能实现 性能优化1. DOM操作优化2. 算法优化 项目亮点技术难点突破1. 首次点击保护2. 连锁…

Qt之自定义界面组件 一

通过qt中的painter绘图事件绘制一个电池电量图的变化。效果如下图 创建一个基于界面widget工程&#xff0c;在wdiget界面添加一个widget界面,将添加的widget界面的类提升为Tbattery.在Tbattery类中重写painEvent电池电量代码 文件目录结构 主要部分代码 //Tbattery.cpp #inc…

LeRobot源码剖析——对机器人各个动作策略的统一封装:包含ALOHA ACT、Diffusion Policy、VLA模型π0

前言 过去2年多的深入超过此前7年&#xff0c;全靠夜以继日的勤奋&#xff0c;一天当两天用&#xff0c;抠论文 抠代码 和大模型及具身同事讨论&#xff0c;是目前日常 而具身库里&#xff0c;idp3、π0、lerobot值得反复研究&#xff0c;故&#xff0c;近期我一直在抠π0及l…

数据结构篇——线索二叉树

一、引入 遍历二叉树是按一定规则将二叉树结点排成线性序列&#xff0c;得到先序、中序或后序序列&#xff0c;本质是对非线性结构线性化&#xff0c;使结点&#xff08;除首尾&#xff09;在线性序列中有唯一前驱和后继&#xff1b;但以二叉链表作存储结构时&#xff0c;只能获…

汽车保养记录用什么软件记录,汽车维修记录查询系统,佳易王汽车保养维护服务记录查询管理系统操作教程

一、概述 本实例以佳易王汽车保养维护服务记录查询管理系统为例说明&#xff0c;其他版本可参考本实例。试用版软件资源可到文章最后了解&#xff0c;下载的文件为压缩包文件&#xff0c;请使用免费版的解压工具解压即可试用。 软件特点&#xff1a;1、功能实用&#xff0c;操…

Python IP解析器 ip2region使用

说明&#xff1a;最近需要在python项目内使用IP定位所在城市的需求&#xff0c;没有采用向外部ISP服务商API请求获取信息的方案&#xff0c;则翻了翻&#xff0c;在搞Java时很多的方案&#xff0c;在Python端反而可选择范围很小。 # 示例查询 ips ["106.38.188.214"…

python开发订单查询功能(flask+orm bee)

1. 搭建python环境。 可以参考其它文档。 此处python使用 3.12 IDE随意&#xff0c;PyCharm 或 Eclipse PyDev也可以。 2. Flask 2.1 安装Flask pip install Flask 2.2 一个最简单的flask实例 创建一个工程&#xff0c; 新建一个 main.py文件&#xff0c; 输入以下内容…