Skip to content
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

Support both old and new diffusers import path #843

Merged
merged 7 commits into from
Oct 12, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion trl/models/modeling_sd_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
from dataclasses import dataclass
from typing import Any, Callable, Dict, List, Optional, Union

import diffusers
import numpy as np
import torch
from diffusers import DDIMScheduler, StableDiffusionPipeline, UNet2DConditionModel
from diffusers.loaders import AttnProcsLayers
from diffusers.models.attention_processor import LoRAAttnProcessor
from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion import rescale_noise_cfg
from diffusers.utils.torch_utils import randn_tensor


_diffusers_greater_21_4 = hasattr(diffusers.utils, "randn_tensor")
if _diffusers_greater_21_4:
from diffusers.utils import randn_tensor
else:
from diffusers.utils.torch_utils import randn_tensor


@dataclass
Expand Down
Loading