Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py3.6中报错:APIError(-1, url, 'json decode error, value={0!r}'.format(ret)) #3

Open
mattzheng opened this issue Dec 20, 2018 · 4 comments

Comments

@mattzheng
Copy link

    if self._api.decode_result:
        try:
            ret = json.loads(ret, object_hook=ObjectDict)
        except:
            raise APIError(-1, url, 'json decode error, value={0!r}'.format(ret))

我在py3.6中跑这句的时候,老是报错,就注释掉了。

@ShwetanshuSingh
Copy link

ShwetanshuSingh commented Dec 23, 2018

I believe I'm facing the same issue. I'm running python 3.5.

@mattzheng Any workaround to it?

code=-1
url=https://api-us.faceplusplus.com/facepp/v3/detect
json decode error, value=b'{"image_id": "8LKKlMVeutiqXxJFYd7lAQ==", "request_id": "1545591172,d8cd331c-1b12-4038-939c-ee52bc65a088", "time_used": 670, "faces": [{"attributes": {"emotion": {"sadness": 0.108, "neutral": 99.61, "disgust": 0.186, "anger": 0.001, "surprise": 0.002, "fear": 0.001, "happiness": 0.092}, "beauty": {"female_score": 81.338, "male_score": 73.428}, "gender": {"value": "Female"}, "age": {"value": 22}, "mouthstatus": {"close": 99.985, "surgical_mask_or_respirator": 0.0, "open": 0.01, "other_occlusion": 0.005}, "glass": {"value": "Normal"}, "skinstatus": {"dark_circle": 13.123, "stain": 2.733, "acne": 3.639, "health": 28.7}, "headpose": {"yaw_angle": 21.387487, "pitch_angle": 5.3423777, "roll_angle": 26.156708}, "blur": {"blurness": {"threshold": 50.0, "value": 0.078}, "motionblur": {"threshold": 50.0, "value": 0.078}, "gaussianblur": {"threshold": 50.0, "value": 0.078}}, "smile": {"threshold": 50.0, "value": 3.084}, "eyestatus": {"left_eye_status": {"normal_glass_eye_open": 67.693, "no_glass_eye_close": 0.0, "occlusion": 0.303, "no_glass_eye_open": 11.356, "normal_glass_eye_close": 0.0, "dark_glasses": 20.648}, "right_eye_status": {"normal_glass_eye_open": 47.296, "no_glass_eye_close": 0.004, "occlusion": 8.392, "no_glass_eye_open": 10.015, "normal_glass_eye_close": 0.018, "dark_glasses": 34.275}}, "facequality": {"threshold": 70.1, "value": 10.756}, "ethnicity": {"value": "WHITE"}, "eyegaze": {"right_eye_gaze": {"position_x_coordinate": 0.538, "vector_z_component": 0.966, "vector_x_component": 0.259, "vector_y_component": 0.026, "position_y_coordinate": 0.465}, "left_eye_gaze": {"position_x_coordinate": 0.595, "vector_z_component": 0.807, "vector_x_component": 0.586, "vector_y_component": -0.075, "position_y_coordinate": 0.407}}}, "face_rectangle": {"width": 377, "top": 306, "left": 298, "height": 377}, "face_token": "bc5003337d082fdfa6df6af4ea270353"}]}'
API key error: code=-1
url=https://api-us.faceplusplus.com/facepp/v3/detect
json decode error, value=b'{"image_id": "DenRhFvzD31kjZYv/rkDGw==", "request_id": "1545591174,7c41279c-c4fa-4245-9f28-de65588249b4", "time_used": 423, "faces": [{"attributes": {"emotion": {"sadness": 0.001, "neutral": 0.009, "disgust": 0.001, "anger": 0.009, "surprise": 0.008, "fear": 0.001, "happiness": 99.973}, "beauty": {"female_score": 65.696, "male_score": 62.644}, "gender": {"value": "Male"}, "age": {"value": 34}, "mouthstatus": {"close": 0.172, "surgical_mask_or_respirator": 97.409, "open": 2.358, "other_occlusion": 0.062}, "glass": {"value": "None"}, "skinstatus": {"dark_circle": 4.8, "stain": 2.692, "acne": 5.16, "health": 19.621}, "headpose": {"yaw_angle": 25.72166, "pitch_angle": 3.9881861, "roll_angle": -18.518732}, "blur": {"blurness": {"threshold": 50.0, "value": 0.338}, "motionblur": {"threshold": 50.0, "value": 0.338}, "gaussianblur": {"threshold": 50.0, "value": 0.338}}, "smile": {"threshold": 50.0, "value": 100.0}, "eyestatus": {"left_eye_status": {"normal_glass_eye_open": 1.11, "no_glass_eye_close": 0.0, "occlusion": 0.0, "no_glass_eye_open": 98.889, "normal_glass_eye_close": 0.0, "dark_glasses": 0.0}, "right_eye_status": {"normal_glass_eye_open": 0.774, "no_glass_eye_close": 0.0, "occlusion": 0.003, "no_glass_eye_open": 99.211, "normal_glass_eye_close": 0.0, "dark_glasses": 0.012}}, "facequality": {"threshold": 70.1, "value": 0.892}, "ethnicity": {"value": "WHITE"}, "eyegaze": {"right_eye_gaze": {"position_x_coordinate": 0.55, "vector_z_component": 0.944, "vector_x_component": 0.285, "vector_y_component": 0.167, "position_y_coordinate": 0.451}, "left_eye_gaze": {"position_x_coordinate": 0.546, "vector_z_component": 0.868, "vector_x_component": 0.454, "vector_y_component": 0.2, "position_y_coordinate": 0.448}}}, "face_rectangle": {"width": 165, "top": 128, "left": 259, "height": 165}, "face_token": "1de781fdeb508244cc0ab640bdf20aca"}, {"attributes": {"emotion": {"sadness": 0.001, "neutral": 0.001, "disgust": 0.001, "anger": 0.001, "surprise": 0.002, "fear": 0.001, "happiness": 99.995}, "beauty": {"female_score": 59.342, "male_score": 61.506}, "gender": {"value": "Female"}, "age": {"value": 37}, "mouthstatus": {"close": 1.675, "surgical_mask_or_respirator": 0.0, "open": 98.316, "other_occlusion": 0.01}, "glass": {"value": "Normal"}, "skinstatus": {"dark_circle": 2.341, "stain": 46.123, "acne": 5.896, "health": 10.664}, "headpose": {"yaw_angle": -11.273614, "pitch_angle": 12.622158, "roll_angle": -12.395025}, "blur": {"blurness": {"threshold": 50.0, "value": 2.732}, "motionblur": {"threshold": 50.0, "value": 2.732}, "gaussianblur": {"threshold": 50.0, "value": 2.732}}, "smile": {"threshold": 50.0, "value": 99.365}, "eyestatus": {"left_eye_status": {"normal_glass_eye_open": 99.755, "no_glass_eye_close": 0.0, "occlusion": 0.001, "no_glass_eye_open": 0.061, "normal_glass_eye_close": 0.087, "dark_glasses": 0.097}, "right_eye_status": {"normal_glass_eye_open": 98.656, "no_glass_eye_close": 0.0, "occlusion": 0.016, "no_glass_eye_open": 0.942, "normal_glass_eye_close": 0.198, "dark_glasses": 0.188}}, "facequality": {"threshold": 70.1, "value": 64.376}, "ethnicity": {"value": "WHITE"}, "eyegaze": {"right_eye_gaze": {"position_x_coordinate": 0.425, "vector_z_component": 0.736, "vector_x_component": -0.267, "vector_y_component": -0.622, "position_y_coordinate": 0.333}, "left_eye_gaze": {"position_x_coordinate": 0.669, "vector_z_component": 0.513, "vector_x_component": 0.604, "vector_y_component": -0.611, "position_y_coordinate": 0.103}}}, "face_rectangle": {"width": 144, "top": 271, "left": 185, "height": 144}, "face_token": "6a1a25f01157a600d7e36fb5b8468597"}]}'

@mattzheng
Copy link
Author

mattzheng commented Dec 24, 2018

I believe I'm facing the same issue. I'm running python 3.5.

@mattzheng Any workaround to it?

code=-1
url=https://api-us.faceplusplus.com/facepp/v3/detect
json decode error, value=b'{"image_id": "8LKKlMVeutiqXxJFYd7lAQ==", "request_id": "1545591172,d8cd331c-1b12-4038-939c-ee52bc65a088", "time_used": 670, "faces": [{"attributes": {"emotion": {"sadness": 0.108, "neutral": 99.61, "disgust": 0.186, "anger": 0.001, "surprise": 0.002, "fear": 0.001, "happiness": 0.092}, "beauty": {"female_score": 81.338, "male_score": 73.428}, "gender": {"value": "Female"}, "age": {"value": 22}, "mouthstatus": {"close": 99.985, "surgical_mask_or_respirator": 0.0, "open": 0.01, "other_occlusion": 0.005}, "glass": {"value": "Normal"}, "skinstatus": {"dark_circle": 13.123, "stain": 2.733, "acne": 3.639, "health": 28.7}, "headpose": {"yaw_angle": 21.387487, "pitch_angle": 5.3423777, "roll_angle": 26.156708}, "blur": {"blurness": {"threshold": 50.0, "value": 0.078}, "motionblur": {"threshold": 50.0, "value": 0.078}, "gaussianblur": {"threshold": 50.0, "value": 0.078}}, "smile": {"threshold": 50.0, "value": 3.084}, "eyestatus": {"left_eye_status": {"normal_glass_eye_open": 67.693, "no_glass_eye_close": 0.0, "occlusion": 0.303, "no_glass_eye_open": 11.356, "normal_glass_eye_close": 0.0, "dark_glasses": 20.648}, "right_eye_status": {"normal_glass_eye_open": 47.296, "no_glass_eye_close": 0.004, "occlusion": 8.392, "no_glass_eye_open": 10.015, "normal_glass_eye_close": 0.018, "dark_glasses": 34.275}}, "facequality": {"threshold": 70.1, "value": 10.756}, "ethnicity": {"value": "WHITE"}, "eyegaze": {"right_eye_gaze": {"position_x_coordinate": 0.538, "vector_z_component": 0.966, "vector_x_component": 0.259, "vector_y_component": 0.026, "position_y_coordinate": 0.465}, "left_eye_gaze": {"position_x_coordinate": 0.595, "vector_z_component": 0.807, "vector_x_component": 0.586, "vector_y_component": -0.075, "position_y_coordinate": 0.407}}}, "face_rectangle": {"width": 377, "top": 306, "left": 298, "height": 377}, "face_token": "bc5003337d082fdfa6df6af4ea270353"}]}'
API key error: code=-1
url=https://api-us.faceplusplus.com/facepp/v3/detect
json decode error, value=b'{"image_id": "DenRhFvzD31kjZYv/rkDGw==", "request_id": "1545591174,7c41279c-c4fa-4245-9f28-de65588249b4", "time_used": 423, "faces": [{"attributes": {"emotion": {"sadness": 0.001, "neutral": 0.009, "disgust": 0.001, "anger": 0.009, "surprise": 0.008, "fear": 0.001, "happiness": 99.973}, "beauty": {"female_score": 65.696, "male_score": 62.644}, "gender": {"value": "Male"}, "age": {"value": 34}, "mouthstatus": {"close": 0.172, "surgical_mask_or_respirator": 97.409, "open": 2.358, "other_occlusion": 0.062}, "glass": {"value": "None"}, "skinstatus": {"dark_circle": 4.8, "stain": 2.692, "acne": 5.16, "health": 19.621}, "headpose": {"yaw_angle": 25.72166, "pitch_angle": 3.9881861, "roll_angle": -18.518732}, "blur": {"blurness": {"threshold": 50.0, "value": 0.338}, "motionblur": {"threshold": 50.0, "value": 0.338}, "gaussianblur": {"threshold": 50.0, "value": 0.338}}, "smile": {"threshold": 50.0, "value": 100.0}, "eyestatus": {"left_eye_status": {"normal_glass_eye_open": 1.11, "no_glass_eye_close": 0.0, "occlusion": 0.0, "no_glass_eye_open": 98.889, "normal_glass_eye_close": 0.0, "dark_glasses": 0.0}, "right_eye_status": {"normal_glass_eye_open": 0.774, "no_glass_eye_close": 0.0, "occlusion": 0.003, "no_glass_eye_open": 99.211, "normal_glass_eye_close": 0.0, "dark_glasses": 0.012}}, "facequality": {"threshold": 70.1, "value": 0.892}, "ethnicity": {"value": "WHITE"}, "eyegaze": {"right_eye_gaze": {"position_x_coordinate": 0.55, "vector_z_component": 0.944, "vector_x_component": 0.285, "vector_y_component": 0.167, "position_y_coordinate": 0.451}, "left_eye_gaze": {"position_x_coordinate": 0.546, "vector_z_component": 0.868, "vector_x_component": 0.454, "vector_y_component": 0.2, "position_y_coordinate": 0.448}}}, "face_rectangle": {"width": 165, "top": 128, "left": 259, "height": 165}, "face_token": "1de781fdeb508244cc0ab640bdf20aca"}, {"attributes": {"emotion": {"sadness": 0.001, "neutral": 0.001, "disgust": 0.001, "anger": 0.001, "surprise": 0.002, "fear": 0.001, "happiness": 99.995}, "beauty": {"female_score": 59.342, "male_score": 61.506}, "gender": {"value": "Female"}, "age": {"value": 37}, "mouthstatus": {"close": 1.675, "surgical_mask_or_respirator": 0.0, "open": 98.316, "other_occlusion": 0.01}, "glass": {"value": "Normal"}, "skinstatus": {"dark_circle": 2.341, "stain": 46.123, "acne": 5.896, "health": 10.664}, "headpose": {"yaw_angle": -11.273614, "pitch_angle": 12.622158, "roll_angle": -12.395025}, "blur": {"blurness": {"threshold": 50.0, "value": 2.732}, "motionblur": {"threshold": 50.0, "value": 2.732}, "gaussianblur": {"threshold": 50.0, "value": 2.732}}, "smile": {"threshold": 50.0, "value": 99.365}, "eyestatus": {"left_eye_status": {"normal_glass_eye_open": 99.755, "no_glass_eye_close": 0.0, "occlusion": 0.001, "no_glass_eye_open": 0.061, "normal_glass_eye_close": 0.087, "dark_glasses": 0.097}, "right_eye_status": {"normal_glass_eye_open": 98.656, "no_glass_eye_close": 0.0, "occlusion": 0.016, "no_glass_eye_open": 0.942, "normal_glass_eye_close": 0.198, "dark_glasses": 0.188}}, "facequality": {"threshold": 70.1, "value": 64.376}, "ethnicity": {"value": "WHITE"}, "eyegaze": {"right_eye_gaze": {"position_x_coordinate": 0.425, "vector_z_component": 0.736, "vector_x_component": -0.267, "vector_y_component": -0.622, "position_y_coordinate": 0.333}, "left_eye_gaze": {"position_x_coordinate": 0.669, "vector_z_component": 0.513, "vector_x_component": 0.604, "vector_y_component": -0.611, "position_y_coordinate": 0.103}}}, "face_rectangle": {"width": 144, "top": 271, "left": 185, "height": 144}, "face_token": "6a1a25f01157a600d7e36fb5b8468597"}]}'

hahahaha~ you could mask those lines:

  if self._api.decode_result:
        try:
            ret = json.loads(ret, object_hook=ObjectDict)
        except:
            raise APIError(-1, url, 'json decode error, value={0!r}'.format(ret))

@ShwetanshuSingh
Copy link

ShwetanshuSingh commented Dec 24, 2018

I found an alternative by converting it into string and then into a dictionary:

    if self._api.decode_result:
            try:
                ret = json.loads(ret, object_hook=ObjectDict)
            except:
                try:
                    ret = json.loads(ast.literal_eval(str(ret)[1:]))
               except:
                    raise APIError(-1, url, 'json decode error, value={0!r}'.format(ret))`

@yanminhui
Copy link

yanminhui commented Jan 22, 2019

I found an alternative by converting it into string and then into a dictionary:

    if self._api.decode_result:
            try:
                ret = json.loads(ret, object_hook=ObjectDict)
            except:
                try:
                    ret = json.loads(ast.literal_eval(str(ret)[1:]))
               except:
                    raise APIError(-1, url, 'json decode error, value={0!r}'.format(ret))`

@ShwetanshuSingh It may be better as follow:

if self._api.decode_result:
    try:    
        try:
            ret = json.loads(ret, object_hook=ObjectDict)
        except:
            ret = json.loads(ast.literal_eval(str(ret)[1:]))
    except:
        raise APIError(-1, url, 'json decode error, value={0!r}'.format(ret))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants