Fehler: "Ich konnte keine variable batch_normalisierung_7/Beta finden" beim Bereitstellen eines benutzerdefinierten ModePython

Python-Programme
Anonymous
 Fehler: "Ich konnte keine variable batch_normalisierung_7/Beta finden" beim Bereitstellen eines benutzerdefinierten Mode

Post by Anonymous »

Ich habe mein Modell mit Transferlernen und Modell sequentiell trainiert. < /p>

Code: Select all

inceptionv3_model = InceptionV3(weights="imagenet", include_top=False, input_shape=(224, 224, 3))
inceptionv3_model.trainable = False

model = Sequential()
model.add(inceptionv3_model)

model.add(Conv2D(32, (3, 3), activation='relu', padding='same'))
model.add(GlobalAveragePooling2D())

# flatten
model.add(Flatten())

# hidden layer
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.2))

# output layer
model.add(Dense(3, activation='softmax'))
Speichern Sie nach Abschluss des Anpassungsmodells das Modell mit SAREDMODEL Format.

Code: Select all

saved_model_path = '/kaggle/working/models/cdb_model/1'
tf.saved_model.save(model, saved_model_path)
und das Ich möchte mit TF-SERVING auf Docker bereitstellen. Erstellen Sie Docker Bild TF-SERVING und erstellen Sie Docker Container zum Ausführen.

Code: Select all

docker pull tf/serving

docker run -it -v models:/models -p 8501:8501 --entrypoint /bin/ba
sh tensorflow/serving

tensorflow_model_server --rest_api_port=8501 --model_name=cdb_model --model_base_path=
/models/cdb_model/
Wenn ich die Endpoint -URL, Status OK überprüfe F0lrdypv.png " /> < /p>
Aber wenn post < /code> Bild für die Vorhersage < /p>
postet

Code: Select all

def images_preprocessing(filename):
img = image.load_img(filename, target_size=(224, 224))
img_array = image.img_to_array(img)
img_array = np.expand_dims(img_array, axis=0)
img_array = img_array / 255.0
return img_array
image = images_preprocessing(cat_path)
json_data = {
"instances": image.tolist()
}
endpoint = "http://localhost:8501/v1/models/cdb_model:predict"
response = requests.post(endpoint, json=json_data)
predictions = response.json()
print(predictions)
< /code>
JSON Rückgabefehler: < /p>
{'error': 'Could not find variable batch_normalization_7/beta. This could mean that the variable has been deleted. In TF1, it can also mean the variable is uninitialized. Debug info: container=localhost, status error message=Resource localhost/batch_normalization_7/beta/N10tensorflow3VarE does not exist.\n\t [[{{function_node __inference_serving_default_199623}}{{node sequential_1/inception_v3_1/batch_normalization_7_1/Cast_2/ReadVariableOp}}]]'}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post