JdeRobot / RoboticsAcademy

Learn Robotics with JdeRobot
https://jderobot.github.io/RoboticsAcademy
GNU General Public License v3.0
313 stars 225 forks source link

[DL Digit Classifier] Backend fails to parse trained model file when uploaded from Chrome browser #974

Open dpascualhe opened 3 years ago

dpascualhe commented 3 years ago

Chrome browser seems to encode in a different way the file uploaded by the user and generates an invalid string. Relevant code in the frontend: https://github.com/JdeRobot/RoboticsAcademy/blob/76aeab680f443bc4aec53e48c34a9d84cd32b497/exercises/static/exercises/dl_digit_classifier/web-template/assets/ws_code.js#L50-L66

Exception raised:

Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/RoboticsAcademy/exercises/dl_digit_classifier/web-template/exercise.py", line 61, in process_dl_model
    raw_dl_model_bytes = base64.b64decode(raw_dl_model_bytes)
  File "/usr/lib/python3.8/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Invalid base64-encoded string: number of data characters (97089) cannot be 1 more than a multiple of 4
shashwat623 commented 3 years ago

Also, there seem to be a few ONNX converted models with which Chrome works just fine. For Example, the pre-trained model (opset version 8) given here gives no error on Chrome. Whereas, the one which I trained (given here) works with Firefox, but not Chrome.