Actualmente, hay un programa back-end de aprendizaje automático en Python, que se ejecuta en Google Cloud. La aplicación toma los siguientes argumentos: arguments
lang: "EN", //language base64: BASE64, //Whether the image is base64 or not width: 224, //width (always 224) height: 224, //height (always 224) channel: 3, // channels (always 3) image: image_final //BAse64 string of an imageEl programa lee una imagen y devuelve la ubicación del daño (si lo encuentra) y la gravedad del mismo.
El objetivo es implementar esto en un chatbot. Esto significa que tengo que hacer una POST request para enviar datos a esta aplicación.
En nodejs, tengo el siguiente código:
`const payload = { lang: "EN", base64: true, width: 224, height: 224, channel: 3, image: image_final, } let options = { method: "POST", url: "https://BASEURL/CarDamageClassification", data: payload, headers: { "Content-Type": "application/json" } } axios .request(options) .then(function (response) { console.log(response.response) }) .catch(function (error) { console.log(error) })`
Sin embargo, cuando se realiza esta llamada, se produce un error en Python:
(`2022-03-02 13:29:23.000 CET Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2073, in wsgi_app response = self.full_dispatch_request File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1518, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/app/Claims_Car_FNOL.py", line 32, in CarDamageClassify language = payload( 'lang'] TypeError: 'NoneType' object is not subscriptable `) En Nodejs, aparece otro mensaje de error ( Error: Request failed with status code 500 ) + algunos parámetros adicionales. En algún lugar encontré esto: data: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n' + '<title>500 Internal Server Error</title>\n' + '<h1>Internal Server Error</h1>\n' + '<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>\n'
Estoy un poco atascado en este tema y no sé dónde van mal las cosas :(. ¡Gracias de antemano!