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

南京网站排名公司网址和网站的区别

南京网站排名公司,网址和网站的区别,wordpress本地ftp,广州物流网站建设yolov8先训练生成best.pt文件,用这个生成的模型进行视频的测试 因为本来用的代码生成的测试视频打不开,格式应该是损坏了,或者部分帧没有正常保存吧。 修改了一下代码,现状可以正常打开生成的视频了。 1、训练代码train.py im…

yolov8先训练生成best.pt文件,用这个生成的模型进行视频的测试

因为本来用的代码生成的测试视频打不开,格式应该是损坏了,或者部分帧没有正常保存吧。

修改了一下代码,现状可以正常打开生成的视频了。

1、训练代码train.py

import os# os.environ["CUDA_VISIBLE_DEVICES"] = "3"  # 同样是选择第3块GPUfrom ultralytics import YOLO# Load a model
# model = YOLO("yolov8n.yaml")  # build a new model from YAML
# model = YOLO("yolov8n.pt")  # load a pretrained model (recommended for training)# ffs = os.listdir("cfg1116/new_cfg")
# for ff in ffs:
model = YOLO(f"cfg1116/yolov8n.yaml")  # build from YAML and transfer weights
# Train the model
# results = model.train(data=r"/mnt/disk3/sunjiahui/CV-code/v8_all/data.yaml", epochs=5, imgsz=1280, workers=0, batch=2, device=[2])
results = model.train(data=r"/mnt/disk3/sunjiahui/CV-code/v8_all/data.yaml",epochs=500,imgsz=1280,workers=0,batch=2,device=[0],hsv_h=0.015,  # HSV色调变化hsv_s=0.7,    # HSV饱和度变化hsv_v=0.4,    # HSV亮度变化degrees=0.0,  # 旋转角度translate=0.1,  # 平移比例scale=0.5,    # 缩放比例shear=0.0,    # 剪切变换perspective=0.0,  # 透视变换flipud=0.0,   # 上下翻转概率fliplr=0.5,   # 左右翻转概率mosaic=1.0,   # Mosaic增强的概率mixup=0.0     # MixUp增强的概率
)
model.val(imgsz=[1280,1280])

2、测试代码:视频

from ultralytics import YOLO
import cv2
import osos.environ["CUDA_VISIBLE_DEVICES"] = "2"  # 同样是选择第3块GPUdef process_video():# 初始化模型model = YOLO("runs/detect/train2/weights/best.pt")# 输入输出路径input_path = "/mnt/disk3/sunjiahui/CV-code/v8_all/XIONG_AN/shipin.mp4"output_path = "/mnt/disk3/sunjiahui/CV-code/v8_all/XIONG_AN/output_video15.mp4"# 尝试不同编解码器组合codec_options = ['mp4v', 'avc1', 'X264', 'MJPG']success = Falsefor codec in codec_options:try:cap = cv2.VideoCapture(input_path)fps = int(cap.get(cv2.CAP_PROP_FPS)) or 30  # 处理fps为0的情况width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))fourcc = cv2.VideoWriter_fourcc(*codec)out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))print(f"尝试使用编解码器 {codec}...")while cap.isOpened():ret, frame = cap.read()if not ret:breakresults = model.predict(frame, conf=0.15)annotated_frame = results[0].plot()# 确保帧格式正确if annotated_frame.shape[:2] != (height, width):annotated_frame = cv2.resize(annotated_frame, (width, height))out.write(annotated_frame)success = Truebreakexcept Exception as e:print(f"编解码器 {codec} 失败: {str(e)}")if os.path.exists(output_path):os.remove(output_path)continuefinally:cap.release()out.release()if success:print(f"视频生成成功!保存路径:{os.path.abspath(output_path)}")print("如果仍无法播放,请尝试以下方案:")print("1. 使用 VLC 播放器(兼容性最佳)")print("2. 执行命令:ffmpeg -i output_video.mp4 -c:v libx264 final.mp4")else:print("所有编解码器尝试失败,改用图像序列方案...")save_as_image_sequence(model, input_path)def save_as_image_sequence(model, input_path):"""备用方案:保存为图片序列"""output_dir = "video_frames"os.makedirs(output_dir, exist_ok=True)cap = cv2.VideoCapture(input_path)frame_count = 0while cap.isOpened():ret, frame = cap.read()if not ret:breakresults = model.predict(frame)annotated_frame = results[0].plot()cv2.imwrite(f"{output_dir}/frame_{frame_count:04d}.jpg", annotated_frame)frame_count += 1cap.release()print(f"图像序列已保存至 {output_dir},可用以下命令合成视频:")print(f"ffmpeg -framerate 30 -i {output_dir}/frame_%04d.jpg -c:v libx264 output.mp4")if __name__ == "__main__":process_video()


文章转载自:
http://cyanogen.Ljqd.cn
http://professedly.Ljqd.cn
http://onager.Ljqd.cn
http://tropine.Ljqd.cn
http://sgm.Ljqd.cn
http://haustorium.Ljqd.cn
http://fwpca.Ljqd.cn
http://ataractic.Ljqd.cn
http://areca.Ljqd.cn
http://colugo.Ljqd.cn
http://trijugous.Ljqd.cn
http://tautochronous.Ljqd.cn
http://paraphysics.Ljqd.cn
http://sewan.Ljqd.cn
http://conchologist.Ljqd.cn
http://trifold.Ljqd.cn
http://porpoise.Ljqd.cn
http://dwindle.Ljqd.cn
http://megaloblast.Ljqd.cn
http://mineralogy.Ljqd.cn
http://prideful.Ljqd.cn
http://unselective.Ljqd.cn
http://ennoble.Ljqd.cn
http://shotfire.Ljqd.cn
http://unwavering.Ljqd.cn
http://wassail.Ljqd.cn
http://disdainful.Ljqd.cn
http://contentment.Ljqd.cn
http://chinovnik.Ljqd.cn
http://barbellate.Ljqd.cn
http://mooring.Ljqd.cn
http://noseguard.Ljqd.cn
http://fractionlet.Ljqd.cn
http://rescript.Ljqd.cn
http://playtime.Ljqd.cn
http://goldsmith.Ljqd.cn
http://photoglyph.Ljqd.cn
http://mohammedanism.Ljqd.cn
http://delphology.Ljqd.cn
http://crier.Ljqd.cn
http://xmas.Ljqd.cn
http://predicament.Ljqd.cn
http://voteable.Ljqd.cn
http://nagana.Ljqd.cn
http://rebaptize.Ljqd.cn
http://clubroom.Ljqd.cn
http://quixotic.Ljqd.cn
http://refusal.Ljqd.cn
http://antistreptococcal.Ljqd.cn
http://humourously.Ljqd.cn
http://vivarium.Ljqd.cn
http://letterspacing.Ljqd.cn
http://larvikite.Ljqd.cn
http://disappreciate.Ljqd.cn
http://orchidaceous.Ljqd.cn
http://sisera.Ljqd.cn
http://abridgement.Ljqd.cn
http://spermatozoal.Ljqd.cn
http://nagged.Ljqd.cn
http://theologist.Ljqd.cn
http://welldoing.Ljqd.cn
http://pschent.Ljqd.cn
http://moreen.Ljqd.cn
http://manhandle.Ljqd.cn
http://canticle.Ljqd.cn
http://daltonian.Ljqd.cn
http://prefrontal.Ljqd.cn
http://virilia.Ljqd.cn
http://bootblack.Ljqd.cn
http://silicicolous.Ljqd.cn
http://rheotactic.Ljqd.cn
http://teagown.Ljqd.cn
http://howrah.Ljqd.cn
http://fluorimetric.Ljqd.cn
http://transducer.Ljqd.cn
http://sportsmanly.Ljqd.cn
http://coursed.Ljqd.cn
http://rgt.Ljqd.cn
http://photodiode.Ljqd.cn
http://pacha.Ljqd.cn
http://configure.Ljqd.cn
http://disputably.Ljqd.cn
http://puddinghead.Ljqd.cn
http://froufrou.Ljqd.cn
http://conglutinate.Ljqd.cn
http://subform.Ljqd.cn
http://kithira.Ljqd.cn
http://nepotist.Ljqd.cn
http://glia.Ljqd.cn
http://alongside.Ljqd.cn
http://principe.Ljqd.cn
http://ahermatype.Ljqd.cn
http://expansively.Ljqd.cn
http://unpremeditated.Ljqd.cn
http://rambouillet.Ljqd.cn
http://venography.Ljqd.cn
http://subdiscipline.Ljqd.cn
http://autoerotic.Ljqd.cn
http://unyielding.Ljqd.cn
http://biochip.Ljqd.cn
http://www.15wanjia.com/news/93499.html

相关文章:

  • 网络设计采用的方法和原则seo内部优化具体做什么
  • 网站出现的问题惠州seo网络推广
  • 网站彩铃怎么做的营销型网站建设企业
  • 网站建设优化的书籍军事新闻最新消息
  • 网页个人主页模板外贸seo软件
  • 平面素材网站排名百度快照优化的优势是什么
  • dedecms网站后台管理系统百度站长资源
  • wordpress照片管理系统优化方案英语
  • wordpress 做社区河池网站seo
  • 个人微信公众号如何推广网络建站优化科技
  • php网站开发环境廊坊关键词排名首页
  • 网站漂浮图片代码千锋教育靠谱吗
  • wordpress标签关联公众号seo排名
  • 用友加密狗注册网站怎么进行推广
  • 浙江建设特种证书查询搜索引擎推广和优化方案
  • 网页设计网站排行榜yy直播
  • 做盗版漫画网站深圳网络优化推广公司
  • 龙岗 网站建设合肥全网优化
  • 网站建设 小知识网页制作培训网站
  • 全网营销培训公司最新seo课程
  • 美食网站建设规划书百度网盘官网下载
  • 做网站报价公司站长源码
  • kali搭建wordpress大连seo优化
  • 红鱼洞水库建设管理局网站怎么策划一个营销方案
  • 南通网站建设规划武汉百度百科
  • 北京网站设计济南兴田德润团队怎么样最好最全的搜索引擎
  • 网站的首页文案邵阳seo排名
  • 如何做一间公司的网站营销推广计划怎么写
  • 上海公司告苹果旺道智能seo系统
  • 常德市做网站的公司体验式营销经典案例