Muyun99's wiki Muyun99's wiki
首页
学术搬砖
学习笔记
生活杂谈
wiki搬运
资源收藏
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

Muyun99

努力成为一个善良的人
首页
学术搬砖
学习笔记
生活杂谈
wiki搬运
资源收藏
关于
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • 代码实践-目标检测

  • 代码实践-图像分割

  • 代码实践-自监督学习

  • 竞赛笔记-视觉竞赛

  • 框架解析-mmlab系列

    • MMClassifiction 框架学习导言
    • mmcls 是如何能够通过config 就搭建好一个模型的?
    • 为自己的 inicls 框架加上 fp16 训练
    • 为自己的 inicls 框架集成 Horovod
    • 为自己的 inicls 框架集成 DALI
    • mmsegmentation框架解析(上)
    • mmsegmentation框架解析(中)
    • mmsegmentation框架解析(下)
    • mmcv 使用
      • mmcv使用(中)--Config
      • 什么是 Register
      • 什么是 ABCMeta
      • mmseg数据集
      • mmseg 推理单张图像并保存
      • 计算loss和计算metric
    • 讲座记录-有意思的文章集合

    • 体会感悟-产品沉思录观后有感

    • 体会感悟-摄影

    • 系列笔记-

    • 系列笔记-乐理和五线谱

    • 系列笔记-爬虫实践

    • 系列笔记-Django学习笔记

    • 系列笔记-Git 使用笔记

    • 系列笔记-网站搭建

    • 系列笔记-图卷积网络

    • 课程笔记-MIT-NULL

    • 系列笔记-OpenCV-Python

    • 系列笔记-使用 Beancount 记账

    • 系列笔记-Python设计模式

    • 系列笔记-MLOps

    • 系列笔记-Apollo自动驾驶

    • 系列笔记-PaddlePaddle

    • 系列笔记-视频操作

    • Vue+Django前后端分离开发

    • 深度学习及机器学习理论知识学习笔记

    • PyTorch Tricks

    • 学习笔记
    • 框架解析-mmlab系列
    Muyun99
    2021-04-17

    mmcv 使用

    # mmcv 使用

    最近发现 open-mmlab 开发的 mmcv 比较好用,故在此记录下使用说明,用的比较多的应该是File IO 和 Image 的相关内容

    # 文件读写(file_handlers)

    对外提供统一的文件读写API,例如下面的示例

    import mmcv
    
    # load data from a file
    data = mmcv.load('test.json')
    data = mmcv.load('test.yaml')
    data = mmcv.load('test.pkl')
    # load data from a file-like object
    with open('test.json', 'r') as f:
        data = mmcv.load(f, file_format='json')
    
    # dump data to a string
    json_str = mmcv.dump(data, file_format='json')
    
    # dump data to a file with a filename (infer format from file extension)
    mmcv.dump(data, 'out.pkl')
    
    # dump data to a file with a file-like object
    with open('test.yaml', 'w') as f:
        data = mmcv.dump(data, f, file_format='yaml')
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19

    # 图像操作

    # 图像的读写和展示
    import mmcv
    
    img = mmcv.imread('test.jpg')
    img = mmcv.imread('test.jpg', flag='grayscale')
    img_ = mmcv.imread(img) # nothing will happen, img_ = img
    mmcv.imwrite(img, 'out.jpg')
    
    1
    2
    3
    4
    5
    6
    mmcv.imshow('tests/data/color.jpg')
    # this is equivalent to
    
    for i in range(10):
        img = np.random.randint(256, size=(100, 100, 3), dtype=np.uint8)
        mmcv.imshow(img, win_name='test image', wait_time=200)
    
    
    1
    2
    3
    4
    5
    6
    7
    # 图像的 Resize
    # resize to a given size
    mmcv.imresize(img, (1000, 600), return_scale=True)
    
    # resize to the same size of another image
    mmcv.imresize_like(img, dst_img, return_scale=False)
    
    # resize by a ratio
    mmcv.imrescale(img, 0.5)
    
    # resize so that the max edge no longer than 1000, short edge no longer than 800
    # without changing the aspect ratio
    mmcv.imrescale(img, (1000, 800))
    
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13

    参考资料

    • https://mmcv.readthedocs.io/en/latest/io.html
    • https://mmcv.readthedocs.io/en/latest/image.html
    上次更新: 2021/08/02, 21:04:52
    mmsegmentation框架解析(下)
    mmcv使用(中)--Config

    ← mmsegmentation框架解析(下) mmcv使用(中)--Config→

    最近更新
    01
    Structured Knowledge Distillation for Semantic Segmentation
    06-03
    02
    README 美化
    05-20
    03
    常见 Tricks 代码片段
    05-12
    更多文章>
    Theme by Vdoing | Copyright © 2021-2023 Muyun99 | MIT License
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式
    ×