记录:在深度学习训练过程中的评估阶段使用pycocotools时出现错误:

if type(resFile) == str or type(resFile) == unicode: NameError: name ‘unicode’ is not defined

搜索后应该是python2和3版本的问题,Python2 的unicode函数在 Python3 中不再使用。

解决方法1:可以用下面的命令重新安装pycocotools

pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'

解决方法2:重新安装不方便的话,可以修改环境中安装的pycocotools库的代码

修改 anaconda3/envs/py37/lib/python3.7/site-packages/pycocotools/coco.py 文件中出错的那行代码,其中,py37是自己的环境名。

# 大约是在300多行
# 修改前
if type(resFile) == str or type(resFile) == unicode:
# 修改后
if type(resFile) == str or (PYTHON_VERSION == 2 and type(resFile) == unicode):
深度学习评估时使用pycocotools时出现错误:if type(resFile) == str or type(resFile) == unicode: NameError: name ‘unicode’ is not defined
Product Description Universal Data Access Components (UniDAC) is a library of components that provides direct access to most popular database servers from Delphi, Delphi for .NET and, C++Builder. UniDAC can work with such servers as Oracle, Microsoft SQL Server, MySQL, Interbase, Firebird. The UniDAC library is designed to help programmers develop faster and cleaner cross-database applications. UniDAC is a complete replacement for such standard universal technology as dbExpress. UniDAC is a handy in use and efficient data access solution bringing into play many features specific to each server. Requirements UniDAC is a product joining functionality of such data access solutions as ODAC, SDAC, MyDAC, and IBDAC. Requirements of UniDAC depend only on used providers. Detailed requirements for each provider can be found in the Requirements topic in the UniDAC Help documentation. Installation Compiled versions of UniDAC are installed automatically by the UniDAC Installer for all supported IDEs. Versions of UniDAC with Source Code must be installed manually. For more information, see the Installation topic of the UniDAC Help documentation. It is important to know that UniDAC, ODAC, SDAC, MyDAC, and IBDAC use the common base packages, so product compatibility is provided for the current build only. In the other words, if you upgrade one of the installed providers, it may conflict with older builds of other products. In order to continue using the products simultaneously, you should upgrade all of them at the same time. 7.1.4 29-Sep-17 InterBase data provider Bug with the "Input parameter mismatch" error for procedure is fixed Bug with transactions when working with Firebird 2.5 is fixed 7.1.3 19-Sep-17 The performance of TVirtualQuery is significantly improved Application- defined functions in TVirtualQuery are supported Application- defined collations in TVirtualQuery are supported AutoInc fields in TVirtualTable are supported Bug with assertion failure when updating a record in TVirtualQuery is fixed Bug with compatibility with TkbmMemTable in TVirtualQuery is fixed Bug with complex WHERE clauses that have several string fields in TVirtualQuery is fixed Bug with selecting from a dataset with a single record in TVirtualQuery is fixed Bug with generating SQL for batch updates is fixed Bug with the Locate method for non-Windows platforms in Lazarus is fixed Bug with the FindFirst, FindLast, FindNext, FindPrior methods in Lazarus is fixed Bug with accessing a product help from the IDE menu is fixed Bug with recreating fields when calling Open after Prepare is fixed Bug with an incorrect error message when using the Connect dialog component on mobile platforms is fixed Bug with AV failure when using calculated fields in TClientDataset is fixed Bug with a key violation error when executing batch operations is fixed Bug with Assert when calling the Locate method in the SmartFetch mode is fixed Bug with using DAC components in DataModule for Linux is fixed Cloud data providers BigCommerce provider is added Dynamics CRM provider is added FreshBooks provider is added Magento provider is added MailChimp provider is added NetSuite provider is added QuickBooks provider is added Salesforce provider is added Salesforce Marketing Cloud provider is added SugarCRM provider is added Zoho CRM provider is added Oracle data provider Oracle 12c connection modes (SYSBACKUP, SYSDG, SYSKM) in the Direct mode are supported OS authentication in the Direct mode is supported NChar literal replacement is supported CLOB parameters behavior when Unicode Environment=True is improved Bug with lost chars in a parameter value when ConvertEOL=True is fixed SQLServer data provider Bug with processing varchar fields when AutoTranslate is True in the Direct mode is fixed Bug with processing a field with alias for query with the JOIN statement is fixed Bug with date and time fractional seconds precision when DescribeParams = True is fixed MySQL data provider Azure Database for MySQL is supported JSON data type is supported InterBase data provider Support for Firebird on Android platform is added Support for Firebird 3 packages is added Aliases handling in the RETURNING clause is supported The WireCompression connection parameter for Firebird 3 is supported Bug with using BLOB data type in batch operations is fixed Bug with the OnBackupProgress event handler in TUniDADump is fixed Bug with using batch parameters of the Bytes type is fixed Bug with closing a connection that has an active transaction for Firebird 3 is fixed Bug with recreating a connection on Linux and mobile platforms is fixed PostgreSQL data provider SSPI authentication is supported Processing GUID data type for the TGuidField class is improved SQLite data provider Now the Direct mode is based on the SQLite engine version 3.20.0 Custom SQL aggregate functions are supported Bug with opening an existing database on iOS 64 is fixed Bug with detecting field types is fixed Bug with international symbols in non- Unicode Delphi versions is fixed Bug with low performance of the LoadFromDataSet method of the Loader component is fixed Bug with index backup using the Dump component when the TableNames property is set is fixed DBF data provider The CodePage specific options are added The ConnectMode specific options are added Bug with using CDX indexes is fixed DB2 data provider The DECFLOAT data type is supported 7.0.2 15-May-17 Bug with using TVirtualQuery with TVirtualTable is fixed Bug with processing NULL values in the Loader component is fixed Bug with executing a query after executing a batch command is fixed Bug with executing a batch operation inside an explicitly started transaction is fixed Bug with using the AsGuid property is fixed Oracle data provider Bug with authentication in the Direct mode is fixed MySQL data provider Bug with processing DATETIME fields is fixed SQLServer data provider Bug with the "Invalid column name" error when editing a query with the JOIN statement is fixed InterBase data provider Bug with memory leak when using the SQLMonitor component is fixed PostgreSQL data provider Bug with AV failure after executing the Ping method is fixed SQLite data provider Bug with creating a database in the Direct Mode on Android is fixed
在编辑代码时,如果需要采用非本代码所在文件夹下的代码文件的函数或者类时,那么需要添加该代码文件所在路径,否则会报“ NameError : name 'XXX' is not defined ”的错误,其实解决方案也非常简单,只要使用sys函数就可以解决: 比如在编写的代码中需要使用另外一个文件夹util内的代码文件Reader.py的一个函数 ,那么只用在头文件下输入如下语句: import s...
python 2.x和 python 3.x之间相差很多,有很多语法知识已经不再适用于新的 python 版本,下面简单列出3个错误: 一、pickle.load错误:a bytes-like object is required, not 'str' pickle(除了最早的版本外)是二进制格式的,所以应该带 'b' 标志打开文件; f=open('./a.txt','rb') 是一个 nameerror ,说var为定义,所以执行不成功。这是因为将var定义在了函数里面,即return后一行的代码缩进了,导致var没有定义成功,只需要去除缩进就可以了。 更改如下: def load_data(): from keras.datasets import mnist # global train_image, train_lable , test_image, test_lable (train_image, train_lable), (test_image, test_lable) = mnist.load_data.
windows下如何安装 pycoco tools ?怎么解决 报错 问题? 程序运行过程中总会无意间 报错 ModuleNotFoundError: No module named ‘ pycoco tools ._mask’ ModuleNotFoundError: No module named ‘ pycoco tools ’ 最简单的方法:pip install pycoco tools 发现并不支持 发现,p...
MaskRCNN时出现了No module named pycoco tools .coco的情况 主要是需要安装需要安装 pycoco tools ,这个就比较蛋疼后来才发现原来大佬开源了windows的API,进入GitHub按提示搞就好了。 Windows: https://github.com/philferriere/cocoapi. You must have the Visual C++ ...
这个问题通常是因为代码中使用了 Python 2.x中的 ` unicode ` 类型,而在 Python 3.x中已经将其删除,改为使用 `str` 类型。解决方法是将代码中所有的 ` unicode ` 替换为 `str`。 如果你使用的是 Python 2.x版本,可以检查是否有其他错误导致了这个问题。如果你使用的是 Python 3.x版本,那么需要将代码中所有的 ` unicode ` 替换为 `str`,或者在代码开头添加以下语句: ``` python import sys if sys.version_info.major == 2: reload(sys) sys.setdefaultencoding('utf8') 这样做可以使 Python 2.x中的 `str` 类型默认编码为 `utf-8`,以避免编码问题。但是,如果你使用的是 Python 3.x版本,则不需要使用这个方法。
MZYYZT: 大佬 有一个问题,就是 我的数据集是NWPU-VHR-10,训练集455张,测试集195张,然后DETR训练的时候,在不加载预训练权重的时候,loss正常,但是val集上map结果一直为0.0000。 如果加载预训练模型后,一切正常。 所以,这是什么问题呢?是数据量太少的问题?请大佬指点一下 使用DETR模型训练自己的数据集过程记录 Limit967: 请问,训练过程中保存的评估文件、权重文件和训练日志文件在哪里修改保存地址啊? 使用DETR模型训练自己的数据集过程记录 W three: 考虑一下预训练权重文件的问题? pycocotools报错,NameError: name ‘unicode’ is not defined CSDN-Ada助手: 恭喜您又写了一篇博客!看到您遇到的问题,我想说这是一个常见的问题,也是我们在学习Python过程中会遇到的问题。如果您想进一步深入学习Python,可以学习一下Python 2和Python 3之间的不同之处,这将有助于更好地理解和解决这些问题。期待您的下一篇博客! CSDN 正在通过评论红包奖励优秀博客,请看红包流:https://bbs.csdn.net/?type=4&header=0&utm_source=csdn_ai_ada_blog_reply3,我们会奖励持续创作和学习的博主,请看:https://bbs.csdn.net/forums/csdnnews?typeId=116148&utm_source=csdn_ai_ada_blog_reply3