classification for 3 birds test
from huggingface_hub import from_pretrained_keras
model = from_pretrained_keras("wenyuan1/EfficientNetV2S-Birds")
print(model.name)
import tensorflow as tf
import matplotlib.pylab as plt
import numpy as np
from tensorflow import keras
from tensorflow.keras.applications.efficientnet import preprocess_input
normalization_layer = tf.keras.layers.Rescaling(1. / 255)
image = keras.preprocessing.image.load_img('/content/validateSet/狗/微信图片_20231031095654.png', target_size=(384, 384))
plt.imshow(image)
image = keras.preprocessing.image.img_to_array(image)
image = preprocess_input(image)
#print(image)
plt.axis('off')
plt.show()
# Expand the validation image to (1, 224, 224, 3) before predicting the label
prediction_scores = model.predict(normalization_layer(np.expand_dims(image, axis=0)))
predicted_index = np.argmax(prediction_scores)
class_names = ["狗","猫","鹦鹉"]
print(class_names)
print(predicted_index)
print("Predicted label: " + class_names[predicted_index])
- Downloads last month
- 34
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.