CoolFace
Apppublic

declare-lab/tango2

sourceHugging Faceupdated 2y agoView on Hugging Face
92likes
test_hub_utils.py52 linesDownload Raw Back to tests
1# coding=utf-82# Copyright 2023 HuggingFace Inc.3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7#8#     http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.15import unittest16from pathlib import Path17from tempfile import TemporaryDirectory18from unittest.mock import Mock, patch19 20import diffusers.utils.hub_utils21 22 23class CreateModelCardTest(unittest.TestCase):24    @patch("diffusers.utils.hub_utils.get_full_repo_name")25    def test_create_model_card(self, repo_name_mock: Mock) -> None:26        repo_name_mock.return_value = "full_repo_name"27        with TemporaryDirectory() as tmpdir:28            # Dummy args values29            args = Mock()30            args.output_dir = tmpdir31            args.local_rank = 032            args.hub_token = "hub_token"33            args.dataset_name = "dataset_name"34            args.learning_rate = 0.0135            args.train_batch_size = 10000036            args.eval_batch_size = 1000037            args.gradient_accumulation_steps = 0.0138            args.adam_beta1 = 0.0239            args.adam_beta2 = 0.0340            args.adam_weight_decay = 0.000541            args.adam_epsilon = 0.00000142            args.lr_scheduler = 143            args.lr_warmup_steps = 1044            args.ema_inv_gamma = 0.00145            args.ema_power = 0.146            args.ema_max_decay = 0.247            args.mixed_precision = True48 49            # Model card mush be rendered and saved50            diffusers.utils.hub_utils.create_model_card(args, model_name="model_name")51            self.assertTrue((Path(tmpdir) / "README.md").is_file())52