Releases: hankyul2/EfficientNetV2-pytorch
Releases · hankyul2/EfficientNetV2-pytorch
Release v1.0.1-2021.12.26
Release model weight fine-tuned on CIFAR
This release includes fine-tuned model weights.
you can use model weights using below command
import torch
model_name = 'efficientnet_v2_s'
weight_path = 'efficientnet_v2_s_cifar100.pth'
model = torch.hub.load('hankyul2/EfficientNetV2-pytorch', model_name, nclass=100, skip_validation=True)
model.load_state_dict(torch.load(weight_path))
v1.0.0-2021.11.13
EfficientNetV2 Numpy weights (Converted from official tensorflow weights)
This release contains efficientnetv2 numpy weights converted from official tensorflow checkpoint. We just download checkpoint from official repo and convert trainable parameters to numpy array without changing any parameters.
How do we convert to numpy format
import os
import shutil
import subprocess
import tensorflow as tf
def download_from_url_and_convert_to_numpy(url, file_name):
subprocess.run(["wget", "-r", "-nc", '-O', file_name, url])
shutil.unpack_archive(file_name)
ckpt_path = os.path.splitext(file_name)[0]
pretrained_ckpt = tf.train.latest_checkpoint(ckpt_path)
np.save(f"{ckpt_path}.npy",
{'/'.join(name.split('/')[1:]): np.array(tf.train.load_variable(ckpt_path, name)) for name, shape in
tf.train.list_variables(pretrained_ckpt)})
url = "https://storage.googleapis.com/cloud-tpu-checkpoints/efficientnet/v2/efficientnetv2-s.tgz"
file_name = "efficientnet_v2.tgz"
download_from_url_and_convert_to_numpy(url, file_name)
How to see variable name and shape
import numpy as np
weight = np.load('efficientnetv2-s.npy', allow_pickle=True).item()
for k, v in weight.items():
print(k, v.shape)
Below links are official tensorflow ckpt download link (got from here)