Model Usage
import os
import numpy as np
from tensorflow.keras.preprocessing import image
from tensorflow.keras.models import load_model
from tensorflow.keras.applications.inception_v3 import preprocess_input
import tensorflow as tf
# Lista de clases
class_names = ['acanthoica', 'akashiwo', 'alexandrium', 'amoeba', 'amphidinium', 'amylax', 'apedinella', 'asterionellopsis', 'bacillaria', 'bacteriastrum', 'biddulphia', 'calciopappus', 'cerataulina', 'ceratium', 'chaetoceros', 'chrysochromulina', 'cochlodinium', 'corethron', 'corymbellus', 'coscinodiscus', 'cryptophyta', 'cylindrotheca', 'dactyliosolen', 'delphineis', 'dictyocha', 'dinobryon', 'dinophysis', 'ditylum', 'emiliania', 'ephemera', 'eucampia', 'euglena', 'gonyaulax', 'guinardia', 'gyrodinium', 'hemiaulus', 'heterocapsa', 'karenia', 'katodinium', 'kryptoperidinium', 'laboea', 'lauderia', 'leptocylindrus', 'licmophora', 'nanoneis', 'odontella', 'ophiaster', 'ostreopsis', 'oxytoxum', 'paralia', 'parvicorbicula', 'phaeocystis', 'pleuronema', 'pleurosigma', 'polykrikos', 'prorocentrum', 'proterythropsis', 'protoperidinium', 'pseudo-nitzschia', 'pseudochattonella', 'pyramimonas', 'rhabdolithes', 'rhizosolenia', 'scrippsiella', 'skeletonema', 'stephanopyxis', 'syracosphaera', 'thalassionema', 'thalassiosira', 'trichodesmium', 'vicicitus', 'warnowia']
def preprocess_image(image_path, target_size=(299, 299)):
img = image.load_img(image_path, target_size=target_size)
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0)
img_array = preprocess_input(img_array) # Usar la función de preprocesamiento de InceptionV3
return img_array
# Ruta de la imagen que deseas procesar
image_path = '/your/image/path'
img_array = preprocess_image(image_path)
# Hacer la predicción
predictions = model.predict(img_array)[0] # Obtener las probabilidades de la primera (y única) imagen
# Obtener el top 10 de predicciones
top_10_indices = predictions.argsort()[-10:][::-1] # Ordenar índices por probabilidad (de mayor a menor)
top_10_classes = [class_names[i] for i in top_10_indices]
top_10_probabilities = predictions[top_10_indices]
# Mostrar el top 10 de clases con sus probabilidades
print("Top 10 predicciones:")
for i in range(10):
print(f"{top_10_classes[i]}: {top_10_probabilities[i] * 100:.2f}%")
- Downloads last month
- 79
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social
visibility and check back later, or deploy to Inference Endpoints (dedicated)
instead.