f7b2b92679bd7e7a9178c6c1e801973011e3ec99,featurex/extractors/google.py,GoogleVisionAPIFaceExtractor,_parse_annotations,#GoogleVisionAPIFaceExtractor#Any#Any#,104

Before Change



    def _parse_annotations(self, stim, annotations):
        annotations = annotations[0]
        data_dict = {}
        for field, val in annotations.items():
            if field not in ["boundingPoly", "fdBoundingPoly", "landmarks"]:
                data_dict[field] = val
            elif "oundingPoly" in field:
                for i, vertex in enumerate(val["vertices"]):
                    for dim in ["x", "y"]:
                        name = "%s_vertex%d_%s" % (field, i+1, dim)
                        val = vertex[dim] if dim in vertex else np.nan
                        data_dict[name] = val
            elif field == "landmarks":
                for lm in val:
                    name = "landmark_" + lm["type"] + "_%s"
                    lm_pos = { name % k : v for (k, v) in lm["position"].items()}
                    data_dict.update(lm_pos)
        return Value(stim=stim, extractor=self, data=data_dict)


class GoogleVisionAPITextExtractor(GoogleVisionAPIExtractor):

After Change


    response_object = "faceAnnotations"

    def _parse_annotations(self, stim, annotations):
        values = []
        for annotation in annotations:
            data_dict = {}
            for field, val in annotation.items():
                if field not in ["boundingPoly", "fdBoundingPoly", "landmarks"]:
                    data_dict[field] = val
                elif "oundingPoly" in field:
                    for i, vertex in enumerate(val["vertices"]):
                        for dim in ["x", "y"]:
                            name = "%s_vertex%d_%s" % (field, i+1, dim)
                            val = vertex[dim] if dim in vertex else np.nan
                            data_dict[name] = val
                elif field == "landmarks":
                    for lm in val:
                        name = "landmark_" + lm["type"] + "_%s"
                        lm_pos = { name % k : v for (k, v) in lm["position"].items()}
                        data_dict.update(lm_pos)
            values.append(Value(stim=stim, extractor=self, data=data_dict))
        return values


class GoogleVisionAPITextExtractor(GoogleVisionAPIExtractor):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 10

Instances


Project Name: tyarkoni/pliers
Commit Name: f7b2b92679bd7e7a9178c6c1e801973011e3ec99
Time: 2016-09-19
Author: quinten.mcnamara@gmail.com
File Name: featurex/extractors/google.py
Class Name: GoogleVisionAPIFaceExtractor
Method Name: _parse_annotations


Project Name: tyarkoni/pliers
Commit Name: f7b2b92679bd7e7a9178c6c1e801973011e3ec99
Time: 2016-09-19
Author: quinten.mcnamara@gmail.com
File Name: featurex/extractors/google.py
Class Name: GoogleVisionAPILabelExtractor
Method Name: _parse_annotations


Project Name: tyarkoni/pliers
Commit Name: f7b2b92679bd7e7a9178c6c1e801973011e3ec99
Time: 2016-09-19
Author: quinten.mcnamara@gmail.com
File Name: featurex/extractors/google.py
Class Name: GoogleVisionAPITextExtractor
Method Name: _parse_annotations