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])

相关推荐
AcaDesign42 分钟前
国家/省部市级科技奖答辩PPT_科技进步奖_自然科学奖_技术发明奖|WordinPPT
大数据·人工智能·科技·powerpoint
Ai-_Man3 小时前
希望大家能推荐一款软件,可以直接把文心生成的代码变流程图,提高办公效率
人工智能·ai·小程序·流程图
AI02265 小时前
探秘AI Agent软件公司:开启智能时代的创新引擎
人工智能
fīɡЙtīиɡ ℡7 小时前
AI 应用系统设计
java·开发语言·人工智能
小淮AI7 小时前
国际教育课程的本土化探索:以枫叶教育三十年为观察样本
大数据·人工智能
又折桃枝换酒钱7 小时前
VisCoder2:构建多语言可视化编码智能体(翻译与解读)
人工智能·信息可视化
AI绘画哇哒哒7 小时前
【建议收藏!】35岁后端血泪忠告,这3类人别硬转Agent(过来人亲述)
java·人工智能·后端·ai·程序员·大模型·agent
Chengbei118 小时前
DSH渗透测试插件dsh-pentest全新升级!适配DeepSeek Harness,可视化探索链路,一键搭建轻量化AI渗透测试环境。
人工智能·web安全·网络安全·微信·小程序·系统安全·安全架构
QN1幻化引擎8 小时前
DalinX Phi 性能突破:跨层秩保持对齐与意识涌现度量的实证研究
人工智能·ai·架构·agi·asi