Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
Convierta una cadena de blob en una imagen Numpy en el backend

Así que tengo una interfaz que tiene una clase de cuadro que almacena x e y en una imagen y cuando el usuario presiona un botón de predicción, la imagen, x, y se envían al backend donde una aplicación de matraz los toma y luego convierte la imagen en un matriz numpy para tensorflow. La imagen está codificada como utf8, sin embargo, parece que no puedo cargarla o decodificarla con opencv o jpeg de codificación de tensorflow. Se agradece cualquier ayuda.

Interfaz:

 async predict() { //Get the image of the box const response = await fetch(document.getElementById('image').src); const data = await response.text(); const response2 = await fetch('/predict', { headers: { 'Content-Type': 'application/json' }, method: 'POST', body: JSON.stringify({ x: this.x, y: this.y, data, }), }) const json = await response2.json(); return json; }
 @app.route("/predict", methods=['POST']) def predict(): #get image from blob image #Get image from url args = request.get_json() x = args['x'] y = args['y'] #Get url but filter the blob: part image = args['data'] #Decode string to image here. #read utf-8 encoded string into image return json({"prediction":enhance.predict(image,enhance.model,x,y)})
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Usando la codificación base64:

 async predict() { //Get the image of the box const response = await fetch(document.getElementById('image').src); let data = await response.arrayBuffer(); data = btoa(data); // base64 encode const response2 = await fetch('/predict', { headers: { 'Content-Type': 'application/json' }, method: 'POST', body: JSON.stringify({ x: this.x, y: this.y, data, }), }) const json = await response2.json(); return json; }
 import base64 @app.route("/predict", methods=['POST']) def predict(): #get image from blob image #Get image from url args = request.get_json() x = args['x'] y = args['y'] #Get url but filter the blob: part image = args['data'] # base64 decode image = base64.b64decode(image) return json({"prediction": enhance.predict(image, enhance.model, x, y)})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!