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

116
Views
Tensorflow Serving sigue devolviendo el mismo resultado

Entonces, estoy siguiendo este tutorial: https://www.youtube.com/watch?v=t6NI0u_lgNo&t=1826s y justo después de la parte de servicio de tensorflow, había estado probando mi código API fastapi que se ve así:

 from fastapi import FastAPI, File, UploadFile from fastapi.middleware.cors import CORSMiddleware import uvicorn import numpy as np from io import BytesIO from PIL import Image import tensorflow as tf import os import requests os.environ["CUDA_VISIBLE_DEVICES"] = "-1" app = FastAPI() endpoint = "http://localhost:8501/v1/models/plant_model:predict" CLASS_NAMES = ['Potato___Early_blight', 'Potato___Late_blight', 'Potato___healthy', 'Tomato_Early_blight', 'Tomato_Late_blight', 'Tomato_healthy'] @app.get("/ping") async def ping(): return "Hello, I am alive" def read_file_as_image(data) -> np.ndarray: image = np.array(Image.open(BytesIO(data))) return image @app.post("/predict") async def predict( file: UploadFile = File(...) ): image = read_file_as_image(await file.read()) img_batch = np.expand_dims(image, 0) json_data = { "instances": img_batch.tolist() } response = requests.post(endpoint, json=json_data) prediction = np.array(response.json()["predictions"][0]) predicted_class = CLASS_NAMES[np.argmax(prediction[0])] confidence = np.max(prediction[0]) return { 'class': predicted_class, 'confidence': float(confidence) } if __name__ == "__main__": uvicorn.run(app, host='localhost', port=8000)

Por cierto, estoy usando Ubuntu Ubuntu 20.04.

y le estoy pasando la imagen de una hoja de 255x255. (mi modelo está hecho para clasificar diferentes tipos de enfermedades para diferentes tipos de hojas vegetales)

Pero, por alguna razón, siempre me da esta misma salida falsa:

 "class": "Potato___Early_blight", "confidence": 0.374938548 }

También lo probé con otra imagen de hoja, pero sigue siendo el mismo solo que con una confianza diferente:

 "class": "Potato___Early_blight", "confidence": 1.21042137e-06

No puedo publicar imágenes aquí porque mi rango es demasiado bajo.

y aquí está el enlace al cuaderno AI google colab que hice para la IA: https://colab.research.google.com/drive/1i2v_RbZ8lI-e0joE-qBxym6_6xF5rR0g?usp=sharing

Entonces, ¿qué estoy haciendo mal? Revisé otras respuestas pero entran en los detalles del código en lugar de una respuesta general.

over 4 years ago · Santiago Trujillo
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!