This file contains hidden or 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 torch | |
import sys | |
import torch | |
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoImageProcessor | |
def load_model_auto(model_path): | |
dtype = torch.float16 | |
model = AutoModelForCausalLM.from_pretrained( | |
model_path, torch_dtype=dtype, trust_remote_code=True, device_map="cuda" |
This file contains hidden or 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
// Copyright 2019 The Flutter Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style license that can be | |
// found in the LICENSE file. | |
import 'package:flutter/material.dart'; | |
import 'package:animations/animations.dart'; | |
const String _loremIpsumParagraph = | |
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod ' | |
'tempor incididunt ut labore et dolore magna aliqua. Vulputate dignissim ' |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
# file: models.py | |
# author: JinTian | |
# time: 11/05/2017 3:03 PM | |
# Copyright 2017 JinTian. All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# |
This file contains hidden or 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 os | |
import sys | |
import numpy as np | |
import tensorflow as tf | |
import logging | |
logging.basicConfig(level=logging.DEBUG, | |
format='%(asctime)s %(filename)s line:%(lineno)d %(levelname)s %(message)s', | |
datefmt='%Y-%m-%d %H:%M:%S') |
This file contains hidden or 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
logging.basicConfig(level=logging.DEBUG, | |
format='%(asctime)s %(filename)s line:%(lineno)d %(levelname)s %(message)s', | |
datefmt='%a, %d %b %Y %H:%M:%S') |
This file contains hidden or 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 torch | |
def load_previous_model(encoder, decoder, checkpoint_dir, model_prefix): | |
""" | |
this can generally used in PyTorch to load previous model, | |
this function will find max epoch from checkpoints dir, for other models | |
just change model load format. | |
:param encoder: | |
:param decoder: |
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
# file: notebook_to_python.py | |
# author: JinTian | |
# time: 09/05/2017 3:28 PM | |
# Copyright 2017 JinTian. All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# |