id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
151,462 | import re
from typing import Any, ClassVar, List, Union, Type
import attrs
from data_diff.abcs.database_types import (
ColType,
Array,
JSON,
Struct,
Timestamp,
Datetime,
Integer,
Decimal,
Float,
Text,
DbPath,
FractionalType,
TemporalType,
Boolean,
UnknownColTy... | null |
151,463 | from typing import Any, ClassVar, Dict, List, Type
from urllib.parse import unquote
import attrs
from data_diff.abcs.database_types import (
ColType,
DbPath,
JSON,
Timestamp,
TimestampTZ,
Float,
Decimal,
Integer,
TemporalType,
Native_UUID,
Text,
FractionalType,
Boolea... | null |
151,464 | from random import randint, randrange
from typing import Tuple
import attrs
from data_diff.utils import safezip
def neg_interval(interval):
return tuple(-i for i in interval) | null |
151,465 | from random import randint, randrange
from typing import Tuple
import attrs
from data_diff.utils import safezip
Vector = Tuple[int]
def neg_v(v: Vector):
return tuple(-i for i in v) | null |
151,466 | from random import randint, randrange
from typing import Tuple
import attrs
from data_diff.utils import safezip
Vector = Tuple[int]
def safezip(*args):
"zip but makes sure all sequences are the same length"
lens = list(map(len, args))
if len(set(lens)) != 1:
raise ValueError(f"Mismatching lengths i... | null |
151,467 | from random import randint, randrange
from typing import Tuple
import attrs
from data_diff.utils import safezip
def add_v(v1: Vector, v2: Vector):
return tuple(i1 + i2 for i1, i2 in safezip(v1, v2))
def rand_v_in_range(v1: Vector, v2: Vector):
return tuple(irandrange(i1, i2) for i1, i2 in safezip(v1, v2))
class... | null |
151,468 | import time
from typing import Container, Dict, List, Optional, Sequence, Tuple
import logging
from itertools import product
import attrs
from typing_extensions import Self
from data_diff.utils import safezip, Vector
from data_diff.utils import ArithString, split_space
from data_diff.databases.base import Database
from... | Returns a list of split-points for each key dimension, essentially returning an N-dimensional grid of split points. |
151,469 | import time
from typing import Container, Dict, List, Optional, Sequence, Tuple
import logging
from itertools import product
import attrs
from typing_extensions import Self
from data_diff.utils import safezip, Vector
from data_diff.utils import ArithString, split_space
from data_diff.databases.base import Database
from... | Given a list of values along each axis of N dimensional space, return an array of boxes whose start-points & end-points align with the given values, and together consitute a mesh filling that space entirely (within the bounds of the given values). Assumes given values are already ordered ascending. len(boxes) == ∏i( le... |
151,470 | import json
import logging
import os
import sys
import time
from copy import deepcopy
from datetime import datetime
from itertools import islice
from typing import Dict, Optional, Tuple, Union, List, Set
import click
import rich
from rich.logging import RichHandler
from data_diff import Database, DbPath
from data_diff.... | null |
151,471 | import json
import logging
import os
import sys
import time
from copy import deepcopy
from datetime import datetime
from itertools import islice
from typing import Dict, Optional, Tuple, Union, List, Set
import click
import rich
from rich.logging import RichHandler
from data_diff import Database, DbPath
from data_diff.... | null |
151,472 | import json
import logging
import os
import sys
import time
from copy import deepcopy
from datetime import datetime
from itertools import islice
from typing import Dict, Optional, Tuple, Union, List, Set
import click
import rich
from rich.logging import RichHandler
from data_diff import Database, DbPath
from data_diff.... | null |
151,473 | import re
import os
from typing import Any, Dict
import toml
def _apply_config(config: Dict[str, Any], run_name: str, kw: Dict[str, Any]):
_resolve_env(config)
# Load config
databases = config.pop("database", {})
runs = config.pop("run", {})
if config:
raise ConfigParseError(f"Unknown option... | null |
151,474 | import re
import os
from typing import Any, Dict
import toml
def _apply_config(config: Dict[str, Any], run_name: str, kw: Dict[str, Any]):
def apply_config_from_string(toml_config: str, run_name: str, kw: Dict[str, Any]):
return _apply_config(toml.loads(toml_config), run_name, kw) | null |
151,475 | import json
import time
from typing import List, Optional, Union, overload
import pydantic
import rich
from rich.table import Table
from rich.prompt import Confirm, Prompt, FloatPrompt, IntPrompt, InvalidResponse
from typing_extensions import Literal
from data_diff.cloud.datafold_api import (
DatafoldAPI,
TClou... | null |
151,476 | import json
import time
from typing import List, Optional, Union, overload
import pydantic
import rich
from rich.table import Table
from rich.prompt import Confirm, Prompt, FloatPrompt, IntPrompt, InvalidResponse
from typing_extensions import Literal
from data_diff.cloud.datafold_api import (
DatafoldAPI,
TClou... | null |
151,477 | from decimal import Decimal
from functools import partial
import logging
from typing import List, Optional
from itertools import chain
import attrs
from data_diff.databases import Database, MsSQL, MySQL, BigQuery, Presto, Oracle, Snowflake, DuckDB
from data_diff.abcs.database_types import NumericType, DbPath
from data_... | null |
151,478 | from decimal import Decimal
from functools import partial
import logging
from typing import List, Optional
from itertools import chain
import attrs
from data_diff.databases import Database, MsSQL, MySQL, BigQuery, Presto, Oracle, Snowflake, DuckDB
from data_diff.abcs.database_types import NumericType, DbPath
from data_... | null |
151,479 | from decimal import Decimal
from functools import partial
import logging
from typing import List, Optional
from itertools import chain
import attrs
from data_diff.databases import Database, MsSQL, MySQL, BigQuery, Presto, Oracle, Snowflake, DuckDB
from data_diff.abcs.database_types import NumericType, DbPath
from data_... | null |
151,480 | from decimal import Decimal
from functools import partial
import logging
from typing import List, Optional
from itertools import chain
import attrs
from data_diff.databases import Database, MsSQL, MySQL, BigQuery, Presto, Oracle, Snowflake, DuckDB
from data_diff.abcs.database_types import NumericType, DbPath
from data_... | null |
151,481 | from decimal import Decimal
from functools import partial
import logging
from typing import List, Optional
from itertools import chain
import attrs
from data_diff.databases import Database, MsSQL, MySQL, BigQuery, Presto, Oracle, Snowflake, DuckDB
from data_diff.abcs.database_types import NumericType, DbPath
from data_... | null |
151,482 | from decimal import Decimal
from functools import partial
import logging
from typing import List, Optional
from itertools import chain
import attrs
from data_diff.databases import Database, MsSQL, MySQL, BigQuery, Presto, Oracle, Snowflake, DuckDB
from data_diff.abcs.database_types import NumericType, DbPath
from data_... | null |
151,483 | from contextlib import suppress
from data_diff.abcs.database_types import DbPath
from data_diff.databases.base import QueryError
from data_diff.databases.oracle import Oracle
from data_diff.queries.api import table, commit, Expr
def _drop_table_oracle(name: DbPath):
t = table(name)
# Experience shows double dro... | null |
151,484 | from contextlib import suppress
from data_diff.abcs.database_types import DbPath
from data_diff.databases.base import QueryError
from data_diff.databases.oracle import Oracle
from data_diff.queries.api import table, commit, Expr
def _append_to_table_oracle(path: DbPath, expr: Expr):
"""See append_to_table"""
as... | null |
151,485 | from data_diff.utils import CaseAwareMapping, CaseSensitiveDict
from data_diff.queries.ast_classes import *
from data_diff.queries.base import args_as_tuple
The provided code snippet includes necessary dependencies for implementing the `cte` function. Write a Python function `def cte(expr: Expr, *, name: Optional[str]... | Define a CTE |
151,486 | from data_diff.utils import CaseAwareMapping, CaseSensitiveDict
from data_diff.queries.ast_classes import *
from data_diff.queries.base import args_as_tuple
def args_as_tuple(exprs):
if len(exprs) == 1:
(e,) = exprs
if isinstance(e, Generator):
return tuple(e)
return exprs
The prov... | Apply OR between a sequence of boolean expressions |
151,487 | from data_diff.utils import CaseAwareMapping, CaseSensitiveDict
from data_diff.queries.ast_classes import *
from data_diff.queries.base import args_as_tuple
The provided code snippet includes necessary dependencies for implementing the `sum_` function. Write a Python function `def sum_(expr: Expr) -> Func` to solve th... | Call SUM(expr) |
151,488 | from data_diff.utils import CaseAwareMapping, CaseSensitiveDict
from data_diff.queries.ast_classes import *
from data_diff.queries.base import args_as_tuple
The provided code snippet includes necessary dependencies for implementing the `avg` function. Write a Python function `def avg(expr: Expr) -> Func` to solve the ... | Call AVG(expr) |
151,489 | from data_diff.utils import CaseAwareMapping, CaseSensitiveDict
from data_diff.queries.ast_classes import *
from data_diff.queries.base import args_as_tuple
The provided code snippet includes necessary dependencies for implementing the `min_` function. Write a Python function `def min_(expr: Expr) -> Func` to solve th... | Call MIN(expr) |
151,490 | from data_diff.utils import CaseAwareMapping, CaseSensitiveDict
from data_diff.queries.ast_classes import *
from data_diff.queries.base import args_as_tuple
The provided code snippet includes necessary dependencies for implementing the `max_` function. Write a Python function `def max_(expr: Expr) -> Func` to solve th... | Call MAX(expr) |
151,491 | from data_diff.utils import CaseAwareMapping, CaseSensitiveDict
from data_diff.queries.ast_classes import *
from data_diff.queries.base import args_as_tuple
The provided code snippet includes necessary dependencies for implementing the `exists` function. Write a Python function `def exists(expr: Expr) -> Func` to solv... | Call EXISTS(expr) |
151,492 | from data_diff.utils import CaseAwareMapping, CaseSensitiveDict
from data_diff.queries.ast_classes import *
from data_diff.queries.base import args_as_tuple
def args_as_tuple(exprs):
if len(exprs) == 1:
(e,) = exprs
if isinstance(e, Generator):
return tuple(e)
return exprs
The prov... | Returns a call to COALESCE |
151,493 | from data_diff.utils import CaseAwareMapping, CaseSensitiveDict
from data_diff.queries.ast_classes import *
from data_diff.queries.base import args_as_tuple
def insert_rows_in_batches(db, tbl: TablePath, rows, *, columns=None, batch_size=1024 * 8) -> None:
assert batch_size > 0
rows = list(rows)
while row... | null |
151,494 | from data_diff.utils import CaseAwareMapping, CaseSensitiveDict
from data_diff.queries.ast_classes import *
from data_diff.queries.base import args_as_tuple
The provided code snippet includes necessary dependencies for implementing the `code` function. Write a Python function `def code(code: str, **kw: Dict[str, Expr]... | Inline raw SQL code. It allows users to use features and syntax that Sqeleton doesn't yet support. It's the user's responsibility to make sure the contents of the string given to `code()` are correct and safe for execution. Strings given to `code()` are actually templates, and can embed query expressions given as argum... |
151,495 | from datetime import datetime
from typing import Any, Generator, List, Optional, Sequence, Union, Dict
import attrs
from typing_extensions import Self
from data_diff.utils import ArithString
from data_diff.abcs.compiler import Compilable
from data_diff.schema import Schema
from data_diff.queries.base import SKIP, args_... | null |
151,496 | from datetime import datetime
from typing import Any, Generator, List, Optional, Sequence, Union, Dict
import attrs
from typing_extensions import Self
from data_diff.utils import ArithString
from data_diff.abcs.compiler import Compilable
from data_diff.schema import Schema
from data_diff.queries.base import SKIP, args_... | null |
151,497 | from datetime import datetime
from typing import Any, Generator, List, Optional, Sequence, Union, Dict
import attrs
from typing_extensions import Self
from data_diff.utils import ArithString
from data_diff.abcs.compiler import Compilable
from data_diff.schema import Schema
from data_diff.queries.base import SKIP, args_... | null |
151,498 | from datetime import datetime
from typing import Any, Generator, List, Optional, Sequence, Union, Dict
import attrs
from typing_extensions import Self
from data_diff.utils import ArithString
from data_diff.abcs.compiler import Compilable
from data_diff.schema import Schema
from data_diff.queries.base import SKIP, args_... | null |
151,499 | from datetime import datetime
from typing import Any, Generator, List, Optional, Sequence, Union, Dict
import attrs
from typing_extensions import Self
from data_diff.utils import ArithString
from data_diff.abcs.compiler import Compilable
from data_diff.schema import Schema
from data_diff.queries.base import SKIP, args_... | null |
151,500 | import logging
import os
import json
import platform
from time import time
from typing import Any, Dict, Optional
import urllib.request
from uuid import uuid4
import toml
from rich import get_console
from data_diff.version import __version__
g_tracking_enabled = True
def disable_tracking() -> None:
global g_tracki... | null |
151,501 | from contextlib import nullcontext
import json
import os
import re
import time
from typing import List, Optional, Dict, Tuple, Union
import keyring
import pydantic
import rich
from rich.prompt import Prompt
from rich.markdown import Markdown
from concurrent.futures import ThreadPoolExecutor, as_completed
from data_diff... | null |
151,502 | import pytorch_lightning as pl
The provided code snippet includes necessary dependencies for implementing the `data_loader` function. Write a Python function `def data_loader(fn)` to solve the following problem:
Decorator to handle the deprecation of data_loader from 0.7 :param fn: User defined data loader function :r... | Decorator to handle the deprecation of data_loader from 0.7 :param fn: User defined data loader function :return: A wrapper for the data_loader function |
151,503 | import torch
from models import BaseVAE
from torch import nn
from torch.nn import functional as F
from .types_ import *
from math import floor, pi, log
def conv_out_shape(img_size):
return floor((img_size + 2 - 3) / 2.) + 1 | null |
151,504 | import torch
from models import BaseVAE
from torch import nn
from torch.distributions import Gamma
from torch.nn import functional as F
from .types_ import *
import torch.nn.init as init
def init_(m):
if isinstance(m, (nn.Linear, nn.Conv2d)):
init.orthogonal_(m.weight)
if m.bias is not None:
... | null |
151,505 | import fire
import random as rnd
from big_sleep import Imagine, version
from pathlib import Path
from .version import __version_
__version__ = '0.9.1'
def train(
text=None,
img=None,
text_min="",
lr = .07,
image_size = 512,
gradient_accumulate_every = 1,
epochs = 20,
iterations = 1050,... | null |
151,506 | from collections import OrderedDict
from typing import Tuple, Union
import torch
import torch.nn.functional as F
from torch import nn
from pathlib import Path
import hashlib
import os
import urllib
import warnings
from typing import Union, List
import torch
from PIL import Image
from torchvision.transforms import Compo... | Load a CLIP model Parameters ---------- name : str A model name listed by `clip.available_models()`, or the path to a model checkpoint containing the state_dict device : Union[str, torch.device] The device to put the loaded model jit : bool Whether to load the optimized JIT model (default) or more hackable non-JIT mode... |
151,507 | from collections import OrderedDict
from typing import Tuple, Union
import torch
import torch.nn.functional as F
from torch import nn
from pathlib import Path
import hashlib
import os
import urllib
import warnings
from typing import Union, List
import torch
from PIL import Image
from torchvision.transforms import Compo... | Returns the tokenized representation of given input string(s) Parameters ---------- texts : Union[str, List[str]] An input string or a list of input strings to tokenize context_length : int The context length to use; all CLIP models use 77 as the context length Returns ------- A two-dimensional tensor containing the re... |
151,508 | from collections import OrderedDict
from typing import Tuple, Union
import torch
import torch.nn.functional as F
from torch import nn
from pathlib import Path
import hashlib
import os
import urllib
import warnings
from typing import Union, List
import torch
from PIL import Image
from torchvision.transforms import Compo... | null |
151,509 | from collections import OrderedDict
from typing import Tuple, Union
import torch
import torch.nn.functional as F
from torch import nn
from pathlib import Path
import hashlib
import os
import urllib
import warnings
from typing import Union, List
import torch
from PIL import Image
from torchvision.transforms import Compo... | Returns list of utf-8 byte and a corresponding list of unicode strings. The reversible bpe codes work on unicode strings. This means you need a large # of unicode characters in your vocab if you want to avoid UNKs. When you're at something like a 10B token dataset you end up needing around 5K for decent coverage. This ... |
151,510 | from collections import OrderedDict
from typing import Tuple, Union
import torch
import torch.nn.functional as F
from torch import nn
from pathlib import Path
import hashlib
import os
import urllib
import warnings
from typing import Union, List
import torch
from PIL import Image
from torchvision.transforms import Compo... | Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings). |
151,511 | from collections import OrderedDict
from typing import Tuple, Union
import torch
import torch.nn.functional as F
from torch import nn
from pathlib import Path
import hashlib
import os
import urllib
import warnings
from typing import Union, List
import torch
from PIL import Image
from torchvision.transforms import Compo... | null |
151,512 | from collections import OrderedDict
from typing import Tuple, Union
import torch
import torch.nn.functional as F
from torch import nn
from pathlib import Path
import hashlib
import os
import urllib
import warnings
from typing import Union, List
import torch
from PIL import Image
from torchvision.transforms import Compo... | null |
151,513 | import os
import sys
import subprocess
import signal
import string
import re
from datetime import datetime
from pathlib import Path
import random
import torch
import torch.nn.functional as F
from torch import nn
from torch.optim import Adam
from torchvision.utils import save_image
import torchvision.transforms as T
fro... | null |
151,514 | import os
import sys
import subprocess
import signal
import string
import re
from datetime import datetime
from pathlib import Path
import random
import torch
import torch.nn.functional as F
from torch import nn
from torch.optim import Adam
from torchvision.utils import save_image
import torchvision.transforms as T
fro... | null |
151,515 | import os
import sys
import subprocess
import signal
import string
import re
from datetime import datetime
from pathlib import Path
import random
import torch
import torch.nn.functional as F
from torch import nn
from torch.optim import Adam
from torchvision.utils import save_image
import torchvision.transforms as T
fro... | null |
151,516 | import os
import sys
import subprocess
import signal
import string
import re
from datetime import datetime
from pathlib import Path
import random
import torch
import torch.nn.functional as F
from torch import nn
from torch.optim import Adam
from torchvision.utils import save_image
import torchvision.transforms as T
fro... | null |
151,517 | import os
import sys
import subprocess
import signal
import string
import re
from datetime import datetime
from pathlib import Path
import random
import torch
import torch.nn.functional as F
from torch import nn
from torch.optim import Adam
from torchvision.utils import save_image
import torchvision.transforms as T
fro... | null |
151,518 | import os
import sys
import subprocess
import signal
import string
import re
from datetime import datetime
from pathlib import Path
import random
import torch
import torch.nn.functional as F
from torch import nn
from torch.optim import Adam
from torchvision.utils import save_image
import torchvision.transforms as T
fro... | null |
151,519 | import os
import sys
import subprocess
import signal
import string
import re
from datetime import datetime
from pathlib import Path
import random
import torch
import torch.nn.functional as F
from torch import nn
from torch.optim import Adam
from torchvision.utils import save_image
import torchvision.transforms as T
fro... | null |
151,520 | from functools import update_wrapper
import math
import torch
from torch.nn import functional as F
def odd(fn):
return update_wrapper(lambda x: torch.sign(x) * fn(abs(x)), fn) | null |
151,521 | from functools import update_wrapper
import math
import torch
from torch.nn import functional as F
def _to_linear_srgb(input):
cond = input <= 0.04045
a = input / 12.92
b = ((input + 0.055) / 1.055)**2.4
return torch.where(cond, a, b) | null |
151,522 | from functools import update_wrapper
import math
import torch
from torch.nn import functional as F
def _to_nonlinear_srgb(input):
cond = input <= 0.0031308
a = 12.92 * input
b = 1.055 * input**(1/2.4) - 0.055
return torch.where(cond, a, b) | null |
151,523 | from functools import update_wrapper
import math
import torch
from torch.nn import functional as F
def lanczos(x, a):
cond = torch.logical_and(-a < x, x < a)
out = torch.where(cond, sinc(x) * sinc(x/a), x.new_zeros([]))
return out / out.sum()
def ramp(ratio, width):
n = math.ceil(width / ratio + 1)
... | null |
151,524 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import json
import copy
import logging
import os
import shutil
import tempfile
from functools import wraps
from hashlib import sha256
import sys
from io import open
import boto3
import requests
from botocore.exceptions import ClientError
fro... | Return the url and etag (which may be ``None``) stored for `filename`. Raise ``EnvironmentError`` if `filename` or its stored metadata do not exist. |
151,525 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import json
import copy
import logging
import os
import shutil
import tempfile
from functools import wraps
from hashlib import sha256
import sys
from io import open
import boto3
import requests
from botocore.exceptions import ClientError
fro... | Given something that might be a URL (or might be a local path), determine which. If it's a URL, download the file and cache it, and return the path to the cached file. If it's already a local path, make sure the file exists and then return the path. |
151,526 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import json
import copy
import logging
import os
import shutil
import tempfile
from functools import wraps
from hashlib import sha256
import sys
from io import open
import boto3
import requests
from botocore.exceptions import ClientError
fro... | Wrapper function for s3 requests in order to create more helpful error messages. |
151,527 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import json
import copy
import logging
import os
import shutil
import tempfile
from functools import wraps
from hashlib import sha256
import sys
from io import open
import boto3
import requests
from botocore.exceptions import ClientError
fro... | Extract a de-duped collection (set) of text from a file. Expected file format is one item per line. |
151,528 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import json
import copy
import logging
import os
import shutil
import tempfile
from functools import wraps
from hashlib import sha256
import sys
from io import open
import boto3
import requests
from botocore.exceptions import ClientError
fro... | null |
151,529 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import json
import copy
import logging
import os
import shutil
import tempfile
from functools import wraps
from hashlib import sha256
import sys
from io import open
import boto3
import requests
from botocore.exceptions import ClientError
fro... | null |
151,530 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import json
import copy
import logging
import os
import shutil
import tempfile
from functools import wraps
from hashlib import sha256
import sys
from io import open
import boto3
import requests
from botocore.exceptions import ClientError
fro... | null |
151,531 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import json
import copy
import logging
import os
import shutil
import tempfile
from functools import wraps
from hashlib import sha256
import sys
from io import open
import boto3
import requests
from botocore.exceptions import ClientError
fro... | null |
151,532 | import os
import math
import wandb
import random
import logging
import inspect
import argparse
import datetime
import subprocess
from pathlib import Path
from tqdm.auto import tqdm
from einops import rearrange
from omegaconf import OmegaConf
from safetensors import safe_open
from typing import Dict, Optional, Tuple
imp... | Initializes distributed environment. |
151,533 | import os
import math
import wandb
import random
import logging
import inspect
import argparse
import datetime
import subprocess
from pathlib import Path
from tqdm.auto import tqdm
from einops import rearrange
from omegaconf import OmegaConf
from safetensors import safe_open
from typing import Dict, Optional, Tuple
imp... | Returns a list of names of the model parameters that have no gradients. Args: model (torch.nn.Module): The model to check. Returns: List[str]: A list of parameter names without gradients. |
151,534 | import os, io, csv, math, random
import numpy as np
from einops import rearrange
from decord import VideoReader
from PIL import Image
import torch
import torchvision.transforms as transforms
from torch.utils.data.dataset import Dataset
from transformers import CLIPProcessor
import torch.distributed as dist
def collate... | null |
151,535 | import os
import math
import wandb
import random
import logging
import inspect
import argparse
import datetime
import subprocess
from pathlib import Path
from tqdm.auto import tqdm
from einops import rearrange
from omegaconf import OmegaConf
from safetensors import safe_open
from typing import Dict, Optional, Tuple
imp... | Initializes distributed environment. |
151,536 | import os
import math
import wandb
import random
import logging
import inspect
import argparse
import datetime
import subprocess
from pathlib import Path
from tqdm.auto import tqdm
from einops import rearrange
from omegaconf import OmegaConf
from safetensors import safe_open
from typing import Dict, Optional, Tuple
imp... | Returns a list of names of the model parameters that have no gradients. Args: model (torch.nn.Module): The model to check. Returns: List[str]: A list of parameter names without gradients. |
151,537 | import numpy as np
from typing import Callable, Optional, List
def uniform(
step: int = ...,
num_steps: Optional[int] = None,
num_frames: int = ...,
context_size: Optional[int] = None,
context_stride: int = 3,
context_overlap: int = 4,
closed_loop: bool = True,
):
if num_frames <= contex... | null |
151,539 | import os
import numpy as np
from PIL import Image
from demo.animate import AnimateAnyone
import argparse
class AnimateAnyone():
def __init__(self, config="configs/prompts/animation_stage_2_hack.yaml") -> None:
print("Initializing AnimateAnyone Pipeline...")
*_, func_args = inspect.getargvalues(ins... | null |
151,540 | import os
import numpy as np
from PIL import Image
from demo.animate import AnimateAnyone
import argparse
def parse_arguments():
parser = argparse.ArgumentParser(description="Animate images using given parameters.")
parser.add_argument('--config', type=str, default='configs/prompts/animation_stage_2_hack.yaml'... | null |
151,541 | import argparse
import imageio
import numpy as np
import gradio as gr
from PIL import Image
from demo.animate import AnimateAnyone
animator = AnimateAnyone()
def animate(reference_image, motion_sequence_state, seed, steps, guidance_scale):
return animator(reference_image, motion_sequence_state, seed, steps, guidan... | null |
151,542 | import argparse
import imageio
import numpy as np
import gradio as gr
from PIL import Image
from demo.animate import AnimateAnyone
def read_video(video):
reader = imageio.get_reader(video)
fps = reader.get_meta_data()['fps']
return video | null |
151,543 | import argparse
import imageio
import numpy as np
import gradio as gr
from PIL import Image
from demo.animate import AnimateAnyone
def read_image(image, size=512):
return np.array(Image.fromarray(image).resize((size, size))) | null |
151,544 | import os
import cv2
import torch
import numpy as np
from tqdm import tqdm
from dwpose_utils import DWposeDetector
def HWC3(x):
assert x.dtype == np.uint8
if x.ndim == 2:
x = x[:, :, None]
assert x.ndim == 3
H, W, C = x.shape
assert C == 1 or C == 3 or C == 4
if C == 3:
return x... | null |
151,545 | import os
import cv2
import torch
import numpy as np
from tqdm import tqdm
from dwpose_utils import DWposeDetector
def resize_image(input_image, resolution):
H, W, C = input_image.shape
H = float(H)
W = float(W)
k = float(resolution) / min(H, W)
H *= k
W *= k
H = int(np.round(H / 64.0)) * 6... | null |
151,546 | import os
import cv2
import torch
import numpy as np
from tqdm import tqdm
from dwpose_utils import DWposeDetector
class DWposeDetector:
def __init__(self):
self.pose_estimation = Wholebody()
def __call__(self, oriImg):
oriImg = oriImg.copy()
H, W, C = oriImg.shape
with torch.... | null |
151,547 | import os
import cv2
import torch
import numpy as np
from tqdm import tqdm
from dwpose_utils import DWposeDetector
from decord import VideoReader
from decord import cpu
def process(dwprocessor, input_image, detect_resolution):
if not isinstance(dwprocessor, DWposeDetector):
dwprocessor = DWposeDetector()
... | null |
151,548 | import cv2
import numpy as np
import onnxruntime
def multiclass_nms(boxes, scores, nms_thr, score_thr):
"""Multiclass NMS implemented in Numpy. Class-aware version."""
final_dets = []
num_classes = scores.shape[1]
for cls_ind in range(num_classes):
cls_scores = scores[:, cls_ind]
valid_s... | null |
151,549 | import math
import numpy as np
import matplotlib
import cv2
def smart_resize(x, s):
Ht, Wt = s
if x.ndim == 2:
Ho, Wo = x.shape
Co = 1
else:
Ho, Wo, Co = x.shape
if Co == 3 or Co == 1:
k = float(Ht + Wt) / float(Ho + Wo)
return cv2.resize(x, (int(Wt), int(Ht)), i... | null |
151,550 | import math
import numpy as np
import matplotlib
import cv2
def smart_resize_k(x, fx, fy):
if x.ndim == 2:
Ho, Wo = x.shape
Co = 1
else:
Ho, Wo, Co = x.shape
Ht, Wt = Ho * fy, Wo * fx
if Co == 3 or Co == 1:
k = float(Ht + Wt) / float(Ho + Wo)
return cv2.resize(x,... | null |
151,553 | import math
import numpy as np
import matplotlib
import cv2
def draw_bodypose(canvas, candidate, subset):
H, W, C = canvas.shape
candidate = np.array(candidate)
subset = np.array(subset)
stickwidth = 4
limbSeq = [[2, 3], [2, 6], [3, 4], [4, 5], [6, 7], [7, 8], [2, 9], [9, 10], \
[1... | null |
151,554 | import math
import numpy as np
import matplotlib
import cv2
eps = 0.01
def draw_handpose(canvas, all_hand_peaks):
H, W, C = canvas.shape
edges = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], \
[10, 11], [11, 12], [0, 13], [13, 14], [14, 15], [15, 16], [0, 17], ... | null |
151,559 | from typing import List, Tuple
import cv2
import numpy as np
import onnxruntime as ort
def preprocess(
img: np.ndarray, out_bbox, input_size: Tuple[int, int] = (192, 256)
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
"""Do preprocessing for RTMPose model inference.
Args:
img (np.ndarray): Input im... | null |
151,560 | import cv2
import os
import shutil
def extract_first_frame(input_file, output_folder):
if not os.path.exists(output_folder):
os.makedirs(output_folder)
cap = cv2.VideoCapture(input_file)
if not cap.isOpened():
print(f"Error opening video file: {input_file}")
return
ret, frame... | null |
151,561 | import cv2
import os
import shutil
def copy_video(input_file, target_folder):
if not os.path.exists(target_folder):
os.makedirs(target_folder)
target_file = os.path.join(target_folder, os.path.basename(input_file))
shutil.copy(input_file, target_file)
print(f"File copied to {target_file}") | null |
151,562 | import torch
import torch.nn.functional as F
from einops import rearrange
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from diffusers.models.attention import BasicTransformerBlock
from .attention import BasicTransformerBlock as _BasicTransformerBlock
def torch_dfs(model: torch.nn.Module):
r... | null |
151,563 | from dataclasses import dataclass
import torch
import torch.nn.functional as F
from torch import nn
from diffusers.utils import BaseOutput
from diffusers.utils.import_utils import is_xformers_available
from diffusers.models.attention import FeedForward
from .orig_attention import CrossAttention
from einops import rearr... | null |
151,564 | from dataclasses import dataclass
import torch
import torch.nn.functional as F
from torch import nn
from diffusers.utils import BaseOutput
from diffusers.utils.import_utils import is_xformers_available
from diffusers.models.attention import FeedForward
from .orig_attention import CrossAttention
from einops import rearr... | null |
151,565 | import torch
from torch import nn
from .attention import Transformer3DModel
from .resnet import Downsample3D, ResnetBlock3D, Upsample3D
from .motion_module import get_motion_module
class CrossAttnDownBlock3D(nn.Module):
def __init__(
self,
in_channels: int,
out_channels: int,
temb_ch... | null |
151,566 | import torch
from torch import nn
from .attention import Transformer3DModel
from .resnet import Downsample3D, ResnetBlock3D, Upsample3D
from .motion_module import get_motion_module
class CrossAttnUpBlock3D(nn.Module):
def __init__(
self,
in_channels: int,
out_channels: int,
... | null |
151,568 | import os
import imageio
import numpy as np
import torch
import torchvision
from PIL import Image
from typing import Union
from tqdm import tqdm
from einops import rearrange
import torch.distributed as dist
def save_videos_grid(videos: torch.Tensor, path: str, rescale=False, n_rows=6, fps=25):
videos = rearrange(v... | null |
151,569 | import os
import imageio
import numpy as np
import torch
import torchvision
from PIL import Image
from typing import Union
from tqdm import tqdm
from einops import rearrange
import torch.distributed as dist
def save_images_grid(images: torch.Tensor, path: str):
assert images.shape[2] == 1 # no time dimension
i... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.