Property 'model' of 'WandbCallback' object has no setter

When I runn on google colab i have no proble. But when i go to the terminal, i receive this errso when using “WandbCallback”. Don’t know why this is hapenning.
This is my code:
import os
import random

import numpy as np
from tensorflow import keras
from keras.utils import to_categorical
from keras.applications.resnet50 import ResNet50, preprocess_input
from keras.models import Sequential
from keras.layers import Dense, GlobalAveragePooling2D

Set seed for reproducibility

os.environ[‘TF_CUDNN_DETERMINISTIC’] = ‘1’
random.seed(hash(“SETTING ANDOM SEEDS”) % 232-1)
np.random.seed(hash(“improves reproducibility”) % 2
32-1)

Load and preprocess images

def load_images(directory):
images =
labels =
for label_idx, label in enumerate(os.listdir(directory)):
label_path = os.path.join(directory, label)
for filename in os.listdir(label_path):
img_path = os.path.join(label_path, filename)
img = keras.preprocessing.image.load_img(img_path, target_size=(224, 224), color_mode=‘rgb’)
img_array = keras.preprocessing.image.img_to_array(img) / 255.0
images.append(img_array)
labels.append(label_idx)
return np.array(images), np.array(labels)

Define paths to data

base_dir = ‘D:/SMALL_IMAGES_CNN’
train_dir = os.path.join(base_dir, ‘train’)
test_dir = os.path.join(base_dir, ‘test’)

Load and preprocess train and test data

x_train, y_train_raw = load_images(train_dir)
x_test, y_test_raw = load_images(test_dir)

One hot encode output

y_train = to_categorical(y_train_raw)
y_test = to_categorical(y_test_raw)

Load ResNet50 model

resnet_model = ResNet50(weights=“imagenet”, include_top=False, input_shape=(224, 224, 3))

Extract features using ResNet50

x_train_features = preprocess_input(x_train)
x_test_features = preprocess_input(x_test)
CLASS_NAMES = [“negative”, “positive”]

Build a new model

def create_model():
model = Sequential()
model.add(resnet_model)
model.add(GlobalAveragePooling2D())
model.add(Dense(256, activation=‘relu’)) # Adding a dense layer for further processing
model.add(Dense(len(CLASS_NAMES), activation=‘sigmoid’))
return model

Initialize WandB

import wandb
from wandb.keras import WandbCallback
wandb.init(project=‘my-keras-integration-Mydata_test’)

Create and compile model

model = create_model()
model.compile(optimizer=‘adam’, loss=‘binary_crossentropy’, metrics=[‘accuracy’])

Train the model

model.fit(x_train_features, y_train, epochs=50, batch_size=32, validation_data=(x_test_features, y_test), callbacks=[WandbCallback()])

Hey @flora-ufsc24, thanks for writing in! Would you mind sharing if you are using the same wandb version both locally and on Colab? Also, please note that this is a legacy callback so we recommend using the three new callback we added in 0.13.4 (docs here)

Hi @flora-ufsc24, I wanted to follow up on this request. Please let us know if we can be of further assistance or if your issue has been resolved.

Hello Luis. I was following a tutorial from the wandb youtube channel. But they already have a few years old. I changed to WandbMetricsLogger and its working well. Thanks for your time !