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

相关推荐
新缸中之脑2 小时前
Paperless-NGX实战文档管理
人工智能
无极低码3 小时前
ecGlypher新手安装分步指南(标准化流程)
人工智能·算法·自然语言处理·大模型·rag
grant-ADAS3 小时前
记录paddlepaddleOCR从环境到使用默认模型,再训练自己的数据微调模型再推理
人工智能·深度学习
炎爆的土豆翔4 小时前
OpenCV 阈值二值化优化实战:LUT 并行、手写 AVX2 与 cv::threshold 性能对比
人工智能·opencv·计算机视觉
智能相对论4 小时前
从AWE看到海尔智慧家庭步步引领
人工智能
云和数据.ChenGuang4 小时前
魔搭社区 测试AI案例故障
人工智能·深度学习·机器学习·ai·mindstudio
小锋学长生活大爆炸4 小时前
【工具】无需Token!WebAI2API将网页AI转为API使用
人工智能·深度学习·chatgpt·openclaw
昨夜见军贴06164 小时前
AI审核赋能司法鉴定:IACheck如何保障刑事证据检测报告精准无误、经得起推敲?
人工智能
测试_AI_一辰4 小时前
AI系统到底怎么测?一套六层测试框架(Agent案例)
人工智能·功能测试·需求分析·ai编程
运维小欣4 小时前
智能体选型实战指南
运维·人工智能