Skip to content

PyTorch backend doesn't work in Kaggle notebook #150

@romanvelichkin

Description

@romanvelichkin

I'm trying to run model on Kaggle notebook using PyTorch backend. I guess notebook by defaul has both Tensorflow and PyTorch. And because of that package create tensorflow model no matter if environ set to "torch".

Code:

os.environ["KECAM_BACKEND"] = "torch"
import torch
from keras_cv_attention_models import efficientnet

model = efficientnet.EfficientNetV2B0(is_torch_mode=True,
                                      pretrained='imagenet21k', # weights pretrained on imagenet21k
                                      num_classes=num_classes,
                                      classifier_activation=activation_fn,
                                      dropout=0.25,
                                     )
print(f"{isinstance(model, torch.nn.Module) = }")

Output:

torch
>>>> Load pretrained from: /root/.keras/models/efficientnetv2-b0-21k.h5
isinstance(model, torch.nn.Module) = False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions