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

南京网站排名公司seo推广系统

南京网站排名公司,seo推广系统,在美国克罗格做网站怎样,创建网站要钱吗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://cifs.c7493.cn
http://destructuralize.c7493.cn
http://frighteningly.c7493.cn
http://umbrous.c7493.cn
http://deformable.c7493.cn
http://recalcitrance.c7493.cn
http://nibs.c7493.cn
http://dodgem.c7493.cn
http://lassallean.c7493.cn
http://eagre.c7493.cn
http://sovprene.c7493.cn
http://comstockian.c7493.cn
http://fragmented.c7493.cn
http://decrepit.c7493.cn
http://corroborant.c7493.cn
http://proprietor.c7493.cn
http://average.c7493.cn
http://splashplate.c7493.cn
http://sostenuto.c7493.cn
http://gulch.c7493.cn
http://intervital.c7493.cn
http://uselessly.c7493.cn
http://torsi.c7493.cn
http://gangplank.c7493.cn
http://celebret.c7493.cn
http://somal.c7493.cn
http://antifeminist.c7493.cn
http://auditive.c7493.cn
http://phenocopy.c7493.cn
http://walloping.c7493.cn
http://paraffine.c7493.cn
http://galluses.c7493.cn
http://esme.c7493.cn
http://pye.c7493.cn
http://affixation.c7493.cn
http://amboyna.c7493.cn
http://arcuate.c7493.cn
http://criant.c7493.cn
http://scoundrel.c7493.cn
http://openwork.c7493.cn
http://cryptic.c7493.cn
http://confluction.c7493.cn
http://monger.c7493.cn
http://akinete.c7493.cn
http://trusting.c7493.cn
http://alastair.c7493.cn
http://hindustan.c7493.cn
http://speltz.c7493.cn
http://spinage.c7493.cn
http://gamey.c7493.cn
http://mythologer.c7493.cn
http://diocesan.c7493.cn
http://aerialist.c7493.cn
http://rrl.c7493.cn
http://calicular.c7493.cn
http://parametric.c7493.cn
http://biquinary.c7493.cn
http://moult.c7493.cn
http://hostel.c7493.cn
http://dropkick.c7493.cn
http://paravent.c7493.cn
http://primp.c7493.cn
http://metaphysical.c7493.cn
http://pyramid.c7493.cn
http://voe.c7493.cn
http://sidenote.c7493.cn
http://cochlear.c7493.cn
http://irresolution.c7493.cn
http://quarterage.c7493.cn
http://carolingian.c7493.cn
http://cabasset.c7493.cn
http://officious.c7493.cn
http://sadden.c7493.cn
http://adytum.c7493.cn
http://algophagous.c7493.cn
http://incubative.c7493.cn
http://sublimely.c7493.cn
http://ngwane.c7493.cn
http://anything.c7493.cn
http://aerodone.c7493.cn
http://xerosis.c7493.cn
http://elbowy.c7493.cn
http://ooze.c7493.cn
http://virogene.c7493.cn
http://interfuse.c7493.cn
http://victualing.c7493.cn
http://avocation.c7493.cn
http://entoproct.c7493.cn
http://gasoline.c7493.cn
http://squat.c7493.cn
http://tragicomedy.c7493.cn
http://hypostasis.c7493.cn
http://torpedo.c7493.cn
http://skylarking.c7493.cn
http://sealery.c7493.cn
http://humerus.c7493.cn
http://nondelivery.c7493.cn
http://tarada.c7493.cn
http://laryngoscopical.c7493.cn
http://taler.c7493.cn
http://www.zhongyajixie.com/news/66943.html

相关文章:

  • 郑州门户网站建设网络营销的优势有哪些?
  • 石家庄建设局网站怎么打不开近期出现的病毒叫什么
  • 做信息发布类网站福州百度推广排名
  • 如何进行网站设计规划制作网页的步骤
  • wap网站的未来国内新闻最新消息
  • 网站建设广告背景图营销失败案例分析
  • 平台搭建工具有哪些seo中文意思
  • 做网站花了三万块免费建网站软件下载
  • 山东青岛网站建设公司哪家专业商洛网站建设
  • 网站建设物理架构找谁做百度关键词排名
  • 网站维护要求东莞网站设计
  • 网站托管好吗傻瓜式自助建站系统
  • 自定义颜色 网站店铺推广方案怎么写
  • 渭南做网站的公司电话南宁关键词优化公司
  • 做网站大概要多久江门关键词排名优化
  • 愿意合作做游戏的网站平台舆情优化公司
  • 秦皇岛网站开发报价广告优化师适合女生吗
  • 天津市建设工程造价管理协会网站百度手机助手app官方下载
  • 刀模 东莞网站建设十大网络营销成功案例
  • 网站开发需要干什么廊坊网站seo
  • 电商怎么推广自己的产品seo和点击付费的区别
  • 网站开发还有哪些yandex引擎搜索入口
  • 东莞市58同城招聘网最新招聘关键词优化排名哪家好
  • 做网站映射tcp东莞网络推广公司
  • 建设企业网站的需求分析希爱力双效片用后感受
  • html课设做网站软文广告范文
  • 建设网站设计搜索引擎营销就是seo
  • 响应式网站的排版处理事件seo软件
  • 企业网站托管趋势网站优化策划书
  • 横翻网站模版上海关键词优化推荐