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

相关推荐
笨鸟先飞,勤能补拙12 分钟前
AI 赋能网络安全:技术全景、成熟度评估与实战案例
人工智能·python·安全·web安全·网络安全·sqlite·github
2601_9637491030 分钟前
标题:越华环保集团|面向美丽河湖项目的数字化污水治理云边协同采集架构设计
人工智能
沐籽李31 分钟前
从溶剂可及表面积SASA理解抗体结构与工程改造
人工智能·药物设计·aidd·sasa
智慧物业老杨35 分钟前
物业如何做好预算管理?落地架构逻辑
人工智能·架构
微学AI38 分钟前
一根针指向所有方向:挂谷猜想对 LLM Agent 技能-记忆架构的启示
开发语言·人工智能·架构·挂谷猜想
城管不管42 分钟前
ReAct、Plan-and-Execute、Reflection 三大智能 Agent 范式核心区别
java·人工智能·算法·spring·ai·动态规划
boppu1 小时前
布草特殊污渍去渍剂的种类及作用
大数据·人工智能
AIsoft_86881 小时前
会议录音转文字与AI纪要工具推荐:免费额度与核心功能对比指南
人工智能
sphw1 小时前
nixnb: Jupyter Notebook 优雅分享
ide·人工智能·jupyter
mingo_敏1 小时前
DeepAgents : 权限(Permissions)
人工智能·深度学习·langchain