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 小时前
春节复工福利就位!天翼云息壤2500万Tokens免费送,全品类大模型一键畅玩!
人工智能·算力服务·息壤
知识浅谈1 小时前
教你如何用 Gemini 将课本图片一键转为精美 PPT
人工智能
Ray Liang2 小时前
被低估的量化版模型,小身材也能干大事
人工智能·ai·ai助手·mindx
shengjk13 小时前
NanoClaw 深度剖析:一个"AI 原生"架构的个人助手是如何运转的?
人工智能
西门老铁5 小时前
🦞OpenClaw 让 MacMini 脱销了,而我拿出了6年陈的安卓机
人工智能
恋猫de小郭6 小时前
AI 可以让 WIFI 实现监控室内人体位置和姿态,无需摄像头?
前端·人工智能·ai编程
是一碗螺丝粉6 小时前
5分钟上手LangChain.js:用DeepSeek给你的App加上AI能力
前端·人工智能·langchain
两万五千个小时6 小时前
落地实现 Anthropic Multi-Agent Research System
人工智能·python·架构
用户4815930195916 小时前
揭秘GPT-4与LLaMA背后的加速黑科技:KV Cache、MQA、GQA、稀疏注意力与MoE全解析
人工智能