• mindrecord.md 无法运行并报错D:\jenkins\age


    writer.commit()

    from mindspore.mindrecord import FileWriter
    
    from mindspore import dataset as ds
    
    ds.config.set_num_parallel_workers(8)
    # 定义一个schema,为双重字典的嵌套,file_name对{"type": "string"},label对{"type": "int32"}
    # data对{"type": "bytes"},我们需要将写入的数据data按照schema的格式给出
    cv_schema_json = {"file_name": {"type": "string"}, "label": {"type": "int32"}, "data": {"type": "bytes"}}
    
    # data为要写入MindRecord的数据,可以将其与cv_schema_json比较验证它的格式,图片以二进制流给出
    data = [{"file_name": "1.jpg", "label": 0, "data": b"\x10c\xb3w\xa8\xee$o&\xd4\x00\xf8\x129\x15\xd9\xf2q\xc0\xa2\x91YFUO\x1dsE1\x1ep"},
            {"file_name": "3.jpg", "label": 99, "data": b"\xaf\xafU<\xb8|6\xbd}\xc1\x99[\xeaj+\x8f\x84\xd3\xcc\xa0,i\xbb\xb9-\xcdz\xecp{T\xb1\xdb"}]
    
    # 添加索引
    indexes = ["file_name", "label"]
    
    # 创建4个MindRecod文件,又含有索引,所以最后又8个MindRecord文件,分别为test.mindrecord0、
    # test.mindrecord0.db、test.mindrecord1、test.mindrecord1.db、test.mindrecord2、
    # test.mindrecord2.db、test.mindrecord3、test.mindrecord3.db
    # 它被称为MindSpore数据集,test.mindrecord0为数据文件,test.mindrecord0.db为索引文件
    writer = FileWriter(file_name="test.mindrecord", shard_num=2)
    writer.add_schema(cv_schema_json, "test_schema")
    writer.add_index(indexes)
    writer.write_raw_data(data)
    # 将最终内存写入磁盘
    writer.commit()

    最后一步报错

        writer.commit()
      File "E:\ProgramData\Anaconda3\envs\mindspore\lib\site-packages\mindspore\mindrecord\filewriter.py", line 391, in commit
        self._generator.build()
      File "E:\ProgramData\Anaconda3\envs\mindspore\lib\site-packages\mindspore\mindrecord\shardindexgenerator.py", line 54, in build
        ret = self._generator.build()
    RuntimeError: Unexpected error. Failed to open file, file path: E:\大三上\深度学习\models-master\official\cv\ssd\MindRecord_COCO\test.mindrecord0
    Line of code : 66
    File         : D:\jenkins\agent-working-dir\workspace\Compile_CPU_Windows\mindspore\mindspore\ccsrc\minddata\mindrecord\meta\shard_header.cc


    Process finished with exit code 1

    【截图信息】

    *******************************************************************************************************************

    应该是文件路径中有中文的文件夹,请改用英文命名试试

  • 相关阅读:
    Scala集合使用flatMap、map的优化及迭代器的原理
    内存取证
    Operator 开发实践 五 (多版本API)
    Linux基础系列(三)——压缩命令、网络命令、关机重启
    MySQL高阶语句(三)
    金某OA协同办公管理系统存在任意文件下载漏洞分析 CNVD-2021-43036
    rem响应式布局
    【强化学习论文合集】五.2017国际表征学习大会论文(ICLR2017)
    python venv 打包,更换路径后,仍然读取到旧路径 ,最好别换路径,采用docker封装起来
    苍穹外卖技术栈
  • 原文地址:https://blog.csdn.net/weixin_45666880/article/details/126498222