id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
151,001
from __future__ import annotations from typing import Callable, Optional from typing_extensions import Literal import os from functools import partial from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor, Future from time import sleep from signal import signal, SIGINT, SIGTERM from collections import ...
null
151,002
from __future__ import annotations from typing import Callable, Optional from typing_extensions import Literal import os from functools import partial from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor, Future from time import sleep from signal import signal, SIGINT, SIGTERM from collections import ...
null
151,003
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl.patched import Message from . import inner, misc from .utils import command_gatekeeper, parse_customization_callback_data, parse_callback_data_with_page, \ escape_html, parse_command_get_sub_or...
send_mode: -1=force link, 0=auto, 1=force Telegraph, 2=force message length_limit: Telegraph length limit, valid when send_mode==0. If exceeded, send via Telegraph; If is 0, send via Telegraph when a post cannot be sent in a single message link_preview: 0=auto, 1=force enable display_author: -1=disable, 0=auto, 1=force...
151,004
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl.patched import Message from . import inner, misc from .utils import command_gatekeeper, parse_customization_callback_data, parse_callback_data_with_page, \ escape_html, parse_command_get_sub_or...
null
151,005
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl.patched import Message from . import inner, misc from .utils import command_gatekeeper, parse_customization_callback_data, parse_callback_data_with_page, \ escape_html, parse_command_get_sub_or...
null
151,006
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl.patched import Message from . import inner, misc from .utils import command_gatekeeper, parse_customization_callback_data, parse_callback_data_with_page, \ escape_html, parse_command_get_sub_or...
null
151,007
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl.patched import Message from . import inner, misc from .utils import command_gatekeeper, parse_customization_callback_data, parse_callback_data_with_page, \ escape_html, parse_command_get_sub_or...
null
151,008
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl.patched import Message from . import inner, misc from .utils import command_gatekeeper, parse_customization_callback_data, parse_callback_data_with_page, \ escape_html, parse_command_get_sub_or...
null
151,009
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl.patched import Message from . import inner, misc from .utils import command_gatekeeper, parse_customization_callback_data, parse_callback_data_with_page, \ escape_html, parse_command_get_sub_or...
null
151,010
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl.patched import Message from . import inner, misc from .utils import command_gatekeeper, parse_customization_callback_data, parse_callback_data_with_page, \ escape_html, parse_command_get_sub_or...
null
151,011
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl.patched import Message from . import inner, misc from .utils import command_gatekeeper, parse_customization_callback_data, parse_callback_data_with_page, \ escape_html, parse_command_get_sub_or...
null
151,012
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl.patched import Message from . import inner, misc from .utils import command_gatekeeper, parse_customization_callback_data, parse_callback_data_with_page, \ escape_html, parse_command_get_sub_or...
null
151,013
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl.patched import Message from . import inner, misc from .utils import command_gatekeeper, parse_customization_callback_data, parse_callback_data_with_page, \ escape_html, parse_command_get_sub_or...
null
151,014
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl.patched import Message from . import inner, misc from .utils import command_gatekeeper, parse_customization_callback_data, parse_callback_data_with_page, \ escape_html, parse_command_get_sub_or...
null
151,015
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl import types from telethon.tl.patched import Message from .. import env from ..i18n import i18n from . import inner from .utils import command_gatekeeper, parse_command, escape_html, parse_callback...
null
151,016
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl import types from telethon.tl.patched import Message from .. import env from ..i18n import i18n from . import inner from .utils import command_gatekeeper, parse_command, escape_html, parse_callback...
null
151,017
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl import types from telethon.tl.patched import Message from .. import env from ..i18n import i18n from . import inner from .utils import command_gatekeeper, parse_command, escape_html, parse_callback...
null
151,018
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl import types from telethon.tl.patched import Message from .. import env from ..i18n import i18n from . import inner from .utils import command_gatekeeper, parse_command, escape_html, parse_callback...
null
151,019
from __future__ import annotations from typing import Union, Optional from telethon import events, Button from telethon.tl import types from telethon.tl.patched import Message from .. import env from ..i18n import i18n from . import inner from .utils import command_gatekeeper, parse_command, escape_html, parse_callback...
null
151,020
from __future__ import annotations from typing import Union, Optional, AnyStr, Any from collections.abc import Callable import asyncio import re from contextlib import suppress from functools import partial, wraps from cachetools import TTLCache from telethon import events, Button, hints from telethon.utils import get_...
null
151,021
from __future__ import annotations from typing import Union, Optional import listparser from datetime import datetime from functools import partial from telethon import events, Button from telethon.tl import types from telethon.tl.patched import Message from .. import env, db from ..compat import bozo_exception_removal...
null
151,022
from __future__ import annotations from typing import Union, Optional import listparser from datetime import datetime from functools import partial from telethon import events, Button from telethon.tl import types from telethon.tl.patched import Message from .. import env, db from ..compat import bozo_exception_removal...
null
151,023
from __future__ import annotations from typing import Union, Optional import listparser from datetime import datetime from functools import partial from telethon import events, Button from telethon.tl import types from telethon.tl.patched import Message from .. import env, db from ..compat import bozo_exception_removal...
null
151,024
from __future__ import annotations from typing import Union, Optional from collections.abc import Iterable from itertools import chain from telethon import Button from telethon.tl.types import KeyboardButtonCallback from ... import db, env from ...i18n import i18n from .utils import arrange_grid, update_interval, activ...
null
151,025
from __future__ import annotations from typing import Union, Optional from collections.abc import Iterable from itertools import chain from telethon import Button from telethon.tl.types import KeyboardButtonCallback from ... import db, env from ...i18n import i18n from .utils import arrange_grid, update_interval, activ...
null
151,026
from __future__ import annotations from typing import Union, Optional from collections.abc import Iterable from itertools import chain from telethon import Button from telethon.tl.types import KeyboardButtonCallback from ... import db, env from ...i18n import i18n from .utils import arrange_grid, update_interval, activ...
null
151,027
from __future__ import annotations from typing import Union, Optional from collections.abc import Iterable from itertools import chain from telethon import Button from telethon.tl.types import KeyboardButtonCallback from ... import db, env from ...i18n import i18n from .utils import arrange_grid, update_interval, activ...
null
151,028
from __future__ import annotations from typing import Union, Optional from collections.abc import Iterable from itertools import chain from telethon import Button from telethon.tl.types import KeyboardButtonCallback from ... import db, env from ...i18n import i18n from .utils import arrange_grid, update_interval, activ...
null
151,029
from __future__ import annotations from typing import Union, Optional from collections.abc import Iterable from itertools import chain from telethon import Button from telethon.tl.types import KeyboardButtonCallback from ... import db, env from ...i18n import i18n from .utils import arrange_grid, update_interval, activ...
null
151,030
from __future__ import annotations from typing import Union, Optional from collections.abc import Iterable from itertools import chain from telethon import Button from telethon.tl.types import KeyboardButtonCallback from ... import db, env from ...i18n import i18n from .utils import arrange_grid, update_interval, activ...
null
151,031
from __future__ import annotations from typing import Union, Optional from collections.abc import Iterable from itertools import chain from telethon import Button from telethon.tl.types import KeyboardButtonCallback from ... import db, env from ...i18n import i18n from .utils import arrange_grid, update_interval, activ...
null
151,032
from __future__ import annotations from typing import Union, Optional from collections.abc import Iterable from itertools import chain from telethon import Button from telethon.tl.types import KeyboardButtonCallback from ... import db, env from ...i18n import i18n from .utils import arrange_grid, update_interval, activ...
null
151,033
from __future__ import annotations from typing import Union, Optional from collections.abc import Iterable from itertools import chain from telethon import Button from telethon.tl.types import KeyboardButtonCallback from ... import db, env from ...i18n import i18n from .utils import arrange_grid, update_interval, activ...
null
151,034
from __future__ import annotations from typing import Union, Optional from collections.abc import Iterable from itertools import chain from telethon import Button from telethon.tl.types import KeyboardButtonCallback from ... import db, env from ...i18n import i18n from .utils import arrange_grid, update_interval, activ...
null
151,035
from __future__ import annotations from typing import Union, Optional, AnyStr from collections.abc import Sequence import re import asyncio from datetime import datetime from bs4 import BeautifulSoup from bs4.element import SoupStrainer from urllib.parse import urljoin from cachetools import TTLCache from os import pat...
null
151,036
from __future__ import annotations from typing import Union, Optional, AnyStr from collections.abc import Sequence import re import asyncio from datetime import datetime from bs4 import BeautifulSoup from bs4.element import SoupStrainer from urllib.parse import urljoin from cachetools import TTLCache from os import pat...
null
151,037
from __future__ import annotations from typing import Any, Union, Optional from collections.abc import Iterable, Mapping, Sequence import asyncio import re from itertools import chain, repeat from datetime import datetime from email.utils import parsedate_to_datetime from telethon import Button from telethon.tl.types i...
null
151,038
from __future__ import annotations from typing import Any, Union, Optional from collections.abc import Iterable, Mapping, Sequence import asyncio import re from itertools import chain, repeat from datetime import datetime from email.utils import parsedate_to_datetime from telethon import Button from telethon.tl.types i...
:param user_id: user id :param page_number: page number (1-based) :param callback: callback data header :param get_page_callback: callback data header for getting another page :param callback_contain_page_num: callback data should be followed by current page number or not? :param lang: language code :param rows: the nu...
151,039
from __future__ import annotations from typing import Any, Union, Optional from collections.abc import Iterable, Mapping, Sequence import asyncio import re from itertools import chain, repeat from datetime import datetime from email.utils import parsedate_to_datetime from telethon import Button from telethon.tl.types i...
null
151,040
from __future__ import annotations from typing import Any, Union, Optional from collections.abc import Iterable, Mapping, Sequence import asyncio import re from itertools import chain, repeat from datetime import datetime from email.utils import parsedate_to_datetime from telethon import Button from telethon.tl.types i...
:param user_id: user id :param activate: activate all subs if `Ture`, deactivate if `False` :return: the updated sub, `None` if the sub does not exist
151,041
from __future__ import annotations from typing import Union, Optional from typing_extensions import Final import asyncio import re from telethon import events, Button from telethon.tl.patched import Message from telethon.tl import types from telethon.utils import get_peer_id from .. import web, db, env from ..i18n impo...
null
151,042
from __future__ import annotations from typing import Union, Optional from typing_extensions import Final import asyncio import re from telethon import events, Button from telethon.tl.patched import Message from telethon.tl import types from telethon.utils import get_peer_id from .. import web, db, env from ..i18n impo...
null
151,043
from __future__ import annotations from typing import Union, Optional from typing_extensions import Final import asyncio import re from telethon import events, Button from telethon.tl.patched import Message from telethon.tl import types from telethon.utils import get_peer_id from .. import web, db, env from ..i18n impo...
callback data = reset_sub_limit={user_id}
151,044
from __future__ import annotations from typing import Union, Optional from typing_extensions import Final import asyncio import re from telethon import events, Button from telethon.tl.patched import Message from telethon.tl import types from telethon.utils import get_peer_id from .. import web, db, env from ..i18n impo...
command = `/set_sub_limit user_id sub_limit`
151,045
from __future__ import annotations from typing import Union from typing_extensions import Final from collections.abc import MutableMapping, Iterable import gc import asyncio from datetime import datetime, timedelta, timezone from email.utils import format_datetime from collections import defaultdict, Counter from itert...
null
151,046
from __future__ import annotations from typing import Optional, Union from contextlib import suppress from telethon import events, types, Button from telethon.tl.patched import Message from telethon.errors import RPCError from .. import env, db from .utils import command_gatekeeper, get_group_migration_help_msg, set_bo...
null
151,047
from __future__ import annotations from typing import Optional, Union from contextlib import suppress from telethon import events, types, Button from telethon.tl.patched import Message from telethon.errors import RPCError from .. import env, db from .utils import command_gatekeeper, get_group_migration_help_msg, set_bo...
null
151,048
from __future__ import annotations from typing import Optional, Union from contextlib import suppress from telethon import events, types, Button from telethon.tl.patched import Message from telethon.errors import RPCError from .. import env, db from .utils import command_gatekeeper, get_group_migration_help_msg, set_bo...
null
151,049
from __future__ import annotations from typing import Optional, Union from contextlib import suppress from telethon import events, types, Button from telethon.tl.patched import Message from telethon.errors import RPCError from .. import env, db from .utils import command_gatekeeper, get_group_migration_help_msg, set_bo...
null
151,050
from __future__ import annotations from typing import Optional, Union from contextlib import suppress from telethon import events, types, Button from telethon.tl.patched import Message from telethon.errors import RPCError from .. import env, db from .utils import command_gatekeeper, get_group_migration_help_msg, set_bo...
null
151,051
from __future__ import annotations from typing import Optional, Union from contextlib import suppress from telethon import events, types, Button from telethon.tl.patched import Message from telethon.errors import RPCError from .. import env, db from .utils import command_gatekeeper, get_group_migration_help_msg, set_bo...
null
151,052
from __future__ import annotations from typing import Optional, Union from contextlib import suppress from telethon import events, types, Button from telethon.tl.patched import Message from telethon.errors import RPCError from .. import env, db from .utils import command_gatekeeper, get_group_migration_help_msg, set_bo...
null
151,053
from __future__ import annotations from typing import Union from contextlib import AbstractAsyncContextManager import asyncio from time import time from collections import defaultdict from functools import partial from urllib.parse import urlparse from . import log, env from .errors_collection import ContextTimeoutErro...
null
151,054
from __future__ import annotations from typing import Union from contextlib import AbstractAsyncContextManager import asyncio from time import time from collections import defaultdict from functools import partial from urllib.parse import urlparse from . import log, env from .errors_collection import ContextTimeoutErro...
:return: user_msg_lock, user_flood_lock
151,055
from __future__ import annotations from typing import Union from typing_extensions import Final import aiohttp import json import PIL.Image import PIL.ImageFile from PIL import UnidentifiedImageError from io import BytesIO, SEEK_END from typing import Optional from asyncstdlib import lru_cache from .. import env from ....
null
151,056
from __future__ import annotations from typing import Union from typing_extensions import Final import aiohttp import json import PIL.Image import PIL.ImageFile from PIL import UnidentifiedImageError from io import BytesIO, SEEK_END from typing import Optional from asyncstdlib import lru_cache from .. import env from ....
null
151,057
from __future__ import annotations from typing import Union, Optional, AnyStr from typing_extensions import Final from collections.abc import Callable import re import asyncio import aiohttp import aiohttp.helpers from contextlib import suppress from bs4 import BeautifulSoup from aiohttp_socks import ProxyConnector fro...
null
151,058
from __future__ import annotations from typing import Optional, Union from typing_extensions import Final import asyncio import aiohttp import feedparser from io import BytesIO from ssl import SSLError from functools import partial from .. import log from ..aio_helper import run_async from ..compat import bozo_exceptio...
null
151,059
from __future__ import annotations from typing import Optional from typing_extensions import Final import asyncio import os import sys import colorlog import re import argparse from telethon import TelegramClient from telethon.tl.types import User, InputPeerUser from python_socks import parse_proxy_url from dotenv impo...
null
151,060
from __future__ import annotations from typing import Optional from typing_extensions import Final import asyncio import os import sys import colorlog import re import argparse from telethon import TelegramClient from telethon.tl.types import User, InputPeerUser from python_socks import parse_proxy_url from dotenv impo...
null
151,061
from __future__ import annotations import sys from typing import Callable import copy import functools import itertools import listparser.opml import listparser.common from aiohttp import ClientResponse from bs4 import BeautifulSoup from cachetools.keys import hashkey from minify_html import minify as minify_html impor...
https://github.com/tkem/cachetools/commit/3f073633ed4f36f05b57838a3e5655e14d3e3524
151,062
from __future__ import annotations from typing import Optional from aiohttp import web from . import log async def redirect(_): return web.HTTPFound('https://github.com/Rongronggg9/RSS-to-Telegram-Bot')
null
151,063
from __future__ import annotations from typing import Optional from aiohttp import web from . import log logger = log.getLogger('RSStT.redirect_server') app = web.Application() app.add_routes([web.route('*', '/{tail:.*}', redirect)]) async def run(port: Optional[int] = 5000): runner = web.AppRunner(app) await ...
null
151,064
from __future__ import annotations from typing import Optional, Sequence, Union import re import json from contextlib import suppress from bs4.element import Tag from html import unescape from emoji import emojize from telethon.tl.types import TypeMessageEntity from functools import partial from urllib.parse import url...
null
151,065
from __future__ import annotations from typing import Optional, Sequence, Union import re import json from contextlib import suppress from bs4.element import Tag from html import unescape from emoji import emojize from telethon.tl.types import TypeMessageEntity from functools import partial from urllib.parse import url...
null
151,066
from __future__ import annotations from typing import Optional from collections.abc import Sequence from contextlib import suppress from telethon.extensions.html import parse from telethon.helpers import strip_text, add_surrogate, del_surrogate from telethon.tl.types import TypeMessageEntity from .utils import surrogat...
null
151,067
from __future__ import annotations from typing import Optional from collections.abc import Sequence from contextlib import suppress from telethon.extensions.html import parse from telethon.helpers import strip_text, add_surrogate, del_surrogate from telethon.tl.types import TypeMessageEntity from .utils import surrogat...
null
151,068
from __future__ import annotations from typing import Optional from collections.abc import Sequence from contextlib import suppress from telethon.extensions.html import parse from telethon.helpers import strip_text, add_surrogate, del_surrogate from telethon.tl.types import TypeMessageEntity from .utils import surrogat...
null
151,069
from __future__ import annotations from typing import Optional from collections.abc import Sequence from contextlib import suppress from telethon.extensions.html import parse from telethon.helpers import strip_text, add_surrogate, del_surrogate from telethon.tl.types import TypeMessageEntity from .utils import surrogat...
null
151,070
from __future__ import annotations from collections.abc import Iterator, Iterable, Awaitable from typing import Union, Optional import re import asyncio from bs4 import BeautifulSoup from bs4.element import NavigableString, PageElement, Tag from urllib.parse import urlparse from dataclasses import dataclass from .. imp...
null
151,071
from __future__ import annotations from collections.abc import Iterator, Iterable, Awaitable from typing import Union, Optional import re import asyncio from bs4 import BeautifulSoup from bs4.element import NavigableString, PageElement, Tag from urllib.parse import urlparse from dataclasses import dataclass from .. imp...
:param html: HTML content :param feed_link: feed link (use for resolve relative urls)
151,072
from __future__ import annotations from typing import Union, Optional from typing_extensions import Final from collections.abc import Awaitable import asyncio import time import aiographfix as aiograph from io import BytesIO from bs4 import BeautifulSoup from contextlib import suppress from aiohttp import ClientTimeout...
null
151,073
from __future__ import annotations from typing import Union, Optional from typing_extensions import Final from collections.abc import Awaitable import asyncio import time import aiographfix as aiograph from io import BytesIO from bs4 import BeautifulSoup from contextlib import suppress from aiohttp import ClientTimeout...
null
151,074
from __future__ import annotations from typing import Optional from typing_extensions import Final import matplotlib from math import ceil from PIL import Image from io import BytesIO from bs4 import BeautifulSoup from matplotlib import pyplot as plt from matplotlib.font_manager import FontManager from cjkwrap import f...
null
151,075
from __future__ import annotations from typing import Optional, Union from typing_extensions import Final from abc import ABC, abstractmethod from collections.abc import Callable, Awaitable import asyncio import re from io import BytesIO from collections import defaultdict from telethon.tl.functions.messages import Upl...
null
151,076
from __future__ import annotations from typing import Optional, Union from typing_extensions import Final from abc import ABC, abstractmethod from collections.abc import Callable, Awaitable import asyncio import re from io import BytesIO from collections import defaultdict from telethon.tl.functions.messages import Upl...
null
151,077
from __future__ import annotations from typing import Optional, Union from typing_extensions import Final from abc import ABC, abstractmethod from collections.abc import Callable, Awaitable import asyncio import re from io import BytesIO from collections import defaultdict from telethon.tl.functions.messages import Upl...
null
151,078
from __future__ import annotations from typing import Optional, Any, NoReturn, Union from typing_extensions import Final from collections.abc import Callable from contextlib import suppress from math import ceil from random import shuffle from . import models EffectiveOptions = __EffectiveOptions() class EffectiveTasks...
null
151,079
from __future__ import annotations from typing_extensions import Awaitable import asyncio import logging import colorlog import os import signal from . import env async def exit_handler(prerequisite: Awaitable = None): try: if prerequisite and env.bot.is_connected(): try: await a...
null
151,080
from __future__ import annotations from typing_extensions import Awaitable import asyncio import logging import colorlog import os import signal from . import env getLogger = colorlog.getLogger INFO = colorlog.INFO WARNING = colorlog.WARNING getLogger('aiohttp_retry').setLevel(logger_level_muted) getLogger('asyncio').s...
null
151,081
import numpy as np import torch import torch.utils.data as data import torch.nn.functional as F import os import math import random from glob import glob import os.path as osp from utils import frame_utils from utils.augmentor import FlowAugmentor, SparseFlowAugmentor class MpiSintel(FlowDataset): def __init__(self...
Create the data loader for the corresponding trainign set
151,082
import sys import argparse import os import cv2 import glob import numpy as np import torch from PIL import Image from .raft import RAFT from .utils import flow_viz from .utils.utils import InputPadder DEVICE = 'cuda' def load_image_list(image_files): images = [] for imfile in sorted(image_files): image...
null
151,083
import sys import argparse import os import cv2 import glob import numpy as np import torch from PIL import Image from .raft import RAFT from .utils import flow_viz from .utils.utils import InputPadder DEVICE = 'cuda' class RAFT(nn.Module): def __init__(self, args): super(RAFT, self).__init__() sel...
null
151,084
import torch import torch.nn.functional as F import numpy as np from scipy import interpolate def forward_interpolate(flow): flow = flow.detach().cpu().numpy() dx, dy = flow[0], flow[1] ht, wd = dx.shape x0, y0 = np.meshgrid(np.arange(wd), np.arange(ht)) x1 = x0 + dx y1 = y0 + dy x1 ...
null
151,085
import torch import torch.nn.functional as F import numpy as np from scipy import interpolate The provided code snippet includes necessary dependencies for implementing the `bilinear_sampler` function. Write a Python function `def bilinear_sampler(img, coords, mode='bilinear', mask=False)` to solve the following probl...
Wrapper for grid_sample, uses pixel coordinates
151,086
import torch import torch.nn.functional as F import numpy as np from scipy import interpolate def coords_grid(batch, ht, wd): coords = torch.meshgrid(torch.arange(ht), torch.arange(wd)) coords = torch.stack(coords[::-1], dim=0).float() return coords[None].repeat(batch, 1, 1, 1)
null
151,087
import torch import torch.nn.functional as F import numpy as np from scipy import interpolate def upflow8(flow, mode='bilinear'): new_size = (8 * flow.shape[2], 8 * flow.shape[3]) return 8 * F.interpolate(flow, size=new_size, mode=mode, align_corners=True)
null
151,088
import torch torch.pi = torch.acos(torch.zeros(1)).item() * 2 def _normalized_flow_to_image(normalized_flow: torch.Tensor) -> torch.Tensor: """ Converts a batch of normalized flow to an RGB image. Args: normalized_flow (torch.Tensor): Normalized flow tensor of shape (N, 2, H, W) Returns: ...
Converts a flow to an RGB image. Args: flow (Tensor): Flow of shape (N, 2, H, W) or (2, H, W) and dtype torch.float. Returns: img (Tensor): Image Tensor of dtype uint8 where each color corresponds to a given flow direction. Shape is (N, 3, H, W) or (3, H, W) depending on the input.
151,089
import numpy as np from PIL import Image from os.path import * import re import cv2 TAG_CHAR = np.array([202021.25], np.float32) The provided code snippet includes necessary dependencies for implementing the `writeFlow` function. Write a Python function `def writeFlow(filename,uv,v=None)` to solve the following proble...
Write optical flow to file. If v is None, uv is assumed to contain both u and v channels, stacked in depth. Original code by Deqing Sun, adapted from Daniel Scharstein.
151,090
import numpy as np from PIL import Image from os.path import * import re import cv2 cv2.setNumThreads(0) cv2.ocl.setUseOpenCL(False) def readFlowKITTI(filename): flow = cv2.imread(filename, cv2.IMREAD_ANYDEPTH|cv2.IMREAD_COLOR) flow = flow[:,:,::-1].astype(np.float32) flow, valid = flow[:, :, :2], flow[:, ...
null
151,091
import numpy as np from PIL import Image from os.path import * import re import cv2 cv2.setNumThreads(0) cv2.ocl.setUseOpenCL(False) def readDispKITTI(filename): disp = cv2.imread(filename, cv2.IMREAD_ANYDEPTH) / 256.0 valid = disp > 0.0 flow = np.stack([-disp, np.zeros_like(disp)], -1) return flow, va...
null
151,092
import numpy as np from PIL import Image from os.path import * import re import cv2 cv2.setNumThreads(0) cv2.ocl.setUseOpenCL(False) def writeFlowKITTI(filename, uv): uv = 64.0 * uv + 2**15 valid = np.ones([uv.shape[0], uv.shape[1], 1]) uv = np.concatenate([uv, valid], axis=-1).astype(np.uint16) cv2.im...
null
151,093
import numpy as np from PIL import Image from os.path import * import re import cv2 def readFlow(fn): """ Read .flo file in Middlebury format""" # Code adapted from: # http://stackoverflow.com/questions/28013200/reading-middlebury-flow-files-with-python-bytes-array-numpy # WARNING: this will work on lit...
null
151,094
import os import io import cv2 import random import numpy as np from PIL import Image, ImageOps import zipfile import math import torch import matplotlib import matplotlib.patches as patches from matplotlib.path import Path from matplotlib import pyplot as plt from torchvision import transforms def read_dirnames_under...
null
151,095
import os import io import cv2 import random import numpy as np from PIL import Image, ImageOps import zipfile import math import torch import matplotlib import matplotlib.patches as patches from matplotlib.path import Path from matplotlib import pyplot as plt from torchvision import transforms def get_random_shape(edg...
null
151,096
import os import io import cv2 import random import numpy as np from PIL import Image, ImageOps import zipfile import math import torch import matplotlib import matplotlib.patches as patches from matplotlib.path import Path from matplotlib import pyplot as plt from torchvision import transforms def get_random_shape(edg...
null
151,102
import numpy as np from skimage import measure from scipy import linalg import torch import torch.nn as nn import torch.nn.functional as F from core.utils import to_tensors The provided code snippet includes necessary dependencies for implementing the `calculate_epe` function. Write a Python function `def calculate_ep...
Calculate End point errors.
151,103
import numpy as np from skimage import measure from scipy import linalg import torch import torch.nn as nn import torch.nn.functional as F from core.utils import to_tensors def calculate_psnr(img1, img2): """Calculate PSNR (Peak Signal-to-Noise Ratio). Ref: https://en.wikipedia.org/wiki/Peak_signal-to-noise_rat...
Calculate PSNR and SSIM for images. img1: ndarray, range [0, 255] img2: ndarray, range [0, 255]
151,104
import numpy as np from skimage import measure from scipy import linalg import torch import torch.nn as nn import torch.nn.functional as F from core.utils import to_tensors class InceptionI3d(nn.Module): """Inception-v1 I3D architecture. The model is introduced in: Quo Vadis, Action Recognition? A New M...
null
151,105
import numpy as np from skimage import measure from scipy import linalg import torch import torch.nn as nn import torch.nn.functional as F from core.utils import to_tensors def get_i3d_activations(batched_video, i3d_model, target_endpoint='Logits', ...
Calculate VFID metric. video1: list[PIL.Image] video2: list[PIL.Image]