Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6403 Discussions

AttributeError: 'DatasetConversionInfo' object has no attribute 'identifier'

shirleyliu
New Contributor I
2,461 Views
 
 
 
 

 

my commad line is 

pot -c SR-fsrcnn.json

my json configuration file is here 

{
/* Model parameters */

"model": {
"model_name": "withoutd_s8_x4_fp32", // Model name
"model": "withoutd_s8_x4_fp32.xml", // Path to model (.xml format)
"weights": "withoutd_s8_x4_fp32.bin" // Path to weights (.bin format)
},

/* Parameters of the engine used for model inference */

"engine": {
"config": "AC-SR-FP32-fsrcnn.yml"
},

/* Optimization hyperparameters */

"compression": {
"target_device": "GPU", // Target device, the specificity of which will be taken
// into account during optimization
"algorithms": [
{
"name": "DefaultQuantization", // Optimization algorithm name
"params": {
"preset": "performance", // Preset [performance, mixed, accuracy] which control the quantization
// mode (symmetric, mixed (weights symmetric and activations asymmetric)
// and fully asymmetric respectively)

"stat_subset_size": 1 // Size of subset to calculate activations statistics that can be used
// for quantization parameters calculation
}
}
]
}
}

my yml configuration file is 

models:
- name: SR-fsrcnn-x4-fp32
launchers:
- framework: dlsdk
model: withoutd_s8_x4_fp32.xml
weights: withoutd_s8_x4_fp32.bin

device: GPU
adapter:
type: super_resolution
reverse_channels: True
datasets:
- name: SR_fsrcnn_x4
reader:
type: opencv_imread
reading_flag: gray
data_source: dataset_x4
annotation_conversion:
converter: super_resolution
data_dir: dataset_x4
lr_suffix: lr_y_
#upsample_suffix: upsample_x4
hr_suffix: hr_y_
#two_streams: True
annotation: SR_fsrcnn_x4.pickle
metrics:
- type: psnr
scale_border: 0
presenter: print_vector
- type: ssim
presenter: print_vector

 

 

Labels (1)
0 Kudos
1 Solution
shirleyliu
New Contributor I
2,276 Views

hello,

Yes. Actually, I have already shared the method in the previous message box.

I debug the source code and found that the error derives from "l\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\libs\open_model_zoo\tools\accuracy_checker\accuracy_checker\dataset.py"

def read_annotation(annotation_file: Path):
    annotation_file = get_path(annotation_file)
    result = []
    with annotation_file.open('rb') as file:
        try:
            first_obj = pickle.load(file)
            if isinstance(first_obj, DatasetConversionInfo): # it returns false
                describe_cached_dataset(first_obj)
            else:
                result.append(first_obj)
        except EOFError:
            return result
        while True:
            try:
                result.append(BaseRepresentation.load(file))
            except EOFError:
                break
    print_info("result is {}".format(result))
    return result

this code 

if isinstance(first_obj, DatasetConversionInfo):

expected "True" but it returned "False". so the "DatasetConversionInfo" instance will be appended to "result" list.
and when it comes to code, it will show 'DatasetConversionInfo' object has no attribute 'identifier'

class AnnotationProvider:
    def __init__(self, annotations, meta, name='', config=None):
        self.name = name
        self.config = config
        self._data_buffer = OrderedDict()
        self._meta = meta
        for ann in annotations:
            idx = create_identifier_key(ann.identifier) # bug accurs
            self._data_buffer[idx] = ann

I compare the "repr(first_obj.__class__)" and "repr(DatasetConversionInfo)" and found they are different
repr(first_obj.__class__) is 

accuracy_checker.annotation_converters.convert.DatasetConversionInfo


repr(DatasetConversionInfo) is 

libs.open_model_zoo.tools.accuracy_checker.accuracy_checker.annotation_converters.convert.DatasetConversionInfo

 

so I try to change the code in the file which locates in "openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\libs\open_model_zoo\tools\accuracy_checker\accuracy_checker\annotation_converters_init_.py"

from  accuracy_checker.annotation_converters.convert import make_subset, save_annotation, analyze_dataset, DatasetConversionInfo
# from .convert import make_subset, save_annotation, analyze_dataset, DatasetConversionInfo

View solution in original post

0 Kudos
10 Replies
Zulkifli_Intel
Moderator
2,444 Views

Hello Liu Xue Chun,


Thank you for reaching out.


Can you try running the setupenv.bat file again to initialize the OpenVINO environment?


Regards,

Zulkifli


0 Kudos
shirleyliu
New Contributor I
2,342 Views

I compare the repr(first_obj.__class__) and repr(DatasetConversionInfo) and found they are different
repr(first_obj.__class__) is accuracy_checker.annotation_converters.convert.DatasetConversionInfo
repr(DatasetConversionInfo) is libs.open_model_zoo.tools.accuracy_checker.accuracy_checker.annotation_converters.convert.DatasetConversionInfo

so I try to change the code in the file which locates in "openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\libs\open_model_zoo\tools\accuracy_checker\accuracy_checker\annotation_converters_init_.py"

from  accuracy_checker.annotation_converters.convert import make_subset, save_annotation, analyze_dataset, DatasetConversionInfo
# from .convert import make_subset, save_annotation, analyze_dataset, DatasetConversionInfo

now the pot tool works okay. but if there is a better way to solve this, please let me know,
thanks,
BR

0 Kudos
shirleyliu
New Contributor I
2,427 Views

hello Zulkifli,

I have tried to run the setupenv.bat again but the problem still exists

0 Kudos
shirleyliu
New Contributor I
2,380 Views

my environment is 

Python 3.7.10(anaconda)

openvino_2021.3.394

the packages in conda environment

# packages in environment at C:\Users\l00532714\Anaconda3\envs\openvino_py37:
#
# Name                    Version                   Build  Channel
accuracy-checker          0.8.6                    pypi_0    pypi
addict                    2.2.1                    pypi_0    pypi
blas                      1.0                         mkl
ca-certificates           2021.5.25            haa95532_1
certifi                   2021.5.30        py37haa95532_0
click                     8.0.1                    pypi_0    pypi
colorama                  0.4.4                    pypi_0    pypi
cycler                    0.10.0                   pypi_0    pypi
decorator                 5.0.9                    pypi_0    pypi
defusedxml                0.7.1              pyhd3eb1b0_0
editdistance              0.5.3                    pypi_0    pypi
fast-ctc-decode           0.3.0                    pypi_0    pypi
geos                      3.8.0                h33f27b4_0
imageio                   2.9.0                    pypi_0    pypi
importlib-metadata        4.4.0                    pypi_0    pypi
intel-openmp              2021.2.0           haa95532_616
intelpython               2021.1.1                      1    intel
joblib                    1.0.1                    pypi_0    pypi
kiwisolver                1.3.1                    pypi_0    pypi
matplotlib                3.4.2                    pypi_0    pypi
mkl                       2021.2.0           haa95532_296
mkl-service               2.3.0            py37h2bbff1b_1
mkl_fft                   1.3.0            py37h277e83a_2
mkl_random                1.2.1            py37hf11a4ad_2
networkx                  2.6rc1                   pypi_0    pypi
nibabel                   3.2.1                    pypi_0    pypi
nltk                      3.6.2                    pypi_0    pypi
numpy                     1.16.6                   pypi_0    pypi
numpy-base                1.20.2           py37hc2deb75_0
opencv-python             4.5.2.52                 pypi_0    pypi
openssl                   1.1.1k               h2bbff1b_0
openvino-ie               2021.3                intel_394    intel
openvino-ie4py            2021.3                     py37    intel
packaging                 20.9                     pypi_0    pypi
pandas                    0.24.2                   pypi_0    pypi
parasail                  1.2.4                    pypi_0    pypi
pillow                    8.2.0                    pypi_0    pypi
pip                       21.1.1           py37haa95532_0
pot                       1.0                      pypi_0    pypi
py-cpuinfo                8.0.0                    pypi_0    pypi
pydicom                   2.1.2                    pypi_0    pypi
pyparsing                 3.0.0b2                  pypi_0    pypi
python                    3.7.10               h6244533_0
python-dateutil           2.8.1                    pypi_0    pypi
pytz                      2021.1                   pypi_0    pypi
pywavelets                1.1.1                    pypi_0    pypi
pyyaml                    5.4.1                    pypi_0    pypi
rawpy                     0.16.0                   pypi_0    pypi
regex                     2021.4.4                 pypi_0    pypi
scikit-image              0.18.2rc1                pypi_0    pypi
scikit-learn              0.24.2                   pypi_0    pypi
scipy                     1.5.4                    pypi_0    pypi
sentencepiece             0.1.95                   pypi_0    pypi
setuptools                52.0.0           py37haa95532_0
shapely                   1.7.1            py37h210f175_0
six                       1.15.0           py37haa95532_0
sqlite                    3.35.4               h2bbff1b_0
tbb                       2020.3           vc14_intel_311  [vc14]  intel
texttable                 1.6.3                    pypi_0    pypi
threadpoolctl             2.1.0                    pypi_0    pypi
tifffile                  2021.4.8                 pypi_0    pypi
tokenizers                0.10.3                   pypi_0    pypi
tqdm                      4.61.0                   pypi_0    pypi
typing-extensions         3.10.0.0                 pypi_0    pypi
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wheel                     0.36.2             pyhd3eb1b0_0
wincertstore              0.2                      py37_0
zipp                      3.4.1                    pypi_0    pypi

I found that the accuracy_checker and pot can be successfully installed only in python3.7. so I create a conda environment(python 3.7.10) and conda install openvino toolkit from Anaconda cloud using

 conda install openvino-ie4py -c intel.

and then I use 

python setup.py install 

to successfully install accuracy_checker and pot

0 Kudos
shirleyliu
New Contributor I
2,356 Views
hello, I got some updates when I debug the code

I meet an error when I try to do quantization. it shows"AttributeError: 'DatasetConversionInfo' object has no attribute 'identifier'"
So I debug the source code and found that the error derives from "l\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\libs\open_model_zoo\tools\accuracy_checker\accuracy_checker\dataset.py"

def read_annotation(annotation_file: Path):
    annotation_file = get_path(annotation_file)
    result = []
    with annotation_file.open('rb') as file:
        try:
            first_obj = pickle.load(file)
            if isinstance(first_obj, DatasetConversionInfo): # it returns false
                describe_cached_dataset(first_obj)
            else:
                result.append(first_obj)
        except EOFError:
            return result
        while True:
            try:
                result.append(BaseRepresentation.load(file))
            except EOFError:
                break
    print_info("result is {}".format(result))
    return result

this code if isinstance(first_obj, DatasetConversionInfo): expected True but it return False. so the DatasetConversionInfo instance will be appended to result list.
and when it comes to code, it will show 'DatasetConversionInfo' object has no attribute 'identifier',  there might be some import problems, so what's the best way to solve this problem 

class AnnotationProvider:
    def __init__(self, annotations, meta, name='', config=None):
        self.name = name
        self.config = config
        self._data_buffer = OrderedDict()
        self._meta = meta
        for ann in annotations:
            idx = create_identifier_key(ann.identifier) # bug accurs
            self._data_buffer[idx] = ann
0 Kudos
Zulkifli_Intel
Moderator
2,328 Views

Hello Liu Xue Chun

 

Thank you for your patience. Based on discussion with the POT developer, we identify that the problem happens in Accuracy Checker and we suspected the AC configuration file (.yaml) that you used having some issues or some problems during AC processes itself - not from POT.

 

Also, INT8 support for FSRCNN has been officially enabled and added in the OpenVINO 2021.4 and we strongly recommend trying it in this latest version of OpenVINO. The official installation package is yet to be released, but you can obtain it from our GitHub release branch: openvinotoolkit/openvino at releases/2021/4 (github.com).

 

Please re-run the POT using the .yml file that we provided before in the previous case and share with us the findings.

 

Sincerely,

Zulkifli


0 Kudos
shirleyliu
New Contributor I
2,313 Views

hello,

thanks for your reply and I use the .yml file you provided. the problem still occurs. I guess the problem has nothing to do with the configuration file. because it's some import error in accuracy checker. when I fixed it the problem disappear

0 Kudos
Zulkifli_Intel
Moderator
2,309 Views

Hello Liu Xue Chun,


Would you mind sharing with us the changes you make to fix the error? I believe it will be beneficial for other users if they encountered the same error.


Sincerely,

Zulkifli


0 Kudos
shirleyliu
New Contributor I
2,277 Views

hello,

Yes. Actually, I have already shared the method in the previous message box.

I debug the source code and found that the error derives from "l\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\libs\open_model_zoo\tools\accuracy_checker\accuracy_checker\dataset.py"

def read_annotation(annotation_file: Path):
    annotation_file = get_path(annotation_file)
    result = []
    with annotation_file.open('rb') as file:
        try:
            first_obj = pickle.load(file)
            if isinstance(first_obj, DatasetConversionInfo): # it returns false
                describe_cached_dataset(first_obj)
            else:
                result.append(first_obj)
        except EOFError:
            return result
        while True:
            try:
                result.append(BaseRepresentation.load(file))
            except EOFError:
                break
    print_info("result is {}".format(result))
    return result

this code 

if isinstance(first_obj, DatasetConversionInfo):

expected "True" but it returned "False". so the "DatasetConversionInfo" instance will be appended to "result" list.
and when it comes to code, it will show 'DatasetConversionInfo' object has no attribute 'identifier'

class AnnotationProvider:
    def __init__(self, annotations, meta, name='', config=None):
        self.name = name
        self.config = config
        self._data_buffer = OrderedDict()
        self._meta = meta
        for ann in annotations:
            idx = create_identifier_key(ann.identifier) # bug accurs
            self._data_buffer[idx] = ann

I compare the "repr(first_obj.__class__)" and "repr(DatasetConversionInfo)" and found they are different
repr(first_obj.__class__) is 

accuracy_checker.annotation_converters.convert.DatasetConversionInfo


repr(DatasetConversionInfo) is 

libs.open_model_zoo.tools.accuracy_checker.accuracy_checker.annotation_converters.convert.DatasetConversionInfo

 

so I try to change the code in the file which locates in "openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\libs\open_model_zoo\tools\accuracy_checker\accuracy_checker\annotation_converters_init_.py"

from  accuracy_checker.annotation_converters.convert import make_subset, save_annotation, analyze_dataset, DatasetConversionInfo
# from .convert import make_subset, save_annotation, analyze_dataset, DatasetConversionInfo

0 Kudos
Zulkifli_Intel
Moderator
2,273 Views

Hello Lie Xue Chun,


Thank you for your sharing, we really appreciate it. Since the problem has been resolved, this thread will no longer be monitored.


Sincerely,

Zulkifli


0 Kudos
Reply