id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
145,882 | import torch
from samplers.ddim.sampler import DDIMSampler
from samplers.ddim.gaussian_sampler import GaussianDiffusion
from samplers.uni_pc.sampler import UniPCSampler
from tqdm import tqdm
from modules.shared import state
from modules.sd_samplers_common import InterruptedException
def get_tensor_shape(batch_size, ch... | null |
145,883 | import torch
from samplers.ddim.sampler import DDIMSampler
from samplers.ddim.gaussian_sampler import GaussianDiffusion
from samplers.uni_pc.sampler import UniPCSampler
from tqdm import tqdm
from modules.shared import state
from modules.sd_samplers_common import InterruptedException
def inpaint_masking(xt, step, steps... | null |
145,884 | import torch
import torch.nn.functional as F
import math
from einops import rearrange,repeat
from modules.shared import state
from t2v_helpers.general_utils import reconstruct_conds
def expand_dims(v, dims):
"""
Expand the tensor `v` to the dim `dims`.
Args:
`v`: a PyTorch tensor with shape [N].
... | Create a wrapper function for the noise prediction model. DPM-Solver needs to solve the continuous-time diffusion ODEs. For DPMs trained on discrete-time labels, we need to firstly wrap the model function to a noise prediction model that accepts the continuous time as the input. We support four types of the diffusion m... |
145,885 | import torch
import torch.nn.functional as F
import math
from einops import rearrange,repeat
from modules.shared import state
from t2v_helpers.general_utils import reconstruct_conds
The provided code snippet includes necessary dependencies for implementing the `interpolate_fn` function. Write a Python function `def in... | A piecewise linear function y = f(x), using xp and yp as keypoints. We implement f(x) in a differentiable way (i.e. applicable for autograd). The function f(x) is well-defined for all x-axis. (For x beyond the bounds of xp, we use the outmost points of xp to define the linear function.) Args: x: PyTorch tensor with sha... |
145,886 | import re
import numpy as np
import numexpr
import pandas as pd
def check_is_number(value):
float_pattern = r'^(?=.)([+-]?([0-9]*)(\.([0-9]+))?)$'
return re.match(float_pattern, value) | null |
145,887 | import sys, os
import gradio as gr
from modules import script_callbacks, shared
from modules.shared import cmd_opts, opts
from t2v_helpers.render import run
import t2v_helpers.args as args
from t2v_helpers.args import setup_text2video_settings_dictionary
from modules.call_queue import wrap_gradio_gpu_call
from stable_l... | null |
145,888 | import sys, os
import gradio as gr
from modules import script_callbacks, shared
from modules.shared import cmd_opts, opts
from t2v_helpers.render import run
import t2v_helpers.args as args
from t2v_helpers.args import setup_text2video_settings_dictionary
from modules.call_queue import wrap_gradio_gpu_call
from stable_l... | null |
145,890 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
def make_beta_schedule(schedule, n_timestep, linear_start=1e-4, linear_end=2e-2, cosine_s=8... | null |
145,891 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
def make_ddim_timesteps(ddim_discr_method, num_ddim_timesteps, num_ddpm_timesteps, verbose=... | null |
145,892 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
def make_ddim_sampling_parameters(alphacums, ddim_timesteps, eta, verbose=True):
# sele... | null |
145,893 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
The provided code snippet includes necessary dependencies for implementing the `betas_for_a... | Create a beta schedule that discretizes the given alpha_t_bar function, which defines the cumulative product of (1-beta) over time from t = [0,1]. :param num_diffusion_timesteps: the number of betas to produce. :param alpha_bar: a lambda that takes an argument t from 0 to 1 and produces the cumulative product of (1-bet... |
145,894 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
def extract_into_tensor(a, t, x_shape):
b, *_ = t.shape
out = a.gather(-1, t)
r... | null |
145,895 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
class CheckpointFunction(torch.autograd.Function):
def forward(ctx, run_function, length... | Evaluate a function without caching intermediate activations, allowing for reduced memory at the expense of extra compute in the backward pass. :param func: the function to evaluate. :param inputs: the argument sequence to pass to `func`. :param params: a sequence of parameters `func` depends on but does not explicitly... |
145,896 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
The provided code snippet includes necessary dependencies for implementing the `timestep_em... | Create sinusoidal timestep embeddings. :param timesteps: a 1-D Tensor of N indices, one per batch element. These may be fractional. :param dim: the dimension of the output. :param max_period: controls the minimum frequency of the embeddings. :return: an [N x dim] Tensor of positional embeddings. |
145,897 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
The provided code snippet includes necessary dependencies for implementing the `zero_module... | Zero out the parameters of a module and return it. |
145,898 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
The provided code snippet includes necessary dependencies for implementing the `scale_modul... | Scale the parameters of a module and return it. |
145,899 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
The provided code snippet includes necessary dependencies for implementing the `mean_flat` ... | Take the mean over all non-batch dimensions. |
145,900 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
class GroupNorm32(nn.GroupNorm):
def forward(self, x):
return super().forward(x.... | Make a standard normalization layer. :param channels: number of input channels. :return: an nn.Module for normalization. |
145,901 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
def Normalize(in_channels):
return torch.nn.GroupNorm(num_groups=32, num_channels=in_ch... | null |
145,902 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
def identity(*args, **kwargs):
return nn.Identity() | null |
145,903 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
class SiLU(nn.Module):
def forward(self, x):
return x * torch.sigmoid(x)
def no... | null |
145,904 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
The provided code snippet includes necessary dependencies for implementing the `conv_nd` fu... | Create a 1D, 2D, or 3D convolution module. |
145,905 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
The provided code snippet includes necessary dependencies for implementing the `linear` fun... | Create a linear module. |
145,906 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
The provided code snippet includes necessary dependencies for implementing the `avg_pool_nd... | Create a 1D, 2D, or 3D average pooling module. |
145,907 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
def noise_like(shape, device, repeat=False, noise_gen=None):
assert noise_gen is not No... | null |
145,908 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
def init_(tensor):
dim = tensor.shape[-1]
std = 1 / math.sqrt(dim)
tensor.unifo... | null |
145,909 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
def uniq(arr):
return{el: True for el in arr}.keys() | null |
145,910 | import math
from inspect import isfunction
import torch
import numpy as np
import torch.nn as nn
from einops import repeat
import torch.nn.functional as F
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
def exists(val):
return val is not None
def default(val, d):
if exists(val):
... | null |
145,911 | import math
import torch
import numpy as np
from torch import nn
from einops import rearrange
The provided code snippet includes necessary dependencies for implementing the `get_timestep_embedding` function. Write a Python function `def get_timestep_embedding(timesteps, embedding_dim)` to solve the following problem:
... | This matches the implementation in Denoising Diffusion Probabilistic Models: From Fairseq. Build sinusoidal embeddings. This matches the implementation in tensor2tensor, but differs slightly from the description in Section 3.5 of "Attention Is All You Need". |
145,912 | import math
import torch
import numpy as np
from torch import nn
from einops import rearrange
def nonlinearity(x):
# swish
return x*torch.sigmoid(x) | null |
145,913 | import math
import torch
import numpy as np
from torch import nn
from einops import rearrange
def Normalize(in_channels, num_groups=32):
return torch.nn.GroupNorm(num_groups=num_groups, num_channels=in_channels, eps=1e-6, affine=True) | null |
145,914 | import math
import torch
import numpy as np
from torch import nn
from einops import rearrange
class LinAttnBlock(LinearAttention):
"""to match AttnBlock usage"""
def __init__(self, in_channels):
super().__init__(dim=in_channels, heads=1, dim_head=in_channels)
class AttnBlock(nn.Module):
def __init__... | null |
145,915 | from abc import abstractmethod
import math
from einops import rearrange
from functools import partial
import numpy as np
import torch as th
import torch.nn as nn
import torch.nn.functional as F
from omegaconf.listconfig import ListConfig
from videocrafter.lvdm.models.modules.util import (
checkpoint,
conv_nd,
... | null |
145,916 | from abc import abstractmethod
import math
from einops import rearrange
from functools import partial
import numpy as np
import torch as th
import torch.nn as nn
import torch.nn.functional as F
from omegaconf.listconfig import ListConfig
from videocrafter.lvdm.models.modules.util import (
checkpoint,
conv_nd,
... | null |
145,917 | from abc import abstractmethod
import math
from einops import rearrange
from functools import partial
import numpy as np
import torch as th
import torch.nn as nn
import torch.nn.functional as F
from omegaconf.listconfig import ListConfig
from videocrafter.lvdm.models.modules.util import (
checkpoint,
conv_nd,
... | null |
145,918 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
The provided code snippet includes necessary dependencies for implementing the `_find_children` function. Write a Python function `def _find_chil... | Find all modules of a certain class (or union of classes). Returns all matching modules, along with the parent of those moduless and the names they are referenced by. |
145,919 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
class LoraInjectedLinear(nn.Module):
def __init__(
self, in_features, out_features, bias=False, r=4, dropout_p=0.1, scale=1.0
):
... | Find all modules of a certain class (or union of classes) that are direct or indirect descendants of other modules of a certain class (or union of classes). Returns all matching modules, along with the parent of those moduless and the names they are referenced by. |
145,920 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
class LoraInjectedLinear(nn.Module):
def __init__(
self, in_features, out_features, bias=False, r=4, dropout_p=0.1, scale=1.0
):
... | null |
145,921 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
class LoraInjectedLinear(nn.Module):
def __init__(
self, in_features, out_features, bias=False, r=4, dropout_p=0.1, scale=1.0
):
... | inject lora into model, and returns lora parameter groups. |
145,922 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
class LoraInjectedLinear(nn.Module):
def __init__(
self, in_features, out_features, bias=False, r=4, dropout_p=0.1, scale=1.0
):
... | inject lora into model, and returns lora parameter groups. |
145,923 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
def extract_lora_ups_down(model, target_replace_module=DEFAULT_TARGET_REPLACE):
loras = []
for _m, _n, _child_module in _find_modules(
... | null |
145,924 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
def save_safeloras_with_embeds(
modelmap: Dict[str, Tuple[nn.Module, Set[str]]] = {},
embeds: Dict[str, torch.Tensor] = {},
outpath=".... | null |
145,925 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
def convert_loras_to_safeloras_with_embeds(
modelmap: Dict[str, Tuple[str, Set[str], int]] = {},
embeds: Dict[str, torch.Tensor] = {},
... | null |
145,926 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
def net_load_lora(net, checkpoint_path, alpha=1.0, remove=False):
visited=[]
state_dict = torch.load(checkpoint_path)
for k, v in stat... | null |
145,927 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
def net_load_lora_v2(net, checkpoint_path, alpha=1.0, remove=False, origin_weight=None):
def change_lora_v2(model, inject_lora=False, lora_scale=... | null |
145,928 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
def parse_safeloras(
safeloras,
) -> Dict[str, Tuple[List[nn.parameter.Parameter], List[int], List[str]]]:
"""
Converts a loaded safet... | null |
145,929 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
def parse_safeloras_embeds(
safeloras,
) -> Dict[str, torch.Tensor]:
"""
Converts a loaded safetensor file that contains Textual Inver... | null |
145,930 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
def parse_safeloras(
safeloras,
) -> Dict[str, Tuple[List[nn.parameter.Parameter], List[int], List[str]]]:
def parse_safeloras_embeds(
saf... | null |
145,931 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
class LoraInjectedLinear(nn.Module):
def __init__(
self, in_features, out_features, bias=False, r=4, dropout_p=0.1, scale=1.0
):
... | null |
145,932 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
class LoraInjectedLinear(nn.Module):
def __init__(
self, in_features, out_features, bias=False, r=4, dropout_p=0.1, scale=1.0
... | null |
145,933 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
class LoraInjectedLinear(nn.Module):
def __init__(
self, in_features, out_features, bias=False, r=4, dropout_p=0.1, scale=1.0
):
... | null |
145,934 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
def tune_lora_scale(model, alpha: float = 1.0):
for _module in model.modules():
if _module.__class__.__name__ in ["LoraInjectedLinear... | null |
145,935 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
def set_lora_diag(model, diag: torch.Tensor):
for _module in model.modules():
if _module.__class__.__name__ in ["LoraInjectedLinear",... | null |
145,936 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
TEXT_ENCODER_DEFAULT_TARGET_REPLACE = {"CLIPAttention"}
DEFAULT_TARGET_REPLACE = UNET_DEFAULT_TARGET_REPLACE
def parse_safeloras_embeds(
safel... | null |
145,937 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
def inspect_lora(model):
moved = {}
for name, _module in model.named_modules():
if _module.__class__.__name__ in ["LoraInjectedL... | null |
145,938 | import json
from itertools import groupby
from typing import Dict, List, Optional, Set, Tuple, Type, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
TEXT_ENCODER_DEFAULT_TARGET_REPLACE = {"CLIPAttention"}
DEFAULT_TARGET_REPLACE = UNET_DEFAULT_TARGET_REPLACE
def save_lora_weight(
model,
... | null |
145,939 | import os
import time
import random
import itertools
from functools import partial
from contextlib import contextmanager
import numpy as np
from tqdm import tqdm
from einops import rearrange, repeat
import torch
import torch.nn as nn
import pytorch_lightning as pl
from torchvision.utils import make_grid
from torch.opti... | Overwrite model.train with this function to make sure train/eval mode does not change anymore. |
145,940 | import os
import time
import random
import itertools
from functools import partial
from contextlib import contextmanager
import numpy as np
from tqdm import tqdm
from einops import rearrange, repeat
import torch
import torch.nn as nn
import pytorch_lightning as pl
from torchvision.utils import make_grid
from torch.opti... | null |
145,941 | import os
import time
import random
import itertools
from functools import partial
from contextlib import contextmanager
import numpy as np
from tqdm import tqdm
from einops import rearrange, repeat
import torch
import torch.nn as nn
import pytorch_lightning as pl
from torchvision.utils import make_grid
from torch.opti... | null |
145,942 | import os
import time
import random
import itertools
from functools import partial
from contextlib import contextmanager
import numpy as np
from tqdm import tqdm
from einops import rearrange, repeat
import torch
import torch.nn as nn
import pytorch_lightning as pl
from torchvision.utils import make_grid
from torch.opti... | null |
145,943 | import importlib
import torch
import numpy as np
from inspect import isfunction
from PIL import Image, ImageDraw, ImageFont
def log_txt_as_img(wh, xc, size=10):
# wh a tuple of (width, height)
# xc a list of captions to plot
b = len(xc)
txts = list()
for bi in range(b):
txt = Image.new("RGB... | null |
145,944 | import importlib
import torch
import numpy as np
from inspect import isfunction
from PIL import Image, ImageDraw, ImageFont
def ismap(x):
if not isinstance(x, torch.Tensor):
return False
return (len(x.shape) == 4) and (x.shape[1] > 3) | null |
145,945 | import importlib
import torch
import numpy as np
from inspect import isfunction
from PIL import Image, ImageDraw, ImageFont
def isimage(x):
if not isinstance(x,torch.Tensor):
return False
return (len(x.shape) == 4) and (x.shape[1] == 3 or x.shape[1] == 1) | null |
145,946 | import importlib
import torch
import numpy as np
from inspect import isfunction
from PIL import Image, ImageDraw, ImageFont
The provided code snippet includes necessary dependencies for implementing the `mean_flat` function. Write a Python function `def mean_flat(tensor)` to solve the following problem:
https://github... | https://github.com/openai/guided-diffusion/blob/27c20a8fab9cb472df5d6bdd6c8d11c8f430b924/guided_diffusion/nn.py#L86 Take the mean over all non-batch dimensions. |
145,947 | import importlib
import torch
import numpy as np
from inspect import isfunction
from PIL import Image, ImageDraw, ImageFont
def count_params(model, verbose=False):
total_params = sum(p.numel() for p in model.parameters())
if verbose:
print(f"{model.__class__.__name__} has {total_params*1.e-6:.2f} M par... | null |
145,948 | import importlib
import torch
import numpy as np
from inspect import isfunction
from PIL import Image, ImageDraw, ImageFont
The provided code snippet includes necessary dependencies for implementing the `check_istarget` function. Write a Python function `def check_istarget(name, para_list)` to solve the following prob... | name: full name of source para para_list: partial name of target para |
145,949 | import torch
import torch.distributed as dist
def setup_dist(local_rank):
if dist.is_initialized():
return
torch.cuda.set_device(local_rank)
torch.distributed.init_process_group(
'nccl',
init_method='env://'
) | null |
145,950 | import numpy as np
import cv2
import os
import time
import imageio
from tqdm import tqdm
from PIL import Image
import os
import sys
import torch
import torchvision
from torchvision.utils import make_grid
from torch import Tensor
from torchvision.transforms.functional import to_tensor
def savenp2sheet(imgs, savepath, nr... | null |
145,951 | import numpy as np
import cv2
import os
import time
import imageio
from tqdm import tqdm
from PIL import Image
import os
import sys
import torch
import torchvision
from torchvision.utils import make_grid
from torch import Tensor
from torchvision.transforms.functional import to_tensor
The provided code snippet includes... | save a batch of videos in one image sheet with shape of [batch_size * num_frames]. data: [b,c,t,h,w] |
145,952 | import numpy as np
import cv2
import os
import time
import imageio
from tqdm import tqdm
from PIL import Image
import os
import sys
import torch
import torchvision
from torchvision.utils import make_grid
from torch import Tensor
from torchvision.transforms.functional import to_tensor
def save_np_to_img(img, path, norm=... | null |
145,953 | import numpy as np
import cv2
import os
import time
import imageio
from tqdm import tqdm
from PIL import Image
import os
import sys
import torch
import torchvision
from torchvision.utils import make_grid
from torch import Tensor
from torchvision.transforms.functional import to_tensor
def npz_to_gifs(data_path, res_dir... | null |
145,954 | import numpy as np
import cv2
import os
import time
import imageio
from tqdm import tqdm
from PIL import Image
import os
import sys
import torch
import torchvision
from torchvision.utils import make_grid
from torch import Tensor
from torchvision.transforms.functional import to_tensor
def npz_to_gif_grid(data_path, out... | null |
145,955 | import numpy as np
import cv2
import os
import time
import imageio
from tqdm import tqdm
from PIL import Image
import os
import sys
import torch
import torchvision
from torchvision.utils import make_grid
from torch import Tensor
from torchvision.transforms.functional import to_tensor
def fill_with_black_squares(video, ... | videos: -1 ~ 1, torch.Tensor, BCTHW |
145,956 | import argparse, os, sys, glob
import datetime, time
from omegaconf import OmegaConf
import torch
from decord import VideoReader, cpu
import torchvision
from pytorch_lightning import seed_everything
from lvdm.samplers.ddim import DDIMSampler
from lvdm.utils.common_utils import instantiate_from_config
from lvdm.utils.sa... | null |
145,957 | import argparse, os, sys, glob
import datetime, time
from omegaconf import OmegaConf
import torch
from decord import VideoReader, cpu
import torchvision
from pytorch_lightning import seed_everything
from lvdm.samplers.ddim import DDIMSampler
from lvdm.utils.common_utils import instantiate_from_config
from lvdm.utils.sa... | null |
145,958 | import argparse, os, sys, glob
import datetime, time
from omegaconf import OmegaConf
import torch
from decord import VideoReader, cpu
import torchvision
from pytorch_lightning import seed_everything
from lvdm.samplers.ddim import DDIMSampler
from lvdm.utils.common_utils import instantiate_from_config
from lvdm.utils.sa... | null |
145,959 | import argparse, os, sys, glob
import datetime, time
from omegaconf import OmegaConf
import torch
from decord import VideoReader, cpu
import torchvision
from pytorch_lightning import seed_everything
from lvdm.samplers.ddim import DDIMSampler
from lvdm.utils.common_utils import instantiate_from_config
from lvdm.utils.sa... | null |
145,960 | import argparse, os, sys, glob
import datetime, time
from omegaconf import OmegaConf
import torch
from decord import VideoReader, cpu
import torchvision
from pytorch_lightning import seed_everything
from lvdm.samplers.ddim import DDIMSampler
from lvdm.utils.common_utils import instantiate_from_config
from lvdm.utils.sa... | null |
145,961 | import os
import time
import argparse
import yaml, math
from tqdm import trange
import torch
import numpy as np
from omegaconf import OmegaConf
import torch.distributed as dist
from pytorch_lightning import seed_everything
from videocrafter.lvdm.samplers.ddim import DDIMSampler
from videocrafter.lvdm.utils.common_utils... | null |
145,962 | import os
import time
import argparse
import yaml, math
from tqdm import trange
import torch
import numpy as np
from omegaconf import OmegaConf
import torch.distributed as dist
from pytorch_lightning import seed_everything
from videocrafter.lvdm.samplers.ddim import DDIMSampler
from videocrafter.lvdm.utils.common_utils... | null |
145,963 | import os
import torch
from PIL import Image
from videocrafter.lvdm.models.modules.lora import net_load_lora
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
def custom_to_pil(x):
x = x.detach().cpu()
x = torch.clamp(x, -1., 1.)
x = (x + 1.) / 2.
x = x.permute(1, 2, 0).numpy()
... | null |
145,964 | import os
import torch
from PIL import Image
from videocrafter.lvdm.models.modules.lora import net_load_lora
from videocrafter.lvdm.utils.common_utils import instantiate_from_config
def make_sample_dir(opt, global_step=None, epoch=None):
if not getattr(opt, 'not_automatic_logdir', False):
gs_str = f"global... | null |
145,965 | import datetime
import argparse, importlib
from pytorch_lightning import seed_everything
import torch
import torch.distributed as dist
def setup_dist(local_rank):
if dist.is_initialized():
return
torch.cuda.set_device(local_rank)
torch.distributed.init_process_group('nccl', init_method='env://') | null |
145,966 | import datetime
import argparse, importlib
from pytorch_lightning import seed_everything
import torch
import torch.distributed as dist
def get_dist_info():
if dist.is_available():
initialized = dist.is_initialized()
else:
initialized = False
if initialized:
rank = dist.get_rank()
... | null |
145,967 | import sys, os
basedirs = [os.getcwd()]
if 'google.colab' in sys.modules:
basedirs.append('/content/gdrive/MyDrive/sd/stable-diffusion-webui') #hardcode as TheLastBen's colab seems to be the primal source
for basedir in basedirs:
deforum_paths_to_ensure = [basedir + '/extensions/sd-webui-text2video/scripts', ba... | null |
145,968 | import os
import sys
import subprocess
from time import sleep
import shutil
from sys import platform
from superagi.lib.logger import logger
logger = Logger('Super AGI')
def check_command(command, message):
if not shutil.which(command):
logger.info(message)
sys.exit(1) | null |
145,969 | import os
import sys
import subprocess
from time import sleep
import shutil
from sys import platform
from superagi.lib.logger import logger
logger = Logger('Super AGI')
def run_npm_commands(shell=False):
os.chdir("gui")
try:
subprocess.run(["npm", "install"], check=True,shell=shell)
except subproc... | null |
145,970 | import os
import sys
import subprocess
from time import sleep
import shutil
from sys import platform
from superagi.lib.logger import logger
def run_server(shell=False):
api_process = subprocess.Popen(["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"], shell=shell)
# celery_process = None
celery... | null |
145,971 | import os
import sys
import subprocess
from time import sleep
import shutil
from sys import platform
from superagi.lib.logger import logger
logger = Logger('Super AGI')
def cleanup(api_process, ui_process, celery_process):
logger.info("Shutting down processes...")
api_process.terminate()
ui_process.termin... | null |
145,972 | import requests
from fastapi import FastAPI, HTTPException, Depends, Request, status, Query
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from fastapi.responses import RedirectResponse
from fastapi_jwt_auth import AuthJWT
from fastapi_jwt_auth.exceptions import AuthJWTExc... | null |
145,973 | import requests
from fastapi import FastAPI, HTTPException, Depends, Request, status, Query
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from fastapi.responses import RedirectResponse
from fastapi_jwt_auth import AuthJWT
from fastapi_jwt_auth.exceptions import AuthJWTExc... | null |
145,974 | import requests
from fastapi import FastAPI, HTTPException, Depends, Request, status, Query
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from fastapi.responses import RedirectResponse
from fastapi_jwt_auth import AuthJWT
from fastapi_jwt_auth.exceptions import AuthJWTExc... | Login API for email and password based login |
145,975 | import requests
from fastapi import FastAPI, HTTPException, Depends, Request, status, Query
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from fastapi.responses import RedirectResponse
from fastapi_jwt_auth import AuthJWT
from fastapi_jwt_auth.exceptions import AuthJWTExc... | GitHub login |
145,976 | import requests
from fastapi import FastAPI, HTTPException, Depends, Request, status, Query
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from fastapi.responses import RedirectResponse
from fastapi_jwt_auth import AuthJWT
from fastapi_jwt_auth.exceptions import AuthJWTExc... | GitHub login callback |
145,977 | import requests
from fastapi import FastAPI, HTTPException, Depends, Request, status, Query
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from fastapi.responses import RedirectResponse
from fastapi_jwt_auth import AuthJWT
from fastapi_jwt_auth.exceptions import AuthJWTExc... | API to validate access token |
145,978 | import requests
from fastapi import FastAPI, HTTPException, Depends, Request, status, Query
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from fastapi.responses import RedirectResponse
from fastapi_jwt_auth import AuthJWT
from fastapi_jwt_auth.exceptions import AuthJWTExc... | API to validate LLM API Key |
145,979 | import requests
from fastapi import FastAPI, HTTPException, Depends, Request, status, Query
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from fastapi.responses import RedirectResponse
from fastapi_jwt_auth import AuthJWT
from fastapi_jwt_auth.exceptions import AuthJWTExc... | API to validate Open AI Key |
145,980 | import requests
from fastapi import FastAPI, HTTPException, Depends, Request, status, Query
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from fastapi.responses import RedirectResponse
from fastapi_jwt_auth import AuthJWT
from fastapi_jwt_auth.exceptions import AuthJWTExc... | null |
145,981 | from superagi.llms.google_palm import GooglePalm
from superagi.llms.local_llm import LocalLLM
from superagi.llms.openai import OpenAi
from superagi.llms.replicate import Replicate
from superagi.llms.hugging_face import HuggingFace
from superagi.models.models_config import ModelsConfig
from superagi.models.models import... | null |
145,982 | import openai
from openai import APIError, InvalidRequestError
from openai.error import RateLimitError, AuthenticationError, Timeout, TryAgain
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_random_exponential
from superagi.config.config import get_config
from superagi.lib.logger import lo... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.