-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add swinv2_loader into libai #353
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
测试代码: import logging
import os
import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
from libai.config import LazyConfig, default_argument_parser, try_get_key
from configs.common.models.swinv2.swinv2_tiny_patch4_window8_256 import cfg as model_cfg
from libai.engine import DefaultTrainer, default_setup
from libai.utils.checkpoint import Checkpointer
from libai.models.utils import SwinV2LoaderHuggerFace
from libai.models import SwinTransformerV2
logger = logging.getLogger("libai." + __name__)
def main(args):
cfg = LazyConfig.load(args.config_file)
cfg = LazyConfig.apply_overrides(cfg, args.opts)
default_setup(cfg, args)
if args.fast_dev_run:
cfg.train.train_epoch = 0
cfg.train.train_iter = 20
cfg.train.evaluation.eval_period = 10
cfg.train.log_period = 1
if args.eval_only:
tokenizer = None
if try_get_key(cfg, "tokenization") is not None:
tokenizer = DefaultTrainer.build_tokenizer(cfg)
loader = SwinV2LoaderHuggerFace(
SwinTransformerV2,
model_cfg,
"/root/.cache/huggingface/hub/models--microsoft--swinv2-tiny-patch4-window8-256/snapshots/2b979ac403df19f72443cd151e9e957842eb9645",
)
model = loader.load()
if try_get_key(cfg, "train.graph.enabled", default=False):
model = DefaultTrainer.build_graph(cfg, model, is_train=False)
test_loader = DefaultTrainer.build_test_loader(cfg, tokenizer)
if len(test_loader) == 0:
logger.info("No dataset in dataloader.test, please set dataset for dataloader.test")
_ = DefaultTrainer.test(cfg, test_loader, model)
return
trainer = DefaultTrainer(cfg)
return trainer.train()
if __name__ == "__main__":
args = default_argument_parser().parse_args()
main(args) 脚本命令:
因此对齐了 |
shaoshitong
force-pushed
the
add_swinv2_loader_to_libai
branch
from
August 12, 2022 16:16
d943c3c
to
8ca9cac
Compare
shaoshitong
requested review from
xiezipeng-ML and
oneflow-ci-bot
and removed request for
oneflow-ci-bot
August 12, 2022 16:16
shaoshitong
requested review from
zhanggj821,
13136983989 and
oneflow-ci-bot
and removed request for
oneflow-ci-bot and
13136983989
August 14, 2022 12:03
添加一下测试,类似于swin的这个,其中allclose的数值需要由huggingface模型得到 |
shaoshitong
force-pushed
the
add_swinv2_loader_to_libai
branch
from
August 15, 2022 04:26
14a3e9e
to
bf79b1e
Compare
shaoshitong
requested review from
oneflow-ci-bot
and removed request for
oneflow-ci-bot
August 15, 2022 04:26
已经添加 |
shaoshitong
requested review from
oneflow-ci-bot
and removed request for
oneflow-ci-bot
August 15, 2022 04:27
xiezipeng-ML
requested review from
oneflow-ci-bot
and removed request for
oneflow-ci-bot
August 15, 2022 07:53
xiezipeng-ML
requested review from
oneflow-ci-bot
and removed request for
oneflow-ci-bot
August 15, 2022 07:54
xiezipeng-ML
approved these changes
Aug 15, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
add swinv2_loader into libai, make it can load huggingface's weight into libai