OpenCV: DNN超采样,性能差,只能整数

  • 说明及各模型下载

https://github.com/opencv/opencv_contrib/tree/master/modules/dnn_superres

  • 结论

时髦归时髦,我在虚拟机中测试,性能非常之差。

而且更可笑的是,必须是整数,这基本没有应用场景。

  • 代码

    import cv2
    from cv2 import dnn_superres
    import time

    def super_resolution(input_path, model_path, model_name, scale):
    # 初始化
    sr = dnn_superres.DnnSuperResImpl_create()
    print(model_path)
    # 读取模型
    sr.readModel(model_path)
    sr.setModel(model_name, scale)

    复制代码
      # 读取图像
      img = cv2.imread(input_path)
      if img is None:
          print("无法读取图像")
          return
      
      # 记录时间
      start_time = time.time()
      
      for index in range(count):
          # 超分辨率重建
          result = sr.upsample(img)
      
      print('%s cost time: %.2f ms' % (model_path, (time.time()-start_time)*1000/count))
      
      return result

    models=[
    ['EDSR_x2.pb', 2, 'edsr'],
    ['ESPCN_x2.pb', 2, 'espcn'],
    ['FSRCNN-small_x2.pb', 2, 'fsrcnn'],
    ['FSRCNN_x2.pb', 2, 'fsrcnn'],
    ['LapSRN_x2.pb', 2, 'lapsrn'],
    ['EDSR_x3.pb', 3, 'edsr'],
    ['ESPCN_x3.pb', 3, 'espcn'],
    ['FSRCNN-small_x3.pb', 3, 'fsrcnn'],
    ['FSRCNN_x3.pb', 3, 'fsrcnn'],
    ['LapSRN_x4.pb', 4, 'lapsrn'],
    ['EDSR_x4.pb', 4, 'edsr'],
    ['ESPCN_x4.pb', 4, 'espcn'],
    ['FSRCNN-small_x4.pb', 4, 'fsrcnn'],
    ['FSRCNN_x4.pb', 4, 'fsrcnn'],
    ['LapSRN_x8.pb', 8, 'lapsrn']
    ]

    test_file='lotus-300x300.jpg'
    test_file='lotus-600x600.jpg'

    count=10
    scale=2
    for model in models:
    super_resolution(
    test_file,
    "models/"+model[0],
    model[2],
    model[1])

相关推荐
林林宋1 小时前
speech/music/sing 分离
人工智能
赛希咨询1 小时前
生成式人工智能问答:在软件工程中的应用
人工智能·软件工程
siliconstorm.ai1 小时前
全球人形机器人产业现状与技术挑战:AI与云计算如何驱动下一波发展
人工智能
Fleshy数模2 小时前
Sklearn实战KNN:快速实现分类任务的入门指南
人工智能·分类·sklearn
犀思云2 小时前
出海SaaS全球分布式部署:流量调度的六大核心挑战与破局思考
运维·网络·人工智能·系统架构·机器人
老蒋每日coding2 小时前
AI Agent 设计模式系列(二十一)—— 探索和发现设计模式
人工智能·设计模式
格林威2 小时前
Baumer相机铁轨表面裂纹巡检:提升铁路安全监测能力的 7 个关键技术,附 OpenCV+Halcon 实战代码!
人工智能·数码相机·opencv·算法·安全·计算机视觉·分类
想你依然心痛2 小时前
AI 音效新征程:HunyuanVideo-Foley 视频配音实战
人工智能·音视频·智能电视
天天代码码天天2 小时前
lw.PPOCRSharp_GPU_Test paddle_inference v3.3
人工智能·深度学习·paddle