python_code
stringlengths
0
290k
repo_name
stringclasses
30 values
file_path
stringlengths
6
125
# flake8: noqa # There's no way to ignore "F401 '...' imported but unused" warnings in this # module, but to preserve other warnings. So, don't check this module at all. from .utils import is_inflect_available, is_transformers_available, is_unidecode_available __version__ = "0.0.4" from .modeling_utils import ModelM...
diffusers_all-main
src/diffusers/__init__.py
# coding=utf-8 # Copyright 2022 The HuggingFace Inc. team. # # 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
diffusers_all-main
src/diffusers/hub_utils.py
import copy import torch class EMAModel: """ Exponential Moving Average of models weights """ def __init__( self, model, update_after_step=0, inv_gamma=1.0, power=2 / 3, min_value=0.0, max_value=0.9999, device=None, ): """ ...
diffusers_all-main
src/diffusers/training_utils.py
# THIS FILE HAS BEEN AUTOGENERATED. To update: # 1. modify the `_deps` dict in setup.py # 2. run `make deps_table_update`` deps = { "Pillow": "Pillow", "black": "black~=22.0,>=22.3", "filelock": "filelock", "flake8": "flake8>=3.8.3", "huggingface-hub": "huggingface-hub", "isort": "isort>=5.5.4",...
diffusers_all-main
src/diffusers/dependency_versions_table.py
# coding=utf-8 # Copyright 2022 The HuggingFace Inc. team. # Copyright (c) 2022, NVIDIA CORPORATION. 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 # # http://www.a...
diffusers_all-main
src/diffusers/modeling_utils.py
# coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. # # 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
diffusers_all-main
src/diffusers/dynamic_modules_utils.py
# coding=utf-8 # Copyright 2022 The HuggingFace Inc. team. # Copyright (c) 2022, NVIDIA CORPORATION. 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 # # http://www.a...
diffusers_all-main
src/diffusers/pipeline_utils.py
from ..utils import is_inflect_available, is_transformers_available, is_unidecode_available from .bddm import BDDMPipeline from .ddim import DDIMPipeline from .ddpm import DDPMPipeline from .latent_diffusion_uncond import LatentDiffusionUncondPipeline from .pndm import PNDMPipeline from .score_sde_ve import ScoreSdeVeP...
diffusers_all-main
src/diffusers/pipelines/__init__.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
diffusers_all-main
src/diffusers/pipelines/ddim/pipeline_ddim.py
from .pipeline_ddim import DDIMPipeline
diffusers_all-main
src/diffusers/pipelines/ddim/__init__.py
# coding=utf-8 # Copyright 2022 The OpenAI Team Authors and The HuggingFace Team. 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 # # http://www.apache.org/licenses/L...
diffusers_all-main
src/diffusers/pipelines/glide/pipeline_glide.py
from ...utils import is_transformers_available if is_transformers_available(): from .pipeline_glide import CLIPTextModel, GlidePipeline
diffusers_all-main
src/diffusers/pipelines/glide/__init__.py
import torch import tqdm from ...pipeline_utils import DiffusionPipeline class LatentDiffusionUncondPipeline(DiffusionPipeline): def __init__(self, vqvae, unet, noise_scheduler): super().__init__() noise_scheduler = noise_scheduler.set_format("pt") self.register_modules(vqvae=vqvae, unet...
diffusers_all-main
src/diffusers/pipelines/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py
from .pipeline_latent_diffusion_uncond import LatentDiffusionUncondPipeline
diffusers_all-main
src/diffusers/pipelines/latent_diffusion_uncond/__init__.py
from ...utils import is_transformers_available if is_transformers_available(): from .pipeline_latent_diffusion import LatentDiffusionPipeline, LDMBertModel
diffusers_all-main
src/diffusers/pipelines/latent_diffusion/__init__.py
from typing import Optional, Tuple, Union import numpy as np import torch import torch.nn as nn import torch.utils.checkpoint import tqdm from transformers.activations import ACT2FN from transformers.configuration_utils import PretrainedConfig from transformers.modeling_outputs import BaseModelOutput from transformer...
diffusers_all-main
src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py
from .pipeline_bddm import BDDMPipeline, DiffWave
diffusers_all-main
src/diffusers/pipelines/bddm/__init__.py
#!/bin/env python # -*- coding: utf-8 -*- ######################################################################## # # DiffWave: A Versatile Diffusion Model for Audio Synthesis # (https://arxiv.org/abs/2009.09761) # Modified from https://github.com/philsyn/DiffWave-Vocoder # # Author: Max W. Y. Lam (maxwylam@tencen...
diffusers_all-main
src/diffusers/pipelines/bddm/pipeline_bddm.py
#!/usr/bin/env python3 import torch from diffusers import DiffusionPipeline # TODO(Patrick, Anton, Suraj) - rename `x` to better variable names class ScoreSdeVpPipeline(DiffusionPipeline): def __init__(self, model, scheduler): super().__init__() self.register_modules(model=model, scheduler=schedu...
diffusers_all-main
src/diffusers/pipelines/score_sde_vp/pipeline_score_sde_vp.py
from .pipeline_score_sde_vp import ScoreSdeVpPipeline
diffusers_all-main
src/diffusers/pipelines/score_sde_vp/__init__.py
from .pipeline_score_sde_ve import ScoreSdeVePipeline
diffusers_all-main
src/diffusers/pipelines/score_sde_ve/__init__.py
#!/usr/bin/env python3 import torch from diffusers import DiffusionPipeline # TODO(Patrick, Anton, Suraj) - rename `x` to better variable names class ScoreSdeVePipeline(DiffusionPipeline): def __init__(self, model, scheduler): super().__init__() self.register_modules(model=model, scheduler=schedu...
diffusers_all-main
src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
diffusers_all-main
src/diffusers/pipelines/pndm/pipeline_pndm.py
from .pipeline_pndm import PNDMPipeline
diffusers_all-main
src/diffusers/pipelines/pndm/__init__.py
""" from https://github.com/jaywalnut310/glow-tts""" import math import torch from torch import nn import tqdm from ...configuration_utils import ConfigMixin from ...modeling_utils import ModelMixin from ...pipeline_utils import DiffusionPipeline from .grad_tts_utils import GradTTSTokenizer # flake8: noqa def se...
diffusers_all-main
src/diffusers/pipelines/grad_tts/pipeline_grad_tts.py
from ...utils import is_inflect_available, is_transformers_available, is_unidecode_available if is_transformers_available() and is_unidecode_available() and is_inflect_available(): from .grad_tts_utils import GradTTSTokenizer from .pipeline_grad_tts import GradTTSPipeline, TextEncoder
diffusers_all-main
src/diffusers/pipelines/grad_tts/__init__.py
# tokenizer import os import re from shutil import copyfile import torch import inflect from transformers import PreTrainedTokenizer from unidecode import unidecode valid_symbols = [ "AA", "AA0", "AA1", "AA2", "AE", "AE0", "AE1", "AE2", "AH", "AH0", "AH1", "AH2", ...
diffusers_all-main
src/diffusers/pipelines/grad_tts/grad_tts_utils.py
from .pipeline_ddpm import DDPMPipeline
diffusers_all-main
src/diffusers/pipelines/ddpm/__init__.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
diffusers_all-main
src/diffusers/pipelines/ddpm/pipeline_ddpm.py
# coding=utf-8 # Copyright 2020 Optuna, Hugging Face # # 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
diffusers_all-main
src/diffusers/utils/logging.py
# This file is autogenerated by the command `make fix-copies`, do not edit. # flake8: noqa from ..utils import DummyObject, requires_backends class GlideSuperResUNetModel(metaclass=DummyObject): _backends = ["transformers"] def __init__(self, *args, **kwargs): requires_backends(self, ["transformers"]...
diffusers_all-main
src/diffusers/utils/dummy_transformers_objects.py
# Copyright 2021 The HuggingFace Inc. team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
diffusers_all-main
src/diffusers/utils/__init__.py
# This file is autogenerated by the command `make fix-copies`, do not edit. # flake8: noqa from ..utils import DummyObject, requires_backends class GradTTSPipeline(metaclass=DummyObject): _backends = ["transformers", "inflect", "unidecode"] def __init__(self, *args, **kwargs): requires_backends(self,...
diffusers_all-main
src/diffusers/utils/dummy_transformers_and_inflect_and_unidecode_objects.py
import math from inspect import isfunction import torch import torch.nn.functional as F from torch import nn # unet_grad_tts.py # TODO(Patrick) - weird linear attention layer. Check with: https://github.com/huawei-noah/Speech-Backbones/issues/15 class LinearAttention(torch.nn.Module): def __init__(self, dim, hea...
diffusers_all-main
src/diffusers/models/attention.py
import torch from ..configuration_utils import ConfigMixin from ..modeling_utils import ModelMixin from .attention import LinearAttention from .embeddings import get_timestep_embedding from .resnet import Downsample2D, ResnetBlock2D, Upsample2D from .unet_new import UNetMidBlock2D class Mish(torch.nn.Module): de...
diffusers_all-main
src/diffusers/models/unet_grad_tts.py
import torch import torch.nn as nn import torch.nn.functional as F from ..configuration_utils import ConfigMixin from ..modeling_utils import ModelMixin from .attention import AttentionBlock from .embeddings import get_timestep_embedding from .resnet import Downsample2D, ResnetBlock2D, Upsample2D from .unet_new import...
diffusers_all-main
src/diffusers/models/unet_glide.py
# model adapted from diffuser https://github.com/jannerm/diffuser/blob/main/diffuser/models/temporal.py import torch import torch.nn as nn from ..configuration_utils import ConfigMixin from ..modeling_utils import ModelMixin from .embeddings import get_timestep_embedding from .resnet import Downsample1D, ResidualTemp...
diffusers_all-main
src/diffusers/models/unet_rl.py
import torch import torch.nn as nn from ..configuration_utils import ConfigMixin from ..modeling_utils import ModelMixin from .attention import AttentionBlock from .embeddings import get_timestep_embedding from .resnet import Downsample2D, ResnetBlock2D, Upsample2D from .unet_new import UNetMidBlock2D, get_down_block,...
diffusers_all-main
src/diffusers/models/unet_unconditional.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
diffusers_all-main
src/diffusers/models/unet.py
# flake8: noqa # There's no way to ignore "F401 '...' imported but unused" warnings in this # module, but to preserve other warnings. So, don't check this module at all. # Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use thi...
diffusers_all-main
src/diffusers/models/__init__.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
diffusers_all-main
src/diffusers/models/embeddings.py
from functools import partial import numpy as np import torch import torch.nn as nn import torch.nn.functional as F class Upsample2D(nn.Module): """ An upsampling layer with an optional convolution. :param channels: channels in the inputs and outputs. :param use_conv: a bool determining if a convolution...
diffusers_all-main
src/diffusers/models/resnet.py
import math from inspect import isfunction import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from ..configuration_utils import ConfigMixin from ..modeling_utils import ModelMixin from .attention import AttentionBlock from .embeddings import get_timestep_embedding from .resnet impor...
diffusers_all-main
src/diffusers/models/unet_ldm.py
import numpy as np import torch import torch.nn as nn from ..configuration_utils import ConfigMixin from ..modeling_utils import ModelMixin from .attention import AttentionBlock from .resnet import Downsample2D, ResnetBlock2D, Upsample2D def nonlinearity(x): # swish return x * torch.sigmoid(x) def Normaliz...
diffusers_all-main
src/diffusers/models/vae.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
diffusers_all-main
src/diffusers/models/unet_sde_score_estimation.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
diffusers_all-main
src/diffusers/models/unet_new.py
# Copyright 2022 UC Berkely Team and The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
diffusers_all-main
src/diffusers/schedulers/scheduling_ddpm.py
# Copyright 2022 Google Brain and The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requ...
diffusers_all-main
src/diffusers/schedulers/scheduling_sde_vp.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
diffusers_all-main
src/diffusers/schedulers/scheduling_grad_tts.py
# flake8: noqa # There's no way to ignore "F401 '...' imported but unused" warnings in this # module, but to preserve other warnings. So, don't check this module at all. # Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use thi...
diffusers_all-main
src/diffusers/schedulers/__init__.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
diffusers_all-main
src/diffusers/schedulers/scheduling_utils.py
# Copyright 2022 Google Brain and The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requ...
diffusers_all-main
src/diffusers/schedulers/scheduling_sde_ve.py
# Copyright 2022 Stanford University Team and The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # #...
diffusers_all-main
src/diffusers/schedulers/scheduling_ddim.py
# Copyright 2022 Zhejiang University Team and The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # #...
diffusers_all-main
src/diffusers/schedulers/scheduling_pndm.py
from setuptools import setup, find_packages with open("requirements.txt", "r") as f: requirements = f.read().splitlines() setup(name="huggan", install_requires=requirements, packages=find_packages())
community-events-main
setup.py
from pathlib import Path TEMPLATE_MODEL_CARD_PATH = Path(__file__).parent.absolute() / 'model_card_template.md'
community-events-main
huggan/__init__.py
import argparse from datasets import load_dataset from tqdm import tqdm # choose a dataset available_datasets = ["apple2orange", "summer2winter_yosemite", "horse2zebra", "monet2photo", "cezanne2photo", "ukiyoe2photo", "vangogh2photo", "maps", "cityscapes", "facades", "iphone2dslr_flower", "ae_photos", "grumpifycat"] ...
community-events-main
huggan/utils/push_to_hub_example.py
community-events-main
huggan/utils/__init__.py
from typing import Optional from huggingface_hub import HfFolder, whoami def get_full_repo_name(model_id: str, organization: Optional[str] = None, token: Optional[str] = None): if token is None: token = HfFolder.get_token() if organization is None: username = whoami(token)["name"] retu...
community-events-main
huggan/utils/hub.py
community-events-main
huggan/tensorflow/dcgan/__init__.py
import tensorflow as tf import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from pathlib import Path import os import PIL from tqdm.auto import tqdm import argparse from tensorflow.keras import layers from datasets import load_dataset from transformers import DefaultDataCollator from huggingfa...
community-events-main
huggan/tensorflow/dcgan/train.py
community-events-main
huggan/pytorch/__init__.py
from pathlib import Path from re import TEMPLATE from typing import Optional, Union import os from huggingface_hub import PyTorchModelHubMixin, HfApi, HfFolder, Repository from huggan import TEMPLATE_MODEL_CARD_PATH class HugGANModelHubMixin(PyTorchModelHubMixin): """A mixin to push PyTorch Models to the Huggin...
community-events-main
huggan/pytorch/huggan_mixin.py
community-events-main
huggan/pytorch/metrics/__init__.py
import torch import torch.nn as nn import torch.nn.functional as F import torchvision try: from torchvision.models.utils import load_state_dict_from_url except ImportError: from torch.utils.model_zoo import load_url as load_state_dict_from_url # Inception weights ported to Pytorch from # http://download.tenso...
community-events-main
huggan/pytorch/metrics/inception.py
# sources: # https://www.kaggle.com/code/ibtesama/gan-in-pytorch-with-fid/notebook # https://github.com/mseitzer/pytorch-fid/blob/master/src/pytorch_fid/fid_score.py import numpy as np from scipy import linalg from torch.nn.functional import adaptive_avg_pool2d def calculate_activation_statistics(images, model, bat...
community-events-main
huggan/pytorch/metrics/fid_score.py
community-events-main
huggan/pytorch/dcgan/__init__.py
#!/usr/bin/env python # coding=utf-8 # Copyright (c) 2022 PyTorch contributors and The HuggingFace Inc. team. 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 # # http...
community-events-main
huggan/pytorch/dcgan/modeling_dcgan.py
#!/usr/bin/env python # coding=utf-8 # Copyright (c) 2022 PyTorch contributors and The HuggingFace Inc. team. 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 # # http...
community-events-main
huggan/pytorch/dcgan/train.py
import random import torch import torch.nn.functional as F def DiffAugment(x, types=[]): for p in types: for f in AUGMENT_FNS[p]: x = f(x) return x.contiguous() # """ # Augmentation functions got images as `x` # where `x` is tensor with this dimensions: # 0 - count of images # 1 - chann...
community-events-main
huggan/pytorch/lightweight_gan/diff_augment.py
community-events-main
huggan/pytorch/lightweight_gan/__init__.py
import fire import random from retry.api import retry_call from tqdm import tqdm from datetime import datetime from pathlib import Path from lightweight_gan import Trainer, NanException import torch import torch.multiprocessing as mp import numpy as np def exists(val): return val is not None def default(val, d)...
community-events-main
huggan/pytorch/lightweight_gan/cli.py
import os import json import tempfile from random import random import math from math import log2, floor from pathlib import Path from functools import partial from contextlib import contextmanager, ExitStack from pathlib import Path from shutil import rmtree import torch from torch.optim import Adam from torch import...
community-events-main
huggan/pytorch/lightweight_gan/lightweight_gan.py
community-events-main
huggan/pytorch/cyclegan/__init__.py
import random import time import datetime import sys from torch.autograd import Variable import torch import numpy as np from torchvision.utils import save_image class ReplayBuffer: def __init__(self, max_size=50): assert max_size > 0, "Empty buffer or trying to create a black hole. Be careful." ...
community-events-main
huggan/pytorch/cyclegan/utils.py
import argparse import os import numpy as np import itertools from pathlib import Path import datetime import time import sys from PIL import Image from torchvision.transforms import Compose, Resize, ToTensor, Normalize, RandomCrop, RandomHorizontalFlip from torchvision.utils import save_image, make_grid from torch....
community-events-main
huggan/pytorch/cyclegan/train.py
import torch.nn as nn import torch.nn.functional as F import torch from huggan.pytorch.huggan_mixin import HugGANModelHubMixin ############################## # RESNET ############################## class ResidualBlock(nn.Module): def __init__(self, in_features): super(ResidualBlock, self).__i...
community-events-main
huggan/pytorch/cyclegan/modeling_cyclegan.py
#!/usr/bin/env python # coding=utf-8 # Copyright (c) 2022 Erik Linder-Norén and The HuggingFace Inc. team. 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 # # http://...
community-events-main
huggan/pytorch/pix2pix/modeling_pix2pix.py
community-events-main
huggan/pytorch/pix2pix/__init__.py
#!/usr/bin/env python # coding=utf-8 # Copyright (c) 2022 Erik Linder-Norén and The HuggingFace Inc. team. 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 # # http://...
community-events-main
huggan/pytorch/pix2pix/train.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE...
community-events-main
whisper-fine-tuning-event/run_speech_recognition_seq2seq_streaming.py
import argparse from transformers import pipeline from transformers.models.whisper.english_normalizer import BasicTextNormalizer from datasets import load_dataset, Audio import evaluate wer_metric = evaluate.load("wer") def is_target_text_in_range(ref): if ref.strip() == "ignore time segment in scoring": ...
community-events-main
whisper-fine-tuning-event/run_eval_whisper_streaming.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. 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 # # http://www.apache.org/licenses/LI...
community-events-main
jax-controlnet-sprint/training_scripts/train_controlnet_flax.py
import os import datasets import pandas as pd _VERSION = datasets.Version("0.0.2") _DESCRIPTION = "TODO" _HOMEPAGE = "TODO" _LICENSE = "TODO" _CITATION = "TODO" _FEATURES = datasets.Features( { "image": datasets.Image(), "conditioning_image": datasets.Image(), "text": datasets.Value("str...
community-events-main
jax-controlnet-sprint/dataset_tools/data.py
import argparse import logging import random import cv2 import jsonlines import numpy as np import requests from datasets import load_dataset from PIL import Image logger = logging.getLogger(__name__) def parse_args(): parser = argparse.ArgumentParser( description="Example of a data preprocessing script...
community-events-main
jax-controlnet-sprint/dataset_tools/coyo_1m_dataset_preprocess.py
# Copyright 2021 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
setup.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
tests/test_big_modeling.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
tests/test_optimizer.py
# Copyright 2021 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
tests/test_data_loader.py
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class MockLaunchConfig(SageMakerConfig): compute_environment = ...
accelerate-main
tests/test_sagemaker.py
# Copyright 2021 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
tests/test_utils.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
tests/test_cpu.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
tests/test_memory_utils.py
# Copyright 2021 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
tests/test_metrics.py
# Copyright 2021 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
tests/test_kwargs_handlers.py
# Copyright 2021 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
tests/test_scheduler.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
tests/test_modeling_utils.py
import json import os import pickle import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state import Gradient...
accelerate-main
tests/test_accelerator.py
# Copyright 2022 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
tests/test_tracking.py
# Copyright 2023 The HuggingFace Team. 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate-main
tests/test_quantization.py