return ExtractorResult(None, stim, self, raw=raw)
def _parse_response_json(self, json):
keys = []values = []
for k, v in json.items():
if k == "faceAttributes":
k = "face"
if isinstance(v, dict):
subkeys, subvalues = self._parse_response_json(v)
keys.extend(["%s_%s" % (k, s) for s in subkeys])
values.extend(subvalues)
elif isinstance(v, list):
// Hard coded to this extractor
for attr in v:
if k == "hairColor":
keys.append("%s" % attr["color"])
elif k == "accessories":
keys.append("%s_%s" % (k, attr["type"]))
else:
continue
values.append(attr["confidence"])
else:
keys.append(k)
values.append(v)
return keys, values
def _to_df(self, result):
cols = []
data = []
After Change
return ExtractorResult(None, stim, self, raw=raw)
def _parse_response_json(self, json):
data_dict = {}
for k, v in json.items():
if k == "faceRectangle" and not self.rectangle:
continue
if k == "faceAttributes":
k = "face"
if isinstance(v, dict):
subdata = self._parse_response_json(v)
for sk, sv in subdata.items():
data_dict["%s_%s" % (k, sk)] = sv
elif isinstance(v, list):
// Hard coded to this extractor
for attr in v:
if k == "hairColor":
key = attr["color"]
elif k == "accessories":
key = "%s_%s" % (k, attr["type"])
else:
continue
data_dict[key] = attr["confidence"]
else:
data_dict[k] = v
return data_dict
def _to_df(self, result):
face_results = []
for i, face in enumerate(result.raw):