python_code stringlengths 0 4.04M | repo_name stringlengths 7 58 | file_path stringlengths 5 147 |
|---|---|---|
import logging
import os
import pdb
from copy import deepcopy
import yaml
import globals
from globals import *
from lbt.utils.experiment_utils import load_yaml
template = load_yaml(CONFIG_TEMPLATE_FILE)
dataset_metadata = load_yaml(DATASET_METADATA_FILE)
hyperopt_config = load_yaml(HYPEROPT_CONFIG_FILE)
def inser... | ludwig-benchmarking-toolkit-main | lbt/build_def_files.py |
import argparse
import datetime
import logging
import os
import pickle
import socket
from typing import Union
from collections import defaultdict
import numpy as np
import ray
import globals
from .build_def_files import *
from database import save_results_to_es
from ludwig.hyperopt.run import hyperopt
from lbt.utils.... | ludwig-benchmarking-toolkit-main | lbt/experiments.py |
import datetime
import os
import shutil
import tempfile
import GPUtil
import ludwig
import numpy as np
import pandas as pd
import psutil
import ray
from experiment_impact_tracker.compute_tracker import ImpactTracker
from experiment_impact_tracker.data_interface import DataInterface
from globals import ENERGY_LOGGING_D... | ludwig-benchmarking-toolkit-main | lbt/metrics/lbt_metrics.py |
from lbt.metrics.base_metric import LBTMetric
import ray
import importlib
import sys
import json
import os
LOCATION = os.path.abspath(os.path.dirname(__file__))
INSTANCE_PRICES_FILEPATH = os.path.join(LOCATION, "instance_prices.json")
METRIC_REGISTERY = {}
INSTANCE_PRICES = {}
def register_metric(name):
"""
... | ludwig-benchmarking-toolkit-main | lbt/metrics/__init__.py |
import abc
from abc import ABC, ABCMeta, abstractmethod
from typing import Tuple, Union
import pandas as pd
from ludwig.api import LudwigModel
class LBTMetric(ABC):
def __init__(self):
super().__init__()
@classmethod
def run(cls, model_path, dataset_path, train_batch_size, run_stats):
pa... | ludwig-benchmarking-toolkit-main | lbt/metrics/base_metric.py |
def scale_bytes(bytes: int, suffix: str = "B") -> str:
factor = 1024
for unit in ["", "K", "M", "G", "T", "P"]:
if bytes < factor:
return f"{bytes:.2f}{unit}{suffix}"
bytes /= factor
| ludwig-benchmarking-toolkit-main | lbt/metrics/utils.py |
ludwig-benchmarking-toolkit-main | lbt/tools/__init__.py | |
from lbt.utils.experiment_utils import load_yaml
from globals import DATASET_METADATA_FILE
from lbt.datasets import DATASET_REGISTRY
def get_dataset_features(dataset_name):
if dataset_name not in DATASET_REGISTRY:
raise ValueError(
f"{dataset_name} not found in dataset registry\n"
... | ludwig-benchmarking-toolkit-main | lbt/tools/utils.py |
from lbt.tools.robustnessgym.base_subpopulation import BaseSubpopulation
from lbt.tools.robustnessgym import register_lbtsubpop
from robustnessgym import (
LengthSubpopulation,
HasPhrase,
HasAnyPhrase,
)
import requests
from robustnessgym import Spacy
from robustnessgym import ScoreSubpopulation, Identifi... | ludwig-benchmarking-toolkit-main | lbt/tools/robustnessgym/lbt_subpopulations.py |
RGSUBPOPULATION_REGISTRY = {}
import importlib
import sys
import inspect
from .base_subpopulation import BaseSubpopulation
from .robustnessgym import RG
from robustnessgym.slicebuilders.subpopulation import Subpopulation
# from lbt.tools.robustnessgym imort RG
def register_lbtsubpop(name):
def register_subpop_... | ludwig-benchmarking-toolkit-main | lbt/tools/robustnessgym/__init__.py |
import abc
from abc import ABC
import pandas as pd
class BaseSubpopulation(ABC):
def __init__(self, name):
self.name = name
@abc.abstractmethod
def score_fn(self):
""" scores a sample based on subpopulation the sample is a part of """
raise NotImplementedError()
@abc.abstract... | ludwig-benchmarking-toolkit-main | lbt/tools/robustnessgym/base_subpopulation.py |
import os
from functools import partial
from typing import Union
import numpy as np
import pandas as pd
from lbt.datasets import DATASET_REGISTRY
from lbt.tools.robustnessgym import RGSUBPOPULATION_REGISTRY
from ludwig.api import LudwigModel
from lbt.tools.utils import get_dataset_features
from robustnessgym import D... | ludwig-benchmarking-toolkit-main | lbt/tools/robustnessgym/robustnessgym.py |
import inspect
import sys
import os
import pandas as pd
from pandas.core.common import SettingWithCopyWarning
import warnings
warnings.simplefilter(action="ignore", category=SettingWithCopyWarning)
from ludwig.api import LudwigModel
from textattack.attack_recipes import AttackRecipe
from textattack.attack_results ... | ludwig-benchmarking-toolkit-main | lbt/tools/textattack/textattack.py |
from .textattack import (
attack,
augment,
ATTACKRECIPE_REGISTRY,
AUGMENTATIONRECIPE_REGISTRY,
)
| ludwig-benchmarking-toolkit-main | lbt/tools/textattack/__init__.py |
from ludwig.datasets.base_dataset import BaseDataset, DEFAULT_CACHE_LOCATION
import abc
import pandas as pd
class LBTDataset(BaseDataset):
"""Base LBT Dataset -- subclass wrapper around Ludwig data class"""
def __init__(self, dataset_name, processed_file_name, cache_dir):
self.name = dataset_name
... | ludwig-benchmarking-toolkit-main | lbt/datasets/base_dataset.py |
import importlib
import inspect
from lbt.datasets.base_dataset import LBTDataset
from ludwig.datasets.base_dataset import BaseDataset
DATASET_REGISTRY = {}
def register_dataset(name):
"""
New dataset types can be added to LBT with the `register_dataset`
function decorator.
:
@register_datase... | ludwig-benchmarking-toolkit-main | lbt/datasets/__init__.py |
import os
import pdb
import pandas as pd
from lbt.datasets import register_dataset
from lbt.datasets.base_dataset import LBTDataset
@register_dataset("toy_agnews")
class ToyAGNews(LBTDataset):
def __init__(
self,
dataset_name="toy_agnews",
processed_file_name="toy_agnews.csv",
cach... | ludwig-benchmarking-toolkit-main | lbt/datasets/toy_datasets.py |
import base64
import copy
import hashlib
import json
import logging
import math
import os
from typing import Union
from lbt.datasets import build_dataset
from lbt.metrics import get_experiment_metadata
import globals
import pandas as pd
import yaml
def get_gpu_list():
try:
return os.environ["CUDA_VISIBLE... | ludwig-benchmarking-toolkit-main | lbt/utils/experiment_utils.py |
from metadata_utils import *
DATAPATH = "/sailhome/avanika/.ludwig_cache/sst2_1.0/processed/sst2.csv"
MODEL_PATH = "/juice/scr/avanika/ludwig-benchmark-dev/ludwig-benchmark/experiment-outputs/sst2_bert/hyperopt_0_config_sst2_bert/model"
machine_info = get_hardware_metadata()
print(machine_info)
#model_flops = model_... | ludwig-benchmarking-toolkit-main | lbt/utils/test_utils.py |
import datetime
import os
import platform
import GPUtil
import ludwig
import numpy as np
import pandas as pd
import psutil
import ray
import tensorflow as tf
from ludwig.api import LudwigModel
from ludwig.collect import collect_weights
@ray.remote
def get_ludwig_version(**kwargs):
return ludwig.__version__
def... | ludwig-benchmarking-toolkit-main | lbt/utils/metadata_utils.py |
from .visualize import (
hyperopt_viz,
compare_performance_viz,
learning_curves_viz,
)
| ludwig-benchmarking-toolkit-main | lbt/visualizations/__init__.py |
import os
from typing import List, Union
import globals
import json
import pickle
from lbt.datasets import DATASET_REGISTRY
from ludwig.visualize import (
compare_performance,
hyperopt_report,
learning_curves,
)
def hyperopt_viz(
hyperopt_stats_path: str = None,
dataset_name: str = None,
mode... | ludwig-benchmarking-toolkit-main | lbt/visualizations/visualize.py |
import time
import torch
from diffusers import StableDiffusionPipeline
import functools
import argparse
# torch disable grad
torch.set_grad_enabled(False)
torch.manual_seed(1231)
torch.cuda.manual_seed(1231)
prompt = "a photo of an astronaut riding a horse on mars"
# cudnn benchmarking
torch.backends.cudnn.benchmar... | diffusers-main | test.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-main | setup.py |
# coding=utf-8
# Copyright 2022 HuggingFace Inc.
#
# 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 or ag... | diffusers-main | tests/test_modeling_common.py |
# coding=utf-8
# Copyright 2022 HuggingFace Inc.
#
# 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 or ag... | diffusers-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... | diffusers-main | tests/conftest.py |
import unittest
from diffusers import FlaxAutoencoderKL
from diffusers.utils import is_flax_available
from diffusers.utils.testing_utils import require_flax
from .test_modeling_common_flax import FlaxModelTesterMixin
if is_flax_available():
import jax
@require_flax
class FlaxAutoencoderKLTests(FlaxModelTester... | diffusers-main | tests/test_models_vae_flax.py |
# coding=utf-8
# Copyright 2022 HuggingFace Inc.
#
# 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 or ag... | diffusers-main | tests/test_pipelines.py |
diffusers-main | tests/__init__.py | |
# coding=utf-8
# Copyright 2022 HuggingFace Inc.
#
# 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 or ag... | diffusers-main | tests/test_scheduler.py |
# coding=utf-8
# Copyright 2022 HuggingFace Inc.
#
# 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 or ag... | diffusers-main | tests/test_models_vq.py |
# coding=utf-8
# Copyright 2022 HuggingFace Inc.
#
# 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 or ag... | diffusers-main | tests/test_models_unet.py |
from diffusers.utils import is_flax_available
from diffusers.utils.testing_utils import require_flax
if is_flax_available():
import jax
@require_flax
class FlaxModelTesterMixin:
def test_output(self):
init_dict, inputs_dict = self.prepare_init_args_and_inputs_for_common()
model = self.model... | diffusers-main | tests/test_modeling_common_flax.py |
# coding=utf-8
# Copyright 2022 HuggingFace Inc.
#
# 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 or ag... | diffusers-main | tests/test_training.py |
# coding=utf-8
# Copyright 2022 HuggingFace Inc.
#
# 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 or ag... | diffusers-main | tests/test_layers_utils.py |
# coding=utf-8
# Copyright 2022 HuggingFace Inc.
#
# 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 or ag... | diffusers-main | tests/test_config.py |
# coding=utf-8
# Copyright 2022 HuggingFace Inc.
#
# 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 or ag... | diffusers-main | tests/test_pipelines_flax.py |
import unittest
from dataclasses import dataclass
from typing import List, Union
import numpy as np
import PIL.Image
from diffusers.utils.outputs import BaseOutput
@dataclass
class CustomOutput(BaseOutput):
images: Union[List[PIL.Image.Image], np.ndarray]
class ConfigTester(unittest.TestCase):
def test_ou... | diffusers-main | tests/test_outputs.py |
# coding=utf-8
# Copyright 2022 HuggingFace Inc.
#
# 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 or ag... | diffusers-main | tests/test_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-main | tests/fixtures/custom_pipeline/pipeline.py |
# Copyright 2022 The HuggingFace Team, the AllenNLP library authors. 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-main | utils/stale.py |
#!/usr/bin/env python3
# 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
#
# Unles... | diffusers-main | utils/print_env.py |
# coding=utf-8
# Copyright 2020 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-main | utils/check_dummies.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-main | utils/check_config_docstrings.py |
# coding=utf-8
# Copyright 2020 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-main | utils/check_inits.py |
# coding=utf-8
# Copyright 2020 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-main | utils/check_copies.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-main | utils/custom_init_isort.py |
# coding=utf-8
# Copyright 2020 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-main | utils/check_repo.py |
# coding=utf-8
# Copyright 2020 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-main | utils/check_table.py |
# coding=utf-8
# Copyright 2020 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-main | utils/get_modified_files.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-main | examples/conftest.py |
# coding=utf-8
# Copyright 2022 HuggingFace Inc..
#
# 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 or a... | diffusers-main | examples/test_examples.py |
import argparse
import math
import os
import torch
import torch.nn.functional as F
from accelerate import Accelerator
from accelerate.logging import get_logger
from datasets import load_dataset
from diffusers import DDPMPipeline, DDPMScheduler, UNet2DModel
from diffusers.hub_utils import init_git_repo
from diffusers.... | diffusers-main | examples/unconditional_image_generation/train_unconditional.py |
import argparse
import itertools
import math
import os
import random
from pathlib import Path
from typing import Optional
import numpy as np
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
from torch.utils.data import Dataset
import PIL
from accelerate import Accelerator
from accelerate.log... | diffusers-main | examples/textual_inversion/textual_inversion.py |
import argparse
import logging
import math
import os
import random
from pathlib import Path
from typing import Iterable, Optional
import numpy as np
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
from accelerate import Accelerator
from accelerate.logging import get_logger
from accelerate.u... | diffusers-main | examples/text_to_image/train_text_to_image.py |
import warnings
from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401
warnings.warn(
"The `inpainting.py` script is outdated. Please use directly `from diffusers import"
" StableDiffusionInpaintPipeline` instead."
)
| diffusers-main | examples/inference/inpainting.py |
import warnings
from diffusers import StableDiffusionImg2ImgPipeline # noqa F401
warnings.warn(
"The `image_to_image.py` script is outdated. Please use directly `from diffusers import"
" StableDiffusionImg2ImgPipeline` instead."
)
| diffusers-main | examples/inference/image_to_image.py |
import argparse
import math
import os
from pathlib import Path
from typing import Optional
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
from torch.utils.data import Dataset
from accelerate import Accelerator
from accelerate.logging import get_logger
from accelerate.utils import set_seed
... | diffusers-main | examples/dreambooth/train_dreambooth.py |
#!/usr/bin/env python3
import torch
from diffusers import DiffusionPipeline
class UnetSchedulerOneForwardPipeline(DiffusionPipeline):
def __init__(self, unet, scheduler):
super().__init__()
self.register_modules(unet=unet, scheduler=scheduler)
def __call__(self):
image = torch.randn... | diffusers-main | examples/community/one_step_unet.py |
import inspect
from typing import List, Optional, Union
import torch
from torch import nn
from torch.nn import functional as F
from diffusers import AutoencoderKL, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, UNet2DConditionModel
from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion import St... | diffusers-main | examples/community/clip_guided_stable_diffusion.py |
from typing import Any, Callable, Dict, List, Optional, Union
import torch
import PIL.Image
from diffusers import (
AutoencoderKL,
DDIMScheduler,
DiffusionPipeline,
LMSDiscreteScheduler,
PNDMScheduler,
StableDiffusionImg2ImgPipeline,
StableDiffusionInpaintPipeline,
StableDiffusionPipel... | diffusers-main | examples/community/stable_diffusion_mega.py |
import inspect
import time
from pathlib import Path
from typing import Callable, List, Optional, Union
import numpy as np
import torch
from diffusers.configuration_utils import FrozenDict
from diffusers.models import AutoencoderKL, UNet2DConditionModel
from diffusers.pipeline_utils import DiffusionPipeline
from diffu... | diffusers-main | examples/community/interpolate_stable_diffusion.py |
import argparse
import torch
import OmegaConf
from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel
def convert_ldm_original(checkpoint_path, config_path, output_path):
config = OmegaConf.load(config_path)
state_dict = torch.load(checkpoint_path, map_location="cpu")["model"]
keys = lis... | diffusers-main | scripts/conversion_ldm_uncond.py |
# Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint.
# *Only* converts the UNet, VAE, and Text Encoder.
# Does not convert optimizer state or any other thing.
import argparse
import os.path as osp
import torch
# =================#
# UNet Conversion #
# =================#
unet_con... | diffusers-main | scripts/convert_diffusers_to_original_stable_diffusion.py |
diffusers-main | scripts/__init__.py | |
import argparse
import json
import torch
from diffusers import AutoencoderKL, DDPMPipeline, DDPMScheduler, UNet2DModel, VQModel
def shave_segments(path, n_shave_prefix_segments=1):
"""
Removes segments. Positive values shave the first segments, negative shave the last segments.
"""
if n_shave_prefix... | diffusers-main | scripts/convert_ddpm_original_checkpoint_to_diffusers.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-main | scripts/convert_ldm_original_checkpoint_to_diffusers.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-main | scripts/convert_stable_diffusion_checkpoint_to_onnx.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-main | scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py |
import random
import torch
from diffusers import UNet2DModel
from huggingface_hub import HfApi
api = HfApi()
results = {}
# fmt: off
results["google_ddpm_cifar10_32"] = torch.tensor([
-0.7515, -1.6883, 0.2420, 0.0300, 0.6347, 1.3433, -1.1743, -3.7467,
1.2342, -2.2485, 0.4636, 0.8076, -0.7991, 0.3969, 0.849... | diffusers-main | scripts/generate_logits.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-main | scripts/convert_original_stable_diffusion_to_diffusers.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-main | scripts/change_naming_configs_and_checkpoints.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-main | src/diffusers/configuration_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-main | src/diffusers/pipeline_flax_utils.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-main | src/diffusers/modeling_flax_utils.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-main | src/diffusers/modeling_flax_pytorch_utils.py |
# Copyright 2020 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-main | src/diffusers/dependency_versions_check.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-main | src/diffusers/optimization.py |
from .utils import (
is_flax_available,
is_inflect_available,
is_onnx_available,
is_scipy_available,
is_torch_available,
is_transformers_available,
is_unidecode_available,
)
__version__ = "0.6.0.dev0"
from .configuration_utils import ConfigMixin
from .onnx_utils import OnnxRuntimeModel
fr... | diffusers-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-main | src/diffusers/hub_utils.py |
import copy
import os
import random
import numpy as np
import torch
def enable_full_determinism(seed: int):
"""
Helper function for reproducible behavior during distributed training. See
- https://pytorch.org/docs/stable/notes/randomness.html for pytorch
"""
# set seed first
set_seed(seed)
... | diffusers-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<10.0",
"accelerate": "accelerate>=0.11.0",
"black": "black==22.8",
"datasets": "datasets",
"filelock": "filelock",
"flake8": "flake8>=3.8.3",
... | diffusers-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-main | src/diffusers/modeling_utils.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-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-main | src/diffusers/onnx_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-main | src/diffusers/pipeline_utils.py |
from ..utils import is_flax_available, is_onnx_available, is_torch_available, is_transformers_available
if is_torch_available():
from .ddim import DDIMPipeline
from .ddpm import DDPMPipeline
from .latent_diffusion_uncond import LDMPipeline
from .pndm import PNDMPipeline
from .score_sde_ve import S... | diffusers-main | src/diffusers/pipelines/__init__.py |
# flake8: noqa
from .pipeline_stochastic_karras_ve import KarrasVePipeline
| diffusers-main | src/diffusers/pipelines/stochastic_karras_ve/__init__.py |
#!/usr/bin/env python3
from typing import Optional, Tuple, Union
import torch
from ...models import UNet2DModel
from ...pipeline_utils import DiffusionPipeline, ImagePipelineOutput
from ...schedulers import KarrasVeScheduler
class KarrasVePipeline(DiffusionPipeline):
r"""
Stochastic sampling from Karras et ... | diffusers-main | src/diffusers/pipelines/stochastic_karras_ve/pipeline_stochastic_karras_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-main | src/diffusers/pipelines/ddim/pipeline_ddim.py |
# flake8: noqa
from .pipeline_ddim import DDIMPipeline
| diffusers-main | src/diffusers/pipelines/ddim/__init__.py |
import inspect
from typing import Optional, Tuple, Union
import torch
from ...models import UNet2DModel, VQModel
from ...pipeline_utils import DiffusionPipeline, ImagePipelineOutput
from ...schedulers import DDIMScheduler
class LDMPipeline(DiffusionPipeline):
r"""
This model inherits from [`DiffusionPipelin... | diffusers-main | src/diffusers/pipelines/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py |
# flake8: noqa
from .pipeline_latent_diffusion_uncond import LDMPipeline
| diffusers-main | src/diffusers/pipelines/latent_diffusion_uncond/__init__.py |
# flake8: noqa
from ...utils import is_transformers_available
if is_transformers_available():
from .pipeline_latent_diffusion import LDMBertModel, LDMTextToImagePipeline
| diffusers-main | src/diffusers/pipelines/latent_diffusion/__init__.py |
import inspect
from typing import List, Optional, Tuple, Union
import torch
import torch.nn as nn
import torch.utils.checkpoint
from transformers.activations import ACT2FN
from transformers.configuration_utils import PretrainedConfig
from transformers.modeling_outputs import BaseModelOutput
from transformers.modeling... | diffusers-main | src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py |
# flake8: noqa
from .pipeline_score_sde_ve import ScoreSdeVePipeline
| diffusers-main | src/diffusers/pipelines/score_sde_ve/__init__.py |
#!/usr/bin/env python3
from typing import Optional, Tuple, Union
import torch
from ...models import UNet2DModel
from ...pipeline_utils import DiffusionPipeline, ImagePipelineOutput
from ...schedulers import ScoreSdeVeScheduler
class ScoreSdeVePipeline(DiffusionPipeline):
r"""
Parameters:
This model inhe... | diffusers-main | src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py |
from functools import partial
from typing import Dict, List, Optional, Union
import numpy as np
import jax
import jax.numpy as jnp
from flax.core.frozen_dict import FrozenDict
from flax.jax_utils import unreplicate
from flax.training.common_utils import shard
from PIL import Image
from transformers import CLIPFeature... | diffusers-main | src/diffusers/pipelines/stable_diffusion/pipeline_flax_stable_diffusion.py |
import warnings
from typing import Optional, Tuple
import numpy as np
import jax
import jax.numpy as jnp
from flax import linen as nn
from flax.core.frozen_dict import FrozenDict
from transformers import CLIPConfig, FlaxPreTrainedModel
from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule
def... | diffusers-main | src/diffusers/pipelines/stable_diffusion/safety_checker_flax.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.