id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
7,241 | import sglang as sgl
def multi_turn_question(s, question_1, question_2):
def stream():
state = multi_turn_question.run(
question_1="What is the capital of the United States?",
question_2="List two local attractions.",
stream=True
)
for out in state.text_iter():
print(out, e... | null |
7,243 | import json
import time
from argparse import ArgumentParser
import sglang as sgl
from sglang.test.test_utils import (
add_common_sglang_args_and_parse,
select_sglang_backend,
)
from sglang.utils import dump_state_text
from vllm.transformers_utils.tokenizer import get_tokenizer
from data_gen import gen_arguments... | null |
7,244 | import random
import string
random.seed(42)
def gen_prompt(tokenizer, token_num):
def gen_arguments(args, tokenizer):
multi_qas = [{"qas": []} for _ in range(args.num_qa)]
for i in range(args.num_qa):
qas = multi_qas[i]["qas"]
for _ in range(args.turns):
prompt_len = random.randint(... | null |
7,245 | import json
import time
from argparse import ArgumentParser
from concurrent.futures import ThreadPoolExecutor
import requests
from sglang.test.test_utils import add_common_other_args_and_parse
from sglang.utils import dump_state_text
from tqdm import tqdm
from vllm.transformers_utils.tokenizer import get_tokenizer
from... | null |
7,246 | import json
import time
from argparse import ArgumentParser
from concurrent.futures import ThreadPoolExecutor
import requests
from sglang.test.test_utils import add_common_other_args_and_parse
from sglang.utils import dump_state_text
from tqdm import tqdm
from vllm.transformers_utils.tokenizer import get_tokenizer
from... | null |
7,247 | import argparse
import asyncio
import json
import random
import time
from typing import AsyncGenerator, List, Tuple
from tqdm.asyncio import tqdm_asyncio
import aiohttp
import numpy as np
from transformers import PreTrainedTokenizerBase
from vllm.transformers_utils.tokenizer import get_tokenizer
def sample_requests(
... | null |
7,248 | import argparse
import asyncio
import json
import random
import time
from typing import AsyncGenerator, List, Tuple
from tqdm.asyncio import tqdm_asyncio
import aiohttp
import numpy as np
from transformers import PreTrainedTokenizerBase
from vllm.transformers_utils.tokenizer import get_tokenizer
async def get_request(
... | null |
7,249 | import argparse
import json
import os
import time
import numpy as np
import pandas as pd
import tiktoken
from tqdm import tqdm
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
tokenizer = tiktoken.encoding_for_model("gpt-3.5-turbo")
def format_example(df, idx, include_answer=Tr... | null |
7,250 | import argparse
import asyncio
from concurrent.futures import ThreadPoolExecutor
import json
from functools import partial
import os
import time
import numpy as np
import pandas as pd
import tiktoken
from tqdm import tqdm
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm, call_g... | null |
7,251 | import argparse
import json
import time
import os
import sglang as sgl
import tqdm
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import read_jsonl, dump_state_text
from PIL import Image
def image_qa(s, image_file, question):
s += sgl.user(sgl.image(ima... | null |
7,252 | import sglang as sgl
def poignancy_event(s, persona_name, persona_iss, event):
s += "Here is a brief description of " + persona_name + ".\n"
s += persona_iss + "\n"
s += "On the scale of 1 to 10, where 1 is purely mundane (e.g., brushing teeth, making bed) and 10 is extremely poignant (e.g., a break up, co... | null |
7,253 | import sglang as sgl
def poignancy_event_prompt(persona_name, persona_iss, event):
# return prompt and max_tokens
s = ""
s += "Here is a brief description of " + persona_name + ".\n"
s += persona_iss + "\n"
s += "On the scale of 1 to 10, where 1 is purely mundane (e.g., brushing teeth, making bed) ... | null |
7,254 | import sglang as sgl
def generate_event_triple(s, persona_name, action):
s += """Task: Turn the input into (subject, predicate, object).
Input: Sam Johnson is eating breakfast.
Output: (Dolores Murphy, eat, breakfast)
---
Input: Joon Park is brewing coffee.
Output: (Joon Park, brew, coffee)
---
Input: Jane Cook... | null |
7,255 | import sglang as sgl
def generate_event_triple_prompt(persona_name, action):
s = ""
s += """Task: Turn the input into (subject, predicate, object).
Input: Sam Johnson is eating breakfast.
Output: (Dolores Murphy, eat, breakfast)
---
Input: Joon Park is brewing coffee.
Output: (Joon Park, brew, coffee)
---
I... | null |
7,256 | import sglang as sgl
def generate_pronunciatio(s, action):
s += "Convert an action description to an emoji (important: use two or less emojis).\n"
s += "Action description: " + action + ".\n"
s += "Emoji:" + sgl.gen(name="Emoji", max_tokens=6) | null |
7,257 | import sglang as sgl
def generate_pronunciatio_prompt(action):
s = ""
s += "Convert an action description to an emoji (important: use two or less emojis).\n"
s += "Action description: " + action + ".\n"
s += "Emoji:"
return {"prompt": s, "max_tokens": 6, "stop": None} | null |
7,258 | import sglang as sgl
def action_location_sector(
s,
persona_name,
living_sector,
living_sector_areas,
current_sector,
current_sector_areas,
daily_plan,
sector_options,
current_action,
next_action,
):
s += """Task -- choose an appropriate area from the area options for a tas... | null |
7,259 | import sglang as sgl
def action_location_sector_prompt(
persona_name,
living_sector,
living_sector_areas,
current_sector,
current_sector_areas,
daily_plan,
sector_options,
current_action,
next_action,
):
s = ""
s += """Task -- choose an appropriate area from the area option... | null |
7,260 | import sglang as sgl
def action_location_object(s, persona_name, target_sector, target_sector_areas,
current_action, next_action):
s += """
Jane Anderson is in kitchen in Jane Anderson's house.
Jane Anderson is going to Jane Anderson's house that has the following areas: {kitchen, bedro... | null |
7,261 | import sglang as sgl
def action_location_object_prompt(persona_name, target_sector,
target_sector_areas, current_action,
next_action):
s = ""
s += """
Jane Anderson is in kitchen in Jane Anderson's house.
Jane Anderson is going to Jane Anderso... | null |
7,262 | import argparse
import json
import time
import sglang as sgl
from sglang.test.test_utils import (
add_common_sglang_args_and_parse,
select_sglang_backend,
)
from sglang.utils import read_jsonl, dump_state_text
def webthink(s, question, triplets):
s += (
"""Solve a question answering task with inter... | null |
7,263 | import argparse
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import time
from pathlib import Path
from tqdm import tqdm
from sglang.test.test_utils import (
add_common_other_args_and_parse,
call_generate_lightllm,
call_generate_vllm,
call_generate_srt_raw,
... | null |
7,264 | import argparse
import ast
from collections import Counter
import json
import re
import time
import numpy as np
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import read_jsonl, dump_state_text
import sglang as sgl
INVALID = -9999999
def get_answer_value(an... | null |
7,265 | import argparse
import ast
from collections import Counter
import json
import re
import time
import numpy as np
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import read_jsonl, dump_state_text
import sglang as sgl
def most_frequent_number(numbers):
if ... | null |
7,266 | import argparse
import ast
from collections import Counter
import json
import re
import time
import numpy as np
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import read_jsonl, dump_state_text
import sglang as sgl
def propose_plan(s, question, num_branches)... | null |
7,267 | import argparse
import ast
import asyncio
from collections import Counter
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import re
import time
import numpy as np
from tqdm import tqdm
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm,... | null |
7,268 | import argparse
import ast
import asyncio
from collections import Counter
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import re
import time
import numpy as np
from tqdm import tqdm
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm,... | null |
7,269 | import argparse
import ast
import asyncio
from collections import Counter
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import re
import time
import numpy as np
from tqdm import tqdm
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm,... | null |
7,272 | import argparse
import ast
from collections import Counter
import json
import re
import time
import numpy as np
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import read_jsonl, dump_state_text
import sglang as sgl
def propose_plan(s, question, num_branches)... | null |
7,275 | import argparse
import ast
import asyncio
from collections import Counter
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import re
import time
import numpy as np
from tqdm import tqdm
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm,... | null |
7,276 | import argparse
import json
import time
import numpy as np
import sglang as sgl
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import read_jsonl, dump_state_text
system_prompt = (
"Please serve as an impartial judge and rigorously evaluate the quality of the... | null |
7,277 | import argparse
import asyncio
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import time
import numpy as np
from tqdm import tqdm
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm, call_generate_vllm, call_generate_srt_raw
from sglan... | null |
7,278 | import argparse
import json
import time
import sglang as sgl
from sglang.test.test_utils import (
add_common_sglang_args_and_parse,
select_sglang_backend,
)
from sglang.utils import dump_state_text, read_jsonl
def city_gen(s, document):
s += "Please extract the information of a city from the following wikip... | null |
7,279 | import argparse
import json
import time
import sglang as sgl
from sglang.test.test_utils import (
add_common_sglang_args_and_parse,
select_sglang_backend,
)
from sglang.utils import dump_state_text, read_jsonl
def character_gen(s, name):
s += name + " is a character in Harry Potter. Please fill in the follo... | null |
7,280 | import argparse
import json
import time
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import guidance
from sglang.test.test_utils import (
add_common_other_args_and_parse,
call_generate_outlines,
)
from sglang.utils import dump_state_text, read_jsonl
from tqdm import tqdm
def c... | null |
7,281 | import argparse
import json
import time
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import guidance
from sglang.test.test_utils import (
add_common_other_args_and_parse,
call_generate_outlines,
)
from sglang.utils import dump_state_text, read_jsonl
from tqdm import tqdm
def c... | null |
7,282 | import json
import transformers
import wikipedia
t = transformers.AutoTokenizer.from_pretrained(model_path)
def get_content(city_name):
content = str(wikipedia.page(city_name).content)
content = content.replace("\n\n", "\n")
tokens = t.encode(content)
expected_tokens = 3000
truncate_len = int((ex... | null |
7,283 | import argparse
import json
import time
import sglang as sgl
from sglang.lang.ir import REGEX_INT, REGEX_STRING, REGEX_FLOAT
from sglang.test.test_utils import (
add_common_sglang_args_and_parse,
select_sglang_backend,
)
from sglang.utils import dump_state_text, read_jsonl
REGEX_LIST = r"\[(" + REGEX_STRING + "... | null |
7,284 | import argparse
import json
import time
import sglang as sgl
from sglang.lang.ir import REGEX_INT, REGEX_STRING, REGEX_FLOAT
from sglang.test.test_utils import (
add_common_sglang_args_and_parse,
select_sglang_backend,
)
from sglang.utils import dump_state_text, read_jsonl
REGEX_LIST = r"\[(" + REGEX_STRING + "... | null |
7,285 | import argparse
import json
import time
from concurrent.futures import ThreadPoolExecutor
from functools import partial
from sglang.test.test_utils import (
add_common_other_args_and_parse,
call_generate_outlines,
)
from sglang.utils import dump_state_text, read_jsonl
from sglang.lang.ir import REGEX_INT, REGEX... | null |
7,287 | import argparse
import ast
import json
import re
import time
import numpy as np
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import read_jsonl, dump_state_text
INVALID = -9999999
def get_answer_value(answer_str):
answer_str = answer_str.replace(",", "... | null |
7,288 | import argparse
import ast
import asyncio
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import re
import time
import numpy as np
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm, call_generate_vllm, call_generate_srt_raw
from sglang... | null |
7,289 | import argparse
import ast
import asyncio
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import re
import time
import numpy as np
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm, call_generate_vllm, call_generate_srt_raw
from sglang... | null |
7,290 | import argparse
import json
import time
import numpy as np
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import read_jsonl
def get_one_example(lines, i, include_answer):
ret = lines[i]["activity_label"] + ": " + lines[i]["ctx"] + " "
if include_ans... | null |
7,291 | import argparse
import asyncio
from concurrent.futures import ThreadPoolExecutor
import json
from functools import partial
import time
import numpy as np
from sglang.test.test_utils import add_common_other_args_and_parse, call_select_lightllm, call_select_vllm
from sglang.utils import read_jsonl
def get_one_example(lin... | null |
7,292 | import argparse
import json
import time
import numpy as np
import sglang as sgl
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import read_jsonl, dump_state_text
def json_decode(s, document):
s += "Please extract the information of a city from the follo... | null |
7,293 | import argparse
import asyncio
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import time
from tqdm import tqdm
import numpy as np
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm, call_generate_vllm, call_generate_srt_raw
from sglan... | null |
7,294 | import argparse
import json
import time
import numpy as np
import sglang as sgl
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import read_jsonl, dump_state_text
number = 5
def expand_tip(s, topic, tip):
s += (
"""Please expand a tip for a topic into a d... | null |
7,295 | import argparse
import asyncio
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import time
from tqdm import tqdm
import numpy as np
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm, call_generate_vllm, call_generate_srt_raw
from sglan... | null |
7,296 | import argparse
import json
import time
import re
import numpy as np
import sglang as sgl
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import dump_state_text
def line_retrieval(s, prefix, suffix, body_0, body_1, body_2, body_3):
s += prefix + "\n"
... | null |
7,297 | import argparse
from collections import defaultdict
import json
from tqdm import tqdm
import numpy as np
def generate_lines(random_words, num_lines, redirect_ratio):
prefix = "Here is a list of lines, each with its corresponding REGISTER_CONTENT value. Please memorize them. Be prepared to provide the REGISTER_CONT... | null |
7,298 | import argparse
import json
import time
import numpy as np
import sglang as sgl
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import read_jsonl, dump_state_text
def multi_document_qa(s, docs, question):
s += sgl.user_begin()
s += "Pleaes answer a q... | null |
7,299 | import argparse
import asyncio
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import time
from tqdm import tqdm
import numpy as np
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm, call_generate_vllm, call_generate_srt_raw
from sglan... | null |
7,300 | import argparse
import ast
import json
import re
import time
import numpy as np
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
from sglang.utils import read_jsonl, dump_state_text
def get_one_example(lines, i, include_answer):
ret = "Question: " + lines[i]["question"] + "... | null |
7,302 | import argparse
import ast
import asyncio
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import re
import time
import numpy as np
from tqdm import tqdm
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm, call_generate_vllm, call_genera... | null |
7,303 | import argparse
import ast
import asyncio
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import re
import time
import numpy as np
from tqdm import tqdm
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm, call_generate_vllm, call_genera... | null |
7,304 | import argparse
import json
import os
import time
import uuid
import sglang as sgl
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
def load_questions(filename):
questions = []
with open(filename, "r") as fin:
for line in fin:
obj = json.loads(line)... | null |
7,305 | import argparse
import json
import os
import time
import uuid
import sglang as sgl
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
def write_answers(filename, model_id, questions, answers):
with open(os.path.expanduser(filename), "w") as fout:
for i in range(len(a... | null |
7,306 | import argparse
import json
import os
import time
import uuid
import sglang as sgl
from sglang.test.test_utils import add_common_sglang_args_and_parse, select_sglang_backend
def answer_mt_bench(s, question_1, question_2):
s += sgl.system()
s += sgl.user(question_1)
s += sgl.assistant(sgl.gen("answer_1"))
... | null |
7,307 | import argparse
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import os
import time
import uuid
from fastchat.model import get_conversation_template
import requests
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm, call_generate_vll... | null |
7,308 | import argparse
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import json
import os
import time
import uuid
from fastchat.model import get_conversation_template
import requests
from sglang.test.test_utils import add_common_other_args_and_parse, call_generate_lightllm, call_generate_vll... | null |
7,309 | import argparse
import json
import os
from transformers import AutoConfig, AutoTokenizer
def add_image_token(model_path: str):
tokenizer = AutoTokenizer.from_pretrained(model_path)
tokenizer.add_tokens(
["<image_placeholder>"],
special_tokens=True
)
print(tokenizer)
tokenizer.save_... | null |
7,310 | import argparse
import json
import os
from transformers import AutoConfig, AutoTokenizer
def edit_model_config(model_path):
config = AutoConfig.from_pretrained(model_path)
setattr(config, "architectures", ["YiVLForCausalLM"])
setattr(config, "image_token_index", 64002)
print(config)
config.save_p... | null |
7,311 | import os
import re
from setuptools import find_packages, setup
def _read(f):
with open(os.path.join(os.path.dirname(__file__), f)) as f_:
return f_.read().strip() | null |
7,312 | import os
import re
from setuptools import find_packages, setup
def _read_version():
regexp = re.compile(r'^__version__\W*=\W*"([\d.abrc]+)"')
init_py = os.path.join(
os.path.dirname(__file__), "torch_optimizer", "__init__.py"
)
with open(init_py) as f:
for line in f:
match ... | null |
7,313 | import math
import matplotlib.pyplot as plt
import numpy as np
import torch
from hyperopt import fmin, hp, tpe
import torch_optimizer as optim
def rastrigin(tensor, lib=torch):
# https://en.wikipedia.org/wiki/Test_functions_for_optimization
x, y = tensor
A = 10
f = (
A * 2
+ (x**2 - A * ... | null |
7,314 | import math
import matplotlib.pyplot as plt
import numpy as np
import torch
from hyperopt import fmin, hp, tpe
import torch_optimizer as optim
def rosenbrock(tensor):
# https://en.wikipedia.org/wiki/Test_functions_for_optimization
x, y = tensor
return (1 - x) ** 2 + 100 * (y - x**2) ** 2
def execute_steps(
... | null |
7,315 | import math
import matplotlib.pyplot as plt
import numpy as np
import torch
from hyperopt import fmin, hp, tpe
import torch_optimizer as optim
plt.style.use("seaborn-white")
def rastrigin(tensor, lib=torch):
def plot_rastrigin(grad_iter, optimizer_name, lr):
x = np.linspace(-4.5, 4.5, 250)
y = np.linspace(-4.5... | null |
7,316 | import math
import matplotlib.pyplot as plt
import numpy as np
import torch
from hyperopt import fmin, hp, tpe
import torch_optimizer as optim
plt.style.use("seaborn-white")
def rosenbrock(tensor):
# https://en.wikipedia.org/wiki/Test_functions_for_optimization
x, y = tensor
return (1 - x) ** 2 + 100 * (y -... | null |
7,317 | import math
import matplotlib.pyplot as plt
import numpy as np
import torch
from hyperopt import fmin, hp, tpe
import torch_optimizer as optim
def execute_steps(
func, initial_state, optimizer_class, optimizer_config, num_iter=500
):
def execute_experiments(
optimizers, objective, func, plot_func, initial_stat... | null |
7,318 | import math
import matplotlib.pyplot as plt
import numpy as np
import torch
from hyperopt import fmin, hp, tpe
import torch_optimizer as optim
def LookaheadYogi(*a, **kw):
base = optim.Yogi(*a, **kw)
return optim.Lookahead(base) | null |
7,319 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.optim.lr_scheduler import StepLR
from torch.utils.tensorboard import SummaryWriter
from torchvision import datasets, transforms, utils
import torch_optimizer as optim
def train(conf, model, device, train_loader, optimizer, epoch, writer):
... | null |
7,320 | import torch
from torch.optim.optimizer import Optimizer
from .types import OptFloat, OptLossClosure, Params
def _matrix_power(matrix: torch.Tensor, power: float) -> torch.Tensor:
# use CPU for svd for speed up
device = matrix.device
matrix = matrix.cpu()
u, s, v = torch.svd(matrix)
return (u @ s.p... | null |
7,321 | import gepetto.config
class GepettoPlugin(idaapi.plugin_t):
def init(self):
def generate_plugin_select_menu(self):
def run(self, arg):
def term(self):
def PLUGIN_ENTRY():
gepetto.config.load_config() # Loads configuration data from gepetto/config.ini
# Only import the rest of the code af... | null |
7,322 | import configparser
import gettext
import os
from gepetto.models.base import get_model
The provided code snippet includes necessary dependencies for implementing the `update_config` function. Write a Python function `def update_config(section, option, new_value)` to solve the following problem:
Updates a single entry ... | Updates a single entry in the configuration. :param section: The section in which the option is located :param option: The option to update :param new_value: The new value to set :return: |
7,323 | import functools
import json
import re
import textwrap
import idaapi
import ida_hexrays
import idc
import gepetto.config
from gepetto.models.base import get_model
_ = gepetto.config.translate.gettext
The provided code snippet includes necessary dependencies for implementing the `comment_callback` function. Write a Pyt... | Callback that sets a comment at the given address. :param address: The address of the function to comment :param view: A handle to the decompiler window :param response: The comment to add |
7,324 | import functools
import json
import re
import textwrap
import idaapi
import ida_hexrays
import idc
import gepetto.config
from gepetto.models.base import get_model
_ = gepetto.config.translate.gettext
The provided code snippet includes necessary dependencies for implementing the `rename_callback` function. Write a Pyth... | Callback that extracts a JSON array of old names and new names from the response and sets them in the pseudocode. :param address: The address of the function to work on :param view: A handle to the decompiler window :param response: The response from the model :param retries: The number of times that we received invali... |
7,325 | import os
import os.path as osp
import shutil
import sys
import warnings
from setuptools import find_packages, setup
The provided code snippet includes necessary dependencies for implementing the `readme` function. Write a Python function `def readme()` to solve the following problem:
Load README.md.
Here is the func... | Load README.md. |
7,326 | import os
import os.path as osp
import shutil
import sys
import warnings
from setuptools import find_packages, setup
The provided code snippet includes necessary dependencies for implementing the `get_version` function. Write a Python function `def get_version()` to solve the following problem:
Get version of mmrotate... | Get version of mmrotate. |
7,327 | import os
import os.path as osp
import shutil
import sys
import warnings
from setuptools import find_packages, setup
The provided code snippet includes necessary dependencies for implementing the `parse_requirements` function. Write a Python function `def parse_requirements(fname='requirements.txt', with_version=True)... | Parse the package dependencies listed in a requirements file but strips specific versioning information. Args: fname (str): path to requirements file with_version (bool, default=False): if True include version specs Returns: List[str]: list of requirements items CommandLine: python -c "import setup; print(setup.parse_r... |
7,328 | import os
import os.path as osp
import shutil
import sys
import warnings
from setuptools import find_packages, setup
The provided code snippet includes necessary dependencies for implementing the `add_mim_extension` function. Write a Python function `def add_mim_extension()` to solve the following problem:
Add extra f... | Add extra files that are required to support MIM into the package. These files will be added by creating a symlink to the originals if the package is installed in `editable` mode (e.g. pip install -e .), or by copying from the originals otherwise. |
7,329 | import os
import sys
import pytorch_sphinx_theme
version_file = '../../mmrotate/version.py'
def get_version():
with open(version_file, 'r') as f:
exec(compile(f.read(), version_file, 'exec'))
return locals()['__version__'] | null |
7,331 | version_info = parse_version_info(__version__)
The provided code snippet includes necessary dependencies for implementing the `parse_version_info` function. Write a Python function `def parse_version_info(version_str)` to solve the following problem:
Parse version information.
Here is the function:
def parse_version... | Parse version information. |
7,332 | import os
from mmcv.runner import (DistSamplerSeedHook, EpochBasedRunner,
Fp16OptimizerHook, OptimizerHook, build_optimizer,
build_runner)
from mmdet.core import DistEvalHook, EvalHook
from mmdet.datasets import (build_dataloader, build_dataset,
... | null |
7,333 | import mmcv
import numpy as np
import torch
from mmcv.ops import RoIPool
from mmcv.parallel import collate, scatter
from mmdet.datasets import replace_ImageToTensor
from mmdet.datasets.pipelines import Compose
from mmrotate.core import get_multiscale_patch, merge_results, slide_window
The provided code snippet include... | inference patches with the detector. Split huge image(s) into patches and inference them with the detector. Finally, merge patch results on one huge image by nms. Args: model (nn.Module): The loaded detector. img (str | ndarray or): Either an image file or loaded image. sizes (list): The sizes of patches. steps (list):... |
7,334 | import math
import cv2
import numpy as np
import torch
def bbox_flip(bboxes, img_shape, direction='horizontal'):
"""Flip bboxes horizontally or vertically.
Args:
bboxes (Tensor): Shape (..., 5*k)
img_shape (tuple): Image shape.
direction (str): Flip direction, options are "horizontal", "... | Map bboxes from testing scale to original image scale. |
7,335 | import math
import cv2
import numpy as np
import torch
The provided code snippet includes necessary dependencies for implementing the `rbbox2result` function. Write a Python function `def rbbox2result(bboxes, labels, num_classes)` to solve the following problem:
Convert detection results to a list of numpy arrays. Arg... | Convert detection results to a list of numpy arrays. Args: bboxes (torch.Tensor): shape (n, 6) labels (torch.Tensor): shape (n, ) num_classes (int): class number, including background class Returns: list(ndarray): bbox results of each class |
7,336 | import math
import cv2
import numpy as np
import torch
The provided code snippet includes necessary dependencies for implementing the `rbbox2roi` function. Write a Python function `def rbbox2roi(bbox_list)` to solve the following problem:
Convert a list of bboxes to roi format. Args: bbox_list (list[Tensor]): a list o... | Convert a list of bboxes to roi format. Args: bbox_list (list[Tensor]): a list of bboxes corresponding to a batch of images. Returns: Tensor: shape (n, 6), [batch_ind, cx, cy, w, h, a] |
7,337 | import math
import cv2
import numpy as np
import torch
def poly2obb_np_oc(poly):
"""Convert polygons to oriented bounding boxes.
Args:
polys (ndarray): [x0,y0,x1,y1,x2,y2,x3,y3]
Returns:
obbs (ndarray): [x_ctr,y_ctr,w,h,angle]
"""
bboxps = np.array(poly).reshape((4, 2))
rbbox = c... | Convert polygons to oriented bounding boxes. Args: polys (ndarray): [x0,y0,x1,y1,x2,y2,x3,y3] version (Str): angle representations. Returns: obbs (ndarray): [x_ctr,y_ctr,w,h,angle] |
7,338 | import math
import cv2
import numpy as np
import torch
def obb2hbb_oc(rbboxes):
"""Convert oriented bounding boxes to horizontal bounding boxes.
Args:
obbs (torch.Tensor): [x_ctr,y_ctr,w,h,angle]
Returns:
hbbs (torch.Tensor): [x_ctr,y_ctr,w,h,pi/2]
"""
w = rbboxes[:, 2::5]
h = rb... | Convert oriented bounding boxes to horizontal bounding boxes. Args: obbs (torch.Tensor): [x_ctr,y_ctr,w,h,angle] version (Str): angle representations. Returns: hbbs (torch.Tensor): [x_ctr,y_ctr,w,h,-pi/2] |
7,339 | import math
import cv2
import numpy as np
import torch
def obb2poly_np_oc(rbboxes):
"""Convert oriented bounding boxes to polygons.
Args:
obbs (ndarray): [x_ctr,y_ctr,w,h,angle,score]
Returns:
polys (ndarray): [x0,y0,x1,y1,x2,y2,x3,y3,score]
"""
x = rbboxes[:, 0]
y = rbboxes[:, 1... | Convert oriented bounding boxes to polygons. Args: obbs (ndarray): [x_ctr,y_ctr,w,h,angle] version (Str): angle representations. Returns: polys (ndarray): [x0,y0,x1,y1,x2,y2,x3,y3] |
7,340 | import math
import cv2
import numpy as np
import torch
def hbb2obb_oc(hbboxes):
"""Convert horizontal bounding boxes to oriented bounding boxes.
Args:
hbbs (torch.Tensor): [x_lt,y_lt,x_rb,y_rb]
Returns:
obbs (torch.Tensor): [x_ctr,y_ctr,w,h,angle]
"""
x = (hbboxes[..., 0] + hbboxes[.... | Convert horizontal bounding boxes to oriented bounding boxes. Args: hbbs (torch.Tensor): [x_lt,y_lt,x_rb,y_rb] version (Str): angle representations. Returns: obbs (torch.Tensor): [x_ctr,y_ctr,w,h,angle] |
7,341 | import math
import cv2
import numpy as np
import torch
The provided code snippet includes necessary dependencies for implementing the `gaussian2bbox` function. Write a Python function `def gaussian2bbox(gmm)` to solve the following problem:
Convert Gaussian distribution to polygons by SVD. Args: gmm (dict[str, torch.T... | Convert Gaussian distribution to polygons by SVD. Args: gmm (dict[str, torch.Tensor]): Dict of Gaussian distribution. Returns: torch.Tensor: Polygons. |
7,342 | import math
import cv2
import numpy as np
import torch
The provided code snippet includes necessary dependencies for implementing the `gt2gaussian` function. Write a Python function `def gt2gaussian(target)` to solve the following problem:
Convert polygons to Gaussian distributions. Args: target (torch.Tensor): Polygo... | Convert polygons to Gaussian distributions. Args: target (torch.Tensor): Polygons with shape (N, 8). Returns: dict[str, torch.Tensor]: Gaussian distributions. |
7,343 | import mmcv
import numpy as np
import torch
from mmdet.core.bbox.coder.base_bbox_coder import BaseBBoxCoder
from ..builder import ROTATED_BBOX_CODERS
from ..transforms import obb2poly, obb2xyxy, poly2obb
def obb2poly(rbboxes, version='oc'):
"""Convert oriented bounding boxes to polygons.
Args:
obbs (t... | Compute deltas of proposals w.r.t. gt. We usually compute the deltas of x, y, w, h, a, b of proposals w.r.t ground truth bboxes to get regression target. This is the inverse function of :func:`delta2bbox`. Args: proposals (torch.Tensor): Boxes to be transformed, shape (N, ..., 4) gt (torch.Tensor): Gt bboxes to be used... |
7,344 | import mmcv
import numpy as np
import torch
from mmdet.core.bbox.coder.base_bbox_coder import BaseBBoxCoder
from ..builder import ROTATED_BBOX_CODERS
from ..transforms import obb2poly, obb2xyxy, poly2obb
def poly2obb(polys, version='oc'):
"""Convert polygons to oriented bounding boxes.
Args:
polys (to... | Apply deltas to shift/scale base boxes. Typically the rois are anchor or proposed bounding boxes and the deltas are network outputs used to shift/scale those boxes. This is the inverse function of :func:`bbox2delta`. Args: rois (torch.Tensor): Boxes to be transformed. Has shape (N, 4). deltas (torch.Tensor): Encoded of... |
7,345 | import mmcv
import numpy as np
import torch
from mmdet.core.bbox.coder.base_bbox_coder import BaseBBoxCoder
from ..builder import ROTATED_BBOX_CODERS
from ..transforms import norm_angle
def norm_angle(angle, angle_range):
"""Limit the range of angles.
Args:
angle (ndarray): shape(n, ).
angle_r... | We usually compute the deltas of x, y, w, h, a of proposals w.r.t ground truth bboxes to get regression target. This is the inverse function of :func:`delta2bbox`. Args: proposals (torch.Tensor): Boxes to be transformed, shape (N, ..., 4) gt (torch.Tensor): Gt bboxes to be used as base, shape (N, ..., 5) means (Sequenc... |
7,346 | import mmcv
import numpy as np
import torch
from mmdet.core.bbox.coder.base_bbox_coder import BaseBBoxCoder
from ..builder import ROTATED_BBOX_CODERS
from ..transforms import norm_angle
def norm_angle(angle, angle_range):
"""Limit the range of angles.
Args:
angle (ndarray): shape(n, ).
angle_r... | Apply deltas to shift/scale base boxes. Typically the rois are anchor or proposed bounding boxes and the deltas are network outputs used to shift/scale those boxes. This is the inverse function of :func:`bbox2delta`. Args: rois (torch.Tensor): Boxes to be transformed. Has shape (N, 4). deltas (torch.Tensor): Encoded of... |
7,347 | import mmcv
import numpy as np
import torch
from mmdet.core.bbox.coder.base_bbox_coder import BaseBBoxCoder
from ..builder import ROTATED_BBOX_CODERS
from ..transforms import norm_angle
def norm_angle(angle, angle_range):
"""Limit the range of angles.
Args:
angle (ndarray): shape(n, ).
angle_r... | We usually compute the deltas of x, y, w, h, a of proposals w.r.t ground truth bboxes to get regression target. This is the inverse function of :func:`delta2bbox`. Args: proposals (torch.Tensor): Boxes to be transformed, shape (N, ..., 5) gt (torch.Tensor): Gt bboxes to be used as base, shape (N, ..., 5) means (Sequenc... |
7,348 | import mmcv
import numpy as np
import torch
from mmdet.core.bbox.coder.base_bbox_coder import BaseBBoxCoder
from ..builder import ROTATED_BBOX_CODERS
from ..transforms import norm_angle
def norm_angle(angle, angle_range):
"""Limit the range of angles.
Args:
angle (ndarray): shape(n, ).
angle_r... | Apply deltas to shift/scale base boxes. Typically the rois are anchor or proposed bounding boxes and the deltas are network outputs used to shift/scale those boxes. This is the inverse function of :func:`bbox2delta`. Args: rois (torch.Tensor): Boxes to be transformed. Has shape (N, 5). deltas (torch.Tensor): Encoded of... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.