Open doaaobeidat opened 10 months ago
Like this:
from classification_models_3D.tfkeras import Classifiers
ResNet18, preprocess_input = Classifiers.get('resnet18')
model = ResNet18(input_shape=(128, 128, 96, 1), weights='imagenet')
When I made what you have mentioned it gives me error about unequal axis, how can I can use these models if I want to use input_shape=(128, 128, 96, 1) and input_shape=(128, 128, 96, 3)
I need more details about your error.
From what I gather from your explanation, it seems that I can utilize your pretrained models, which have already undergone the conversion of image weights from 2D to 3D. Therefore, my implementation would look something like this: from keras_applications import Classifiers from tensorflow.keras.layers import GlobalAveragePooling3D, Dense, Dropout from tensorflow.keras.models import Model
densenet121, preprocess_input = Classifiers.get('densenet121')
model = densenet121(input_shape=(96, 96, 96, 1), weights=None, include_top=False) x = GlobalAveragePooling3D()(model.output) x = Dense(units=256, activation="relu")(x) x = Dropout(0.7)(x) outputs = Dense(units=1, activation="sigmoid")(x)
model = Model(model.input, outputs=outputs, name="densenet121")
To use imagenet weights you need to use shape which has 3 channels: "(96, 96, 96, 3)", it's actually not to much complicate model - only 1st layer changed. You can duplicate input 3 times with x = np.stack([x, x, x], axis=-1)
Hi, If I want to use CT scans , so the width is 128, length 128 and the depth for example 96, how can I use Resnet