id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
161,065 | import nextcord
from nextcord.ext import commands
class FeedbackModal(nextcord.ui.Modal):
def __init__(self):
super().__init__(
title="Feedback",
custom_id="persistent_modal:feedback",
timeout=None,
)
self.discovered = nextcord.ui.TextInput(
label="How did you discover the bot?",
placeholder="e.g. Discord server, friend, etc.",
required=False,
style=nextcord.TextInputStyle.paragraph,
custom_id="persistent_modal:discovered",
)
self.add_item(self.discovered)
self.rating = nextcord.ui.TextInput(
label="How would you rate the bot out of 10?",
placeholder="10",
max_length=2,
custom_id="persistent_modal:rating",
)
self.add_item(self.rating)
self.improve = nextcord.ui.TextInput(
label="How could the bot improve?",
placeholder="e.g. add more features, improve the UI, etc.",
style=nextcord.TextInputStyle.paragraph,
required=False,
custom_id="persistent_modal:improve",
)
self.add_item(self.improve)
async def callback(self, interaction: nextcord.Interaction):
await interaction.send(
f"Feedback from {interaction.user.mention}:\n"
f"Rating: {self.rating.value}\n"
f"Where they discovered the bot: {self.discovered.value}\n"
f"How could the bot improve: {self.improve.value}\n"
)
async def feedback(interaction: nextcord.Interaction):
await interaction.response.send_modal(FeedbackModal()) | null |
161,066 | import random
import nextcord
from nextcord.ext import commands
bot = commands.Bot(command_prefix="$", description=description, intents=intents)
bot.run("token")
async def on_ready():
print(f"Logged in as {bot.user} (ID: {bot.user.id})") | null |
161,067 | import random
import nextcord
from nextcord.ext import commands
The provided code snippet includes necessary dependencies for implementing the `add` function. Write a Python function `async def add(ctx, left: int, right: int)` to solve the following problem:
Adds two numbers together.
Here is the function:
async def add(ctx, left: int, right: int):
"""Adds two numbers together."""
await ctx.send(left + right) | Adds two numbers together. |
161,068 | import random
import nextcord
from nextcord.ext import commands
The provided code snippet includes necessary dependencies for implementing the `roll` function. Write a Python function `async def roll(ctx, dice: str)` to solve the following problem:
Rolls a dice in NdN format.
Here is the function:
async def roll(ctx, dice: str):
"""Rolls a dice in NdN format."""
try:
rolls, limit = map(int, dice.split("d"))
except ValueError:
await ctx.send("Format has to be in NdN!")
return
result = ", ".join(str(random.randint(1, limit)) for _ in range(rolls))
await ctx.send(result) | Rolls a dice in NdN format. |
161,069 | import random
import nextcord
from nextcord.ext import commands
The provided code snippet includes necessary dependencies for implementing the `choose` function. Write a Python function `async def choose(ctx, *choices: str)` to solve the following problem:
Chooses between multiple choices.
Here is the function:
async def choose(ctx, *choices: str):
"""Chooses between multiple choices."""
await ctx.send(random.choice(choices)) | Chooses between multiple choices. |
161,070 | import random
import nextcord
from nextcord.ext import commands
The provided code snippet includes necessary dependencies for implementing the `repeat` function. Write a Python function `async def repeat(ctx, times: int, content="repeating...")` to solve the following problem:
Repeats a message multiple times.
Here is the function:
async def repeat(ctx, times: int, content="repeating..."):
"""Repeats a message multiple times."""
for _ in range(times):
await ctx.send(content) | Repeats a message multiple times. |
161,071 | import random
import nextcord
from nextcord.ext import commands
The provided code snippet includes necessary dependencies for implementing the `joined` function. Write a Python function `async def joined(ctx, member: nextcord.Member)` to solve the following problem:
Says when a member joined.
Here is the function:
async def joined(ctx, member: nextcord.Member):
"""Says when a member joined."""
await ctx.send(f"{member.name} joined in {member.joined_at}") | Says when a member joined. |
161,072 | import random
import nextcord
from nextcord.ext import commands
The provided code snippet includes necessary dependencies for implementing the `cool` function. Write a Python function `async def cool(ctx)` to solve the following problem:
Says if a user is cool. In reality this just checks if a subcommand is being invoked.
Here is the function:
async def cool(ctx):
"""Says if a user is cool.
In reality this just checks if a subcommand is being invoked.
"""
if ctx.invoked_subcommand is None:
await ctx.send(f"No, {ctx.subcommand_passed} is not cool") | Says if a user is cool. In reality this just checks if a subcommand is being invoked. |
161,073 | import random
import nextcord
from nextcord.ext import commands
The provided code snippet includes necessary dependencies for implementing the `_bot` function. Write a Python function `async def _bot(ctx)` to solve the following problem:
Is the bot cool?
Here is the function:
async def _bot(ctx):
"""Is the bot cool?"""
await ctx.send("Yes, the bot is cool.") | Is the bot cool? |
161,074 | import typing
import nextcord
from nextcord.ext import commands
async def userinfo(ctx, user: nextcord.User):
# In the command signature above, you can see that the `user`
# parameter is typehinted to `nextcord.User`. This means that
# during command invocation we will attempt to convert
# the value passed as `user` to a `nextcord.User` instance.
# The documentation notes what can be converted, in the case of `nextcord.User`
# you pass an ID, mention or username (discrim optional)
# E.g. 80088516616269824, @Danny or Danny#0007
# NOTE: typehinting acts as a converter within the `commands` framework only.
# In standard Python, it is use for documentation and IDE assistance purposes.
# If the conversion is successful, we will have a `nextcord.User` instance
# and can do the following:
user_id = user.id
username = user.name
avatar = user.avatar.url
await ctx.send(f"User found: {user_id} -- {username}\n{avatar}") | null |
161,075 | import typing
import nextcord
from nextcord.ext import commands
async def userinfo_error(ctx, error: commands.CommandError):
# if the conversion above fails for any reason, it will raise `commands.BadArgument`
# so we handle this in this error handler:
if isinstance(error, commands.BadArgument):
return await ctx.send("Couldn't find that user.") | null |
161,076 | import typing
import nextcord
from nextcord.ext import commands
class ChannelOrMemberConverter(commands.Converter):
async def convert(self, ctx, argument: str):
# In this example we have made a custom converter.
# This checks if an input is convertible to a
# `nextcord.Member` or `nextcord.TextChannel` instance from the
# input the user has given us using the pre-existing converters
# that the library provides.
member_converter = commands.MemberConverter()
try:
# Try and convert to a Member instance.
# If this fails, then an exception is raised.
# Otherwise, we just return the converted member value.
member = await member_converter.convert(ctx, argument)
except commands.MemberNotFound:
pass
else:
return member
# Do the same for TextChannel...
textchannel_converter = commands.TextChannelConverter()
try:
channel = await textchannel_converter.convert(ctx, argument)
except commands.ChannelNotFound:
pass
else:
return channel
# If the value could not be converted we can raise an error
# so our error handlers can deal with it in one place.
# The error has to be CommandError derived, so BadArgument works fine here.
raise commands.BadArgument(f'No Member or TextChannel could be converted from "{argument}"')
async def notify(ctx, target: ChannelOrMemberConverter):
# This command signature utilises the custom converter written above
# What will happen during command invocation is that the `target` above will be passed to
# the `argument` parameter of the `ChannelOrMemberConverter.convert` method and
# the conversion will go through the process defined there.
await target.send(f"Hello, {target.name}!") | null |
161,077 | import typing
import nextcord
from nextcord.ext import commands
async def ignore(ctx, target: typing.Union[nextcord.Member, nextcord.TextChannel]):
# This command signature utilises the `typing.Union` typehint.
# The `commands` framework attempts a conversion of each type in this Union *in order*.
# So, it will attempt to convert whatever is passed to `target` to a `nextcord.Member` instance.
# If that fails, it will attempt to convert it to a `nextcord.TextChannel` instance.
# See: https://nextcord.readthedocs.io/en/latest/ext/commands/commands.html#typing-union
# NOTE: If a Union typehint converter fails it will raise `commands.BadUnionArgument`
# instead of `commands.BadArgument`.
# To check the resulting type, `isinstance` is used
if isinstance(target, nextcord.Member):
await ctx.send(f"Member found: {target.mention}, adding them to the ignore list.")
elif isinstance(
target, nextcord.TextChannel
): # this could be an `else` but for completeness' sake.
await ctx.send(f"Channel found: {target.mention}, adding it to the ignore list.") | null |
161,078 | import typing
import nextcord
from nextcord.ext import commands
async def multiply(ctx, number: int, maybe: bool):
# We want an `int` and a `bool` parameter here.
# `bool` is a slightly special case, as shown here:
# See: https://nextcord.readthedocs.io/en/latest/ext/commands/commands.html#bool
if maybe:
return await ctx.send(number * 2)
await ctx.send(number * 5) | null |
161,079 | import nextcord
class MyInteraction(nextcord.Interaction):
async def send_embed(self, *, title: str, description: str):
async def create_embed(interaction: MyInteraction, title: str, description: str):
await interaction.send_embed(title=title, description=description) | null |
161,080 | import random
import nextcord
from nextcord.ext import commands
The provided code snippet includes necessary dependencies for implementing the `guess` function. Write a Python function `async def guess(ctx, number: int)` to solve the following problem:
Guess a random number from 1 to 6.
Here is the function:
async def guess(ctx, number: int):
"""Guess a random number from 1 to 6."""
# explained in a previous example, this gives you
# a random number from 1-6
value = random.randint(1, 6)
# with your new helper function, you can add a
# green check mark if the guess was correct,
# or a red cross mark if it wasn't
await ctx.tick(number == value) | Guess a random number from 1 to 6. |
161,081 | import asyncio
import nextcord
from nextcord.ext import commands
async def editme(ctx):
msg = await ctx.send("10")
await asyncio.sleep(3.0)
await msg.edit(content="40") | null |
161,082 | import nextcord
from nextcord.ext import commands
async def deleteme(ctx):
msg = await ctx.send("I will delete myself now...")
await msg.delete()
# this also works
await ctx.send("Goodbye in 3 seconds...", delete_after=3.0) | null |
161,083 | import asyncio
import random
from typing import Optional
import nextcord
from nextcord.ext import commands
bot = commands.Bot(command_prefix="$", intents=intents)
bot.run("token")
async def guess(ctx, guess: Optional[int] = None):
def is_correct(message):
return message.author == ctx.author and message.content.isdigit()
answer = random.randint(1, 10)
if not guess:
await ctx.send("Guess a number between 1 and 10.")
try:
guess = await bot.wait_for("message", check=is_correct, timeout=5.0)
guess = guess.content
except asyncio.TimeoutError:
return await ctx.send(f"Sorry, you took too long it was {answer}.")
if int(guess) == answer:
await ctx.send("You are right!")
else:
await ctx.send(f"Oops. It is actually {answer}.") | null |
161,084 | import nextcord
from nextcord.ext import commands
async def hello(ctx):
await ctx.reply("Hello!") | null |
161,085 | import asyncio
import aiohttp
import nextcord
async def send_to_webhook(url, content):
# Create a new HTTP session and use it to create webhook object
async with aiohttp.ClientSession() as session:
webhook = nextcord.Webhook.from_url(url, session=session)
await webhook.send(content) | null |
161,086 | import argparse
import functools
import gc
import logging
import math
import os
import random
import shutil
from pathlib import Path
import accelerate
import numpy as np
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
import transformers
from accelerate import Accelerator
from accelerate.logging import get_logger
from accelerate.utils import ProjectConfiguration, set_seed
from datasets import load_dataset
from huggingface_hub import create_repo, upload_folder
from packaging import version
from PIL import Image
from torchvision import transforms
from tqdm.auto import tqdm
from transformers import AutoTokenizer, PretrainedConfig
import diffusers
from diffusers import (
AutoencoderKL,
DDPMScheduler,
UNet2DConditionModel,
UniPCMultistepScheduler,
)
from diffusers.optimization import get_scheduler
from diffusers.utils import check_min_version, is_wandb_available
from diffusers.utils.import_utils import is_xformers_available
from configs.utils import instantiate_from_config
from omegaconf import OmegaConf
from Adapter.extra_condition.model_edge import pidinet
from models.unet import UNet
from basicsr.utils import tensor2img
import cv2
from huggingface_hub import hf_hub_url
import subprocess
import shlex
def import_model_class_from_model_name_or_path(
pretrained_model_name_or_path: str, revision: str, subfolder: str = "text_encoder"
):
text_encoder_config = PretrainedConfig.from_pretrained(
pretrained_model_name_or_path, subfolder=subfolder, revision=revision
)
model_class = text_encoder_config.architectures[0]
if model_class == "CLIPTextModel":
from transformers import CLIPTextModel
return CLIPTextModel
elif model_class == "CLIPTextModelWithProjection":
from transformers import CLIPTextModelWithProjection
return CLIPTextModelWithProjection
else:
raise ValueError(f"{model_class} is not supported.") | null |
161,087 | import argparse
import functools
import gc
import logging
import math
import os
import random
import shutil
from pathlib import Path
import accelerate
import numpy as np
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
import transformers
from accelerate import Accelerator
from accelerate.logging import get_logger
from accelerate.utils import ProjectConfiguration, set_seed
from datasets import load_dataset
from huggingface_hub import create_repo, upload_folder
from packaging import version
from PIL import Image
from torchvision import transforms
from tqdm.auto import tqdm
from transformers import AutoTokenizer, PretrainedConfig
import diffusers
from diffusers import (
AutoencoderKL,
DDPMScheduler,
UNet2DConditionModel,
UniPCMultistepScheduler,
)
from diffusers.optimization import get_scheduler
from diffusers.utils import check_min_version, is_wandb_available
from diffusers.utils.import_utils import is_xformers_available
from configs.utils import instantiate_from_config
from omegaconf import OmegaConf
from Adapter.extra_condition.model_edge import pidinet
from models.unet import UNet
from basicsr.utils import tensor2img
import cv2
from huggingface_hub import hf_hub_url
import subprocess
import shlex
def parse_args(input_args=None):
parser = argparse.ArgumentParser(description="Simple example of a T2I-Adapter training script.")
parser.add_argument(
"--pretrained_model_name_or_path",
type=str,
default=None,
required=True,
help="Path to pretrained model or model identifier from huggingface.co/models.",
)
parser.add_argument(
"--pretrained_vae_model_name_or_path",
type=str,
default=None,
help="Path to an improved VAE to stabilize training. For more details check out: https://github.com/huggingface/diffusers/pull/4038.",
)
parser.add_argument(
"--revision",
type=str,
default=None,
required=False,
help=(
"Revision of pretrained model identifier from huggingface.co/models. Trainable model components should be"
" float32 precision."
),
)
parser.add_argument(
"--tokenizer_name",
type=str,
default=None,
help="Pretrained tokenizer name or path if not the same as model_name",
)
parser.add_argument(
"--output_dir",
type=str,
default="experiments/adapter_xl_sketch",
help="The output directory where the model predictions and checkpoints will be written.",
)
parser.add_argument("--seed", type=int, default=None, help="A seed for reproducible training.")
parser.add_argument(
"--resolution",
type=int,
default=1024,
help=(
"The resolution for input images, all the images in the train/validation dataset will be resized to this"
" resolution"
),
)
parser.add_argument(
"--crops_coords_top_left_h",
type=int,
default=0,
help=("Coordinate for (the height) to be included in the crop coordinate embeddings needed by SDXL UNet."),
)
parser.add_argument(
"--crops_coords_top_left_w",
type=int,
default=0,
help=("Coordinate for (the height) to be included in the crop coordinate embeddings needed by SDXL UNet."),
)
parser.add_argument(
"--train_batch_size", type=int, default=4, help="Batch size (per device) for the training dataloader."
)
parser.add_argument("--num_train_epochs", type=int, default=1)
parser.add_argument(
"--max_train_steps",
type=int,
default=None,
help="Total number of training steps to perform. If provided, overrides num_train_epochs.",
)
parser.add_argument(
"--checkpointing_steps",
type=int,
default=1000,
help=(
"Save a checkpoint of the training state every X updates. Checkpoints can be used for resuming training via `--resume_from_checkpoint`. "
"In the case that the checkpoint is better than the final trained model, the checkpoint can also be used for inference."
"Using a checkpoint for inference requires separate loading of the original pipeline and the individual checkpointed model components."
"See https://huggingface.co/docs/diffusers/main/en/training/dreambooth#performing-inference-using-a-saved-checkpoint for step by step"
"instructions."
),
)
parser.add_argument(
"--gradient_accumulation_steps",
type=int,
default=1,
help="Number of updates steps to accumulate before performing a backward/update pass.",
)
parser.add_argument(
"--gradient_checkpointing",
action="store_true",
help="Whether or not to use gradient checkpointing to save memory at the expense of slower backward pass.",
)
parser.add_argument(
"--learning_rate",
type=float,
default=5e-6,
help="Initial learning rate (after the potential warmup period) to use.",
)
parser.add_argument(
"--scale_lr",
action="store_true",
default=False,
help="Scale the learning rate by the number of GPUs, gradient accumulation steps, and batch size.",
)
parser.add_argument(
"--config",
type=str,
default="configs/train/Adapter-XL-sketch.yaml",
help=('config to load the train model and dataset'),
)
parser.add_argument(
"--lr_scheduler",
type=str,
default="constant",
help=(
'The scheduler type to use. Choose between ["linear", "cosine", "cosine_with_restarts", "polynomial",'
' "constant", "constant_with_warmup"]'
),
)
parser.add_argument(
"--lr_warmup_steps", type=int, default=500, help="Number of steps for the warmup in the lr scheduler."
)
parser.add_argument(
"--lr_num_cycles",
type=int,
default=1,
help="Number of hard resets of the lr in cosine_with_restarts scheduler.",
)
parser.add_argument("--lr_power", type=float, default=1.0, help="Power factor of the polynomial scheduler.")
parser.add_argument(
"--use_8bit_adam", action="store_true", help="Whether or not to use 8-bit Adam from bitsandbytes."
)
parser.add_argument(
"--dataloader_num_workers",
type=int,
default=0,
help=(
"Number of subprocesses to use for data loading. 0 means that the data will be loaded in the main process."
),
)
parser.add_argument("--adam_beta1", type=float, default=0.9, help="The beta1 parameter for the Adam optimizer.")
parser.add_argument("--adam_beta2", type=float, default=0.999, help="The beta2 parameter for the Adam optimizer.")
parser.add_argument("--adam_weight_decay", type=float, default=1e-2, help="Weight decay to use.")
parser.add_argument("--adam_epsilon", type=float, default=1e-08, help="Epsilon value for the Adam optimizer")
parser.add_argument("--max_grad_norm", default=1.0, type=float, help="Max gradient norm.")
parser.add_argument(
"--logging_dir",
type=str,
default="logs",
help=(
"[TensorBoard](https://www.tensorflow.org/tensorboard) log directory. Will default to"
" *output_dir/runs/**CURRENT_DATETIME_HOSTNAME***."
),
)
parser.add_argument(
"--allow_tf32",
action="store_true",
help=(
"Whether or not to allow TF32 on Ampere GPUs. Can be used to speed up training. For more information, see"
" https://pytorch.org/docs/stable/notes/cuda.html#tensorfloat-32-tf32-on-ampere-devices"
),
)
parser.add_argument(
"--report_to",
type=str,
default="tensorboard",
help=(
'The integration to report the results and logs to. Supported platforms are `"tensorboard"`'
' (default), `"wandb"` and `"comet_ml"`. Use `"all"` to report to all integrations.'
),
)
parser.add_argument(
"--mixed_precision",
type=str,
default=None,
choices=["no", "fp16", "bf16"],
help=(
"Whether to use mixed precision. Choose between fp16 and bf16 (bfloat16). Bf16 requires PyTorch >="
" 1.10.and an Nvidia Ampere GPU. Default to the value of accelerate config of the current system or the"
" flag passed with the `accelerate.launch` command. Use this argument to override the accelerate config."
),
)
parser.add_argument(
"--enable_xformers_memory_efficient_attention", action="store_true", help="Whether or not to use xformers."
)
parser.add_argument(
"--set_grads_to_none",
action="store_true",
help=(
"Save more memory by using setting grads to None instead of zero. Be aware, that this changes certain"
" behaviors, so disable this argument if it causes any problems. More info:"
" https://pytorch.org/docs/stable/generated/torch.optim.Optimizer.zero_grad.html"
),
)
parser.add_argument(
"--proportion_empty_prompts",
type=float,
default=0,
help="Proportion of image prompts to be replaced with empty strings. Defaults to 0 (no prompt replacement).",
)
parser.add_argument(
"--tracker_project_name",
type=str,
default="sd_xl_train_t2i_adapter ",
help=(
"The `project_name` argument passed to Accelerator.init_trackers for"
" more information see https://huggingface.co/docs/accelerate/v0.17.0/en/package_reference/accelerator#accelerate.Accelerator"
),
)
if input_args is not None:
args = parser.parse_args(input_args)
else:
args = parser.parse_args()
if args.proportion_empty_prompts < 0 or args.proportion_empty_prompts > 1:
raise ValueError("`--proportion_empty_prompts` must be in the range [0, 1].")
if args.resolution % 8 != 0:
raise ValueError(
"`--resolution` must be divisible by 8 for consistently sized encoded images between the VAE and T2I-Adapter."
)
return args | null |
161,088 | import argparse
import functools
import gc
import logging
import math
import os
import random
import shutil
from pathlib import Path
import accelerate
import numpy as np
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
import transformers
from accelerate import Accelerator
from accelerate.logging import get_logger
from accelerate.utils import ProjectConfiguration, set_seed
from datasets import load_dataset
from huggingface_hub import create_repo, upload_folder
from packaging import version
from PIL import Image
from torchvision import transforms
from tqdm.auto import tqdm
from transformers import AutoTokenizer, PretrainedConfig
import diffusers
from diffusers import (
AutoencoderKL,
DDPMScheduler,
UNet2DConditionModel,
UniPCMultistepScheduler,
)
from diffusers.optimization import get_scheduler
from diffusers.utils import check_min_version, is_wandb_available
from diffusers.utils.import_utils import is_xformers_available
from configs.utils import instantiate_from_config
from omegaconf import OmegaConf
from Adapter.extra_condition.model_edge import pidinet
from models.unet import UNet
from basicsr.utils import tensor2img
import cv2
from huggingface_hub import hf_hub_url
import subprocess
import shlex
def encode_prompt(prompt_batch, text_encoders, tokenizers, proportion_empty_prompts, is_train=True):
prompt_embeds_list = []
captions = []
for caption in prompt_batch:
if random.random() < proportion_empty_prompts:
captions.append("")
elif isinstance(caption, str):
captions.append(caption)
elif isinstance(caption, (list, np.ndarray)):
# take a random caption if there are multiple
captions.append(random.choice(caption) if is_train else caption[0])
with torch.no_grad():
for tokenizer, text_encoder in zip(tokenizers, text_encoders):
text_inputs = tokenizer(
captions,
padding="max_length",
max_length=tokenizer.model_max_length,
truncation=True,
return_tensors="pt",
)
text_input_ids = text_inputs.input_ids
prompt_embeds = text_encoder(
text_input_ids.to(text_encoder.device),
output_hidden_states=True,
)
# We are only ALWAYS interested in the pooled output of the final text encoder
pooled_prompt_embeds = prompt_embeds[0]
prompt_embeds = prompt_embeds.hidden_states[-2]
bs_embed, seq_len, _ = prompt_embeds.shape
prompt_embeds = prompt_embeds.view(bs_embed, seq_len, -1)
prompt_embeds_list.append(prompt_embeds)
prompt_embeds = torch.concat(prompt_embeds_list, dim=-1)
pooled_prompt_embeds = pooled_prompt_embeds.view(bs_embed, -1)
return prompt_embeds, pooled_prompt_embeds | null |
161,089 | import argparse
import functools
import gc
import logging
import math
import os
import random
import shutil
from pathlib import Path
import accelerate
import numpy as np
import torch
import torch.nn.functional as F
import torch.utils.checkpoint
import transformers
from accelerate import Accelerator
from accelerate.logging import get_logger
from accelerate.utils import ProjectConfiguration, set_seed
from datasets import load_dataset
from huggingface_hub import create_repo, upload_folder
from packaging import version
from PIL import Image
from torchvision import transforms
from tqdm.auto import tqdm
from transformers import AutoTokenizer, PretrainedConfig
import diffusers
from diffusers import (
AutoencoderKL,
DDPMScheduler,
UNet2DConditionModel,
UniPCMultistepScheduler,
)
from diffusers.optimization import get_scheduler
from diffusers.utils import check_min_version, is_wandb_available
from diffusers.utils.import_utils import is_xformers_available
from configs.utils import instantiate_from_config
from omegaconf import OmegaConf
from Adapter.extra_condition.model_edge import pidinet
from models.unet import UNet
from basicsr.utils import tensor2img
import cv2
from huggingface_hub import hf_hub_url
import subprocess
import shlex
def random_threshold(edge, low_threshold=0.3, high_threshold=0.8):
threshold = round(random.uniform(low_threshold, high_threshold), 1)
edge = edge > threshold
return edge | null |
161,090 | import copy
import gradio as gr
import torch
from basicsr.utils import tensor2img
import os
from huggingface_hub import hf_hub_url
import subprocess
import shlex
import cv2
from omegaconf import OmegaConf
from demo import create_demo_sketch, create_demo_canny, create_demo_pose
from Adapter.Sampling import diffusion_inference
from configs.utils import instantiate_from_config
from Adapter.extra_condition.api import get_cond_model, ExtraCondition
from Adapter.extra_condition import api
from Adapter.inference_base import get_base_argument_parser
torch.set_grad_enabled(False)
global_opt = parser.parse_args()
global_opt.device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
mpler = diffusion_inference('stabilityai/stable-diffusion-xl-base-1.0')
def instantiate_from_config(config):
if not "target" in config:
if config == '__is_first_stage__':
return None
elif config == "__is_unconditional__":
return None
raise KeyError("Expected key `target` to instantiate.")
return get_obj_from_str(config["target"])(**config.get("params", dict()))
class ExtraCondition(Enum):
sketch = 0
keypose = 1
seg = 2
depth = 3
canny = 4
style = 5
color = 6
openpose = 7
edge = 8
zoedepth = 9
def get_cond_model(opt, cond_type: ExtraCondition):
if cond_type == ExtraCondition.sketch:
from Adapter.extra_condition.model_edge import pidinet
model = pidinet()
ckp = torch.load('checkpoints/table5_pidinet.pth', map_location='cpu')['state_dict']
model.load_state_dict({k.replace('module.', ''): v for k, v in ckp.items()}, strict=True)
model.to(opt.device)
return model
elif cond_type == ExtraCondition.seg:
raise NotImplementedError
elif cond_type == ExtraCondition.keypose:
import mmcv
from mmdet.apis import init_detector
from mmpose.apis import init_pose_model
det_config = 'configs/mm/faster_rcnn_r50_fpn_coco.py'
det_checkpoint = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
pose_config = 'configs/mm/hrnet_w48_coco_256x192.py'
pose_checkpoint = 'checkpoints/hrnet_w48_coco_256x192-b9e0b3ab_20200708.pth'
det_config_mmcv = mmcv.Config.fromfile(det_config)
det_model = init_detector(det_config_mmcv, det_checkpoint, device=opt.device)
pose_config_mmcv = mmcv.Config.fromfile(pose_config)
pose_model = init_pose_model(pose_config_mmcv, pose_checkpoint, device=opt.device)
return {'pose_model': pose_model, 'det_model': det_model}
elif cond_type == ExtraCondition.depth:
from Adapter.extra_condition.midas.api import MiDaSInference
model = MiDaSInference(model_type='dpt_hybrid').to(opt.device)
return model
elif cond_type == ExtraCondition.zoedepth:
from handyinfer.depth_estimation import init_depth_estimation_model
model = init_depth_estimation_model('ZoeD_N', device=opt.device)
return model
elif cond_type == ExtraCondition.canny:
return None
elif cond_type == ExtraCondition.style:
from transformers import CLIPProcessor, CLIPVisionModel
version = 'openai/clip-vit-large-patch14'
processor = CLIPProcessor.from_pretrained(version)
clip_vision_model = CLIPVisionModel.from_pretrained(version).to(opt.device)
return {'processor': processor, 'clip_vision_model': clip_vision_model}
elif cond_type == ExtraCondition.color:
return None
elif cond_type == ExtraCondition.openpose:
from Adapter.extra_condition.openpose.api import OpenposeInference
model = OpenposeInference().to(opt.device)
return model
elif cond_type == ExtraCondition.edge:
return None
else:
raise NotImplementedError
def run(input_image, in_type, prompt, a_prompt, n_prompt, ddim_steps, scale, seed, cond_name, con_strength):
in_type = in_type.lower()
prompt = prompt+', '+a_prompt
config = OmegaConf.load(f'configs/inference/Adapter-XL-{cond_name}.yaml')
# Adapter creation
adapter_config = config.model.params.adapter_config
adapter = instantiate_from_config(adapter_config).cuda()
adapter.load_state_dict(torch.load(config.model.params.adapter_config.pretrained))
cond_model = get_cond_model(global_opt, getattr(ExtraCondition, cond_name))
process_cond_module = getattr(api, f'get_cond_{cond_name}')
# diffusion generation
cond = process_cond_module(
global_opt,
input_image,
cond_inp_type = in_type,
cond_model = cond_model
)
with torch.no_grad():
adapter_features = adapter(cond)
for i in range(len(adapter_features)):
adapter_features[i] = adapter_features[i]*con_strength
result = sampler.inference(
prompt = prompt,
prompt_n = n_prompt,
steps = ddim_steps,
adapter_features = copy.deepcopy(adapter_features),
guidance_scale = scale,
size = (cond.shape[-2], cond.shape[-1]),
seed= seed,
)
im_cond = tensor2img(cond)
return result[:,:,::-1], im_cond | null |
161,091 | import numpy as np
import os
import pytorch_lightning as pl
import torch
import webdataset as wds
from torchvision.transforms import transforms
from configs.utils import instantiate_from_config
The provided code snippet includes necessary dependencies for implementing the `dict_collation_fn` function. Write a Python function `def dict_collation_fn(samples, combine_tensors=True, combine_scalars=True)` to solve the following problem:
Take a list of samples (as dictionary) and create a batch, preserving the keys. If `tensors` is True, `ndarray` objects are combined into tensor batches. :param dict samples: list of samples :param bool tensors: whether to turn lists of ndarrays into a single ndarray :returns: single sample consisting of a batch :rtype: dict
Here is the function:
def dict_collation_fn(samples, combine_tensors=True, combine_scalars=True):
"""Take a list of samples (as dictionary) and create a batch, preserving the keys.
If `tensors` is True, `ndarray` objects are combined into
tensor batches.
:param dict samples: list of samples
:param bool tensors: whether to turn lists of ndarrays into a single ndarray
:returns: single sample consisting of a batch
:rtype: dict
"""
keys = set.intersection(*[set(sample.keys()) for sample in samples])
batched = {key: [] for key in keys}
for s in samples:
[batched[key].append(s[key]) for key in batched]
result = {}
for key in batched:
if isinstance(batched[key][0], (int, float)):
if combine_scalars:
result[key] = np.array(list(batched[key]))
elif isinstance(batched[key][0], torch.Tensor):
if combine_tensors:
result[key] = torch.stack(list(batched[key]))
elif isinstance(batched[key][0], np.ndarray):
if combine_tensors:
result[key] = np.array(list(batched[key]))
else:
result[key] = list(batched[key])
return result | Take a list of samples (as dictionary) and create a batch, preserving the keys. If `tensors` is True, `ndarray` objects are combined into tensor batches. :param dict samples: list of samples :param bool tensors: whether to turn lists of ndarrays into a single ndarray :returns: single sample consisting of a batch :rtype: dict |
161,092 | import importlib
import math
import cv2
import torch
import numpy as np
import os
from safetensors.torch import load_file
from inspect import isfunction
from PIL import Image, ImageDraw, ImageFont
def log_txt_as_img(wh, xc, size=10):
# wh a tuple of (width, height)
# xc a list of captions to plot
b = len(xc)
txts = list()
for bi in range(b):
txt = Image.new("RGB", wh, color="white")
draw = ImageDraw.Draw(txt)
font = ImageFont.truetype('assets/DejaVuSans.ttf', size=size)
nc = int(40 * (wh[0] / 256))
lines = "\n".join(xc[bi][start:start + nc] for start in range(0, len(xc[bi]), nc))
try:
draw.text((0, 0), lines, fill="black", font=font)
except UnicodeEncodeError:
print("Cant encode string for logging. Skipping.")
txt = np.array(txt).transpose(2, 0, 1) / 127.5 - 1.0
txts.append(txt)
txts = np.stack(txts)
txts = torch.tensor(txts)
return txts | null |
161,093 | import importlib
import math
import cv2
import torch
import numpy as np
import os
from safetensors.torch import load_file
from inspect import isfunction
from PIL import Image, ImageDraw, ImageFont
def ismap(x):
if not isinstance(x, torch.Tensor):
return False
return (len(x.shape) == 4) and (x.shape[1] > 3) | null |
161,094 | import importlib
import math
import cv2
import torch
import numpy as np
import os
from safetensors.torch import load_file
from inspect import isfunction
from PIL import Image, ImageDraw, ImageFont
def isimage(x):
if not isinstance(x, torch.Tensor):
return False
return (len(x.shape) == 4) and (x.shape[1] == 3 or x.shape[1] == 1) | null |
161,095 | import importlib
import math
import cv2
import torch
import numpy as np
import os
from safetensors.torch import load_file
from inspect import isfunction
from PIL import Image, ImageDraw, ImageFont
The provided code snippet includes necessary dependencies for implementing the `mean_flat` function. Write a Python function `def mean_flat(tensor)` to solve the following problem:
https://github.com/openai/guided-diffusion/blob/27c20a8fab9cb472df5d6bdd6c8d11c8f430b924/guided_diffusion/nn.py#L86 Take the mean over all non-batch dimensions.
Here is the function:
def mean_flat(tensor):
"""
https://github.com/openai/guided-diffusion/blob/27c20a8fab9cb472df5d6bdd6c8d11c8f430b924/guided_diffusion/nn.py#L86
Take the mean over all non-batch dimensions.
"""
return tensor.mean(dim=list(range(1, len(tensor.shape)))) | https://github.com/openai/guided-diffusion/blob/27c20a8fab9cb472df5d6bdd6c8d11c8f430b924/guided_diffusion/nn.py#L86 Take the mean over all non-batch dimensions. |
161,096 | import importlib
import math
import cv2
import torch
import numpy as np
import os
from safetensors.torch import load_file
from inspect import isfunction
from PIL import Image, ImageDraw, ImageFont
def count_params(model, verbose=False):
total_params = sum(p.numel() for p in model.parameters())
if verbose:
print(f"{model.__class__.__name__} has {total_params * 1.e-6:.2f} M params.")
return total_params | null |
161,097 | import importlib
import math
import cv2
import torch
import numpy as np
import os
from safetensors.torch import load_file
from inspect import isfunction
from PIL import Image, ImageDraw, ImageFont
def instantiate_from_config(config):
def read_state_dict(checkpoint_file, print_global_state=False):
def load_model_from_config(config, ckpt, vae_ckpt=None, verbose=False):
print(f"Loading model from {ckpt}")
sd = read_state_dict(ckpt)
model = instantiate_from_config(config.model)
m, u = model.load_state_dict(sd, strict=False)
if len(m) > 0 and verbose:
print("missing keys:")
print(m)
if len(u) > 0 and verbose:
print("unexpected keys:")
print(u)
if 'anything' in ckpt.lower() and vae_ckpt is None:
vae_ckpt = 'models/anything-v4.0.vae.pt'
if vae_ckpt is not None and vae_ckpt != 'None':
print(f"Loading vae model from {vae_ckpt}")
vae_sd = torch.load(vae_ckpt, map_location="cpu")
if "global_step" in vae_sd:
print(f"Global Step: {vae_sd['global_step']}")
sd = vae_sd["state_dict"]
m, u = model.first_stage_model.load_state_dict(sd, strict=False)
if len(m) > 0 and verbose:
print("missing keys:")
print(m)
if len(u) > 0 and verbose:
print("unexpected keys:")
print(u)
model.cuda()
model.eval()
return model | null |
161,098 | import gradio as gr
def create_demo_sketch(run):
cond_name = gr.State(value='sketch')
with gr.Blocks() as demo:
with gr.Row():
gr.Markdown('## Control Stable Diffusion-XL with Sketch Maps')
with gr.Row():
with gr.Column():
input_image = gr.Image(source='upload', type='numpy')
prompt = gr.Textbox(label='Prompt')
run_button = gr.Button(label='Run')
in_type = gr.Radio(
choices=["Image", "Sketch"],
label=f"Input type for Sketch",
interactive=True,
value="Image",
)
with gr.Accordion('Advanced options', open=False):
con_strength = gr.Slider(label='Control Strength',
minimum=0.0,
maximum=1.0,
value=1.0,
step=0.1)
ddim_steps = gr.Slider(label='Steps',
minimum=1,
maximum=100,
value=20,
step=1)
scale = gr.Slider(label='Guidance Scale',
minimum=0.1,
maximum=30.0,
value=7.5,
step=0.1)
seed = gr.Slider(label='Seed',
minimum=-1,
maximum=2147483647,
step=1,
randomize=True)
a_prompt = gr.Textbox(
label='Added Prompt',
value='in real world, high quality')
n_prompt = gr.Textbox(
label='Negative Prompt',
value='extra digit, fewer digits, cropped, worst quality, low quality'
)
with gr.Column():
result_gallery = gr.Gallery(label='Output',
show_label=False,
elem_id='gallery').style(
grid=2, height='auto')
ips = [
input_image, in_type, prompt, a_prompt, n_prompt,
ddim_steps, scale, seed, cond_name, con_strength
]
run_button.click(fn=run,
inputs=ips,
outputs=[result_gallery],
api_name='sketch')
return demo | null |
161,099 | import gradio as gr
def create_demo_canny(run):
cond_name = gr.State(value='canny')
with gr.Blocks() as demo:
with gr.Row():
gr.Markdown('## Control Stable Diffusion-XL with Canny Maps')
with gr.Row():
with gr.Column():
input_image = gr.Image(source='upload', type='numpy')
prompt = gr.Textbox(label='Prompt')
run_button = gr.Button(label='Run')
in_type = gr.Radio(
choices=["Image", "Canny"],
label=f"Input type for Canny",
interactive=True,
value="Image",
)
with gr.Accordion('Advanced options', open=False):
con_strength = gr.Slider(label='Control Strength',
minimum=0.0,
maximum=1.0,
value=1.0,
step=0.1)
ddim_steps = gr.Slider(label='Steps',
minimum=1,
maximum=100,
value=20,
step=1)
scale = gr.Slider(label='Guidance Scale',
minimum=0.1,
maximum=30.0,
value=7.5,
step=0.1)
seed = gr.Slider(label='Seed',
minimum=-1,
maximum=2147483647,
step=1,
randomize=True)
a_prompt = gr.Textbox(
label='Added Prompt',
value='in real world, high quality')
n_prompt = gr.Textbox(
label='Negative Prompt',
value='extra digit, fewer digits, cropped, worst quality, low quality'
)
with gr.Column():
result_gallery = gr.Gallery(label='Output',
show_label=False,
elem_id='gallery').style(
grid=2, height='auto')
ips = [
input_image, in_type, prompt, a_prompt, n_prompt,
ddim_steps, scale, seed, cond_name, con_strength
]
run_button.click(fn=run,
inputs=ips,
outputs=[result_gallery],
api_name='canny')
return demo | null |
161,100 | import gradio as gr
def create_demo_pose(run):
cond_name = gr.State(value='openpose')
in_type = gr.State(value='Image')
with gr.Blocks() as demo:
with gr.Row():
gr.Markdown('## Control Stable Diffusion-XL with Keypoint Maps')
with gr.Row():
with gr.Column():
input_image = gr.Image(source='upload', type='numpy')
prompt = gr.Textbox(label='Prompt')
run_button = gr.Button(label='Run')
with gr.Accordion('Advanced options', open=False):
con_strength = gr.Slider(label='Control Strength',
minimum=0.0,
maximum=1.0,
value=1.0,
step=0.1)
ddim_steps = gr.Slider(label='Steps',
minimum=1,
maximum=100,
value=20,
step=1)
scale = gr.Slider(label='Guidance Scale',
minimum=0.1,
maximum=30.0,
value=7.5,
step=0.1)
seed = gr.Slider(label='Seed',
minimum=-1,
maximum=2147483647,
step=1,
randomize=True)
a_prompt = gr.Textbox(
label='Added Prompt',
value='in real world, high quality')
n_prompt = gr.Textbox(
label='Negative Prompt',
value='extra digit, fewer digits, cropped, worst quality, low quality'
)
with gr.Column():
result_gallery = gr.Gallery(label='Output',
show_label=False,
elem_id='gallery').style(
grid=2, height='auto')
ips = [
input_image, in_type, prompt, a_prompt, n_prompt,
ddim_steps, scale, seed, cond_name, con_strength
]
run_button.click(fn=run,
inputs=ips,
outputs=[result_gallery],
api_name='openpose')
return demo | null |
161,101 | from transformers import PretrainedConfig
import numpy as np
import cv2
def import_model_class_from_model_name_or_path(
pretrained_model_name_or_path: str, revision: str, subfolder: str = "text_encoder"
):
text_encoder_config = PretrainedConfig.from_pretrained(
pretrained_model_name_or_path, subfolder=subfolder, revision=revision
)
model_class = text_encoder_config.architectures[0]
if model_class == "CLIPTextModel":
from transformers import CLIPTextModel
return CLIPTextModel
elif model_class == "CLIPTextModelWithProjection":
from transformers import CLIPTextModelWithProjection
return CLIPTextModelWithProjection
else:
raise ValueError(f"{model_class} is not supported.") | null |
161,102 | from enum import Enum, unique
import cv2
import torch
from basicsr.utils import img2tensor
from PIL import Image
from torch import autocast
from Adapter.utils import resize_numpy_image
def resize_numpy_image(image, max_resolution=1024 * 1024, resize_short_edge=None):
def get_cond_sketch(opt, cond_image, cond_inp_type, cond_model=None):
if isinstance(cond_image, str):
edge = cv2.imread(cond_image)
else:
# for gradio input, pay attention, it's rgb numpy
edge = cv2.cvtColor(cond_image, cv2.COLOR_RGB2BGR)
edge = resize_numpy_image(edge, max_resolution=opt.max_resolution, resize_short_edge=opt.resize_short_edge)
opt.H, opt.W = edge.shape[:2]
if cond_inp_type == 'sketch':
edge = img2tensor(edge)[0].unsqueeze(0).unsqueeze(0) / 255.
edge = edge.to(opt.device)
elif cond_inp_type == 'image':
edge = img2tensor(edge).unsqueeze(0) / 255.
edge = cond_model(edge.to(opt.device))[-1]
else:
raise NotImplementedError
# edge = 1-edge # for white background
edge = edge > 0.5
edge = edge.float()
return edge | null |
161,103 | from enum import Enum, unique
import cv2
import torch
from basicsr.utils import img2tensor
from PIL import Image
from torch import autocast
from Adapter.utils import resize_numpy_image
def resize_numpy_image(image, max_resolution=1024 * 1024, resize_short_edge=None):
h, w = image.shape[:2]
if resize_short_edge is not None:
k = resize_short_edge / min(h, w)
else:
k = max_resolution / (h * w)
k = k**0.5
h = int(np.round(h * k / 64)) * 64
w = int(np.round(w * k / 64)) * 64
image = cv2.resize(image, (w, h), interpolation=cv2.INTER_LANCZOS4)
return image
def get_cond_seg(opt, cond_image, cond_inp_type='image', cond_model=None):
if isinstance(cond_image, str):
seg = cv2.imread(cond_image)
else:
seg = cv2.cvtColor(cond_image, cv2.COLOR_RGB2BGR)
seg = resize_numpy_image(seg, max_resolution=opt.max_resolution, resize_short_edge=opt.resize_short_edge)
opt.H, opt.W = seg.shape[:2]
if cond_inp_type == 'seg':
seg = img2tensor(seg).unsqueeze(0) / 255.
seg = seg.to(opt.device)
else:
raise NotImplementedError
return seg | null |
161,104 | from enum import Enum, unique
import cv2
import torch
from basicsr.utils import img2tensor
from PIL import Image
from torch import autocast
from Adapter.utils import resize_numpy_image
def resize_numpy_image(image, max_resolution=1024 * 1024, resize_short_edge=None):
h, w = image.shape[:2]
if resize_short_edge is not None:
k = resize_short_edge / min(h, w)
else:
k = max_resolution / (h * w)
k = k**0.5
h = int(np.round(h * k / 64)) * 64
w = int(np.round(w * k / 64)) * 64
image = cv2.resize(image, (w, h), interpolation=cv2.INTER_LANCZOS4)
return image
def get_cond_keypose(opt, cond_image, cond_inp_type='image', cond_model=None):
if isinstance(cond_image, str):
pose = cv2.imread(cond_image)
else:
pose = cv2.cvtColor(cond_image, cv2.COLOR_RGB2BGR)
pose = resize_numpy_image(pose, max_resolution=opt.max_resolution, resize_short_edge=opt.resize_short_edge)
opt.H, opt.W = pose.shape[:2]
if cond_inp_type == 'keypose':
pose = img2tensor(pose).unsqueeze(0) / 255.
pose = pose.to(opt.device)
elif cond_inp_type == 'image':
from Adapter.extra_condition.utils import imshow_keypoints
from mmdet.apis import inference_detector
from mmpose.apis import (inference_top_down_pose_model, process_mmdet_results)
# mmpose seems not compatible with autocast fp16
with autocast("cuda", dtype=torch.float32):
mmdet_results = inference_detector(cond_model['det_model'], pose)
# keep the person class bounding boxes.
person_results = process_mmdet_results(mmdet_results, 1)
# optional
return_heatmap = False
dataset = cond_model['pose_model'].cfg.data['test']['type']
# e.g. use ('backbone', ) to return backbone feature
output_layer_names = None
pose_results, returned_outputs = inference_top_down_pose_model(
cond_model['pose_model'],
pose,
person_results,
bbox_thr=0.2,
format='xyxy',
dataset=dataset,
dataset_info=None,
return_heatmap=return_heatmap,
outputs=output_layer_names)
# show the results
pose = imshow_keypoints(pose, pose_results, radius=2, thickness=2)
pose = img2tensor(pose).unsqueeze(0) / 255.
pose = pose.to(opt.device)
else:
raise NotImplementedError
return pose | null |
161,105 | from enum import Enum, unique
import cv2
import torch
from basicsr.utils import img2tensor
from PIL import Image
from torch import autocast
from Adapter.utils import resize_numpy_image
def resize_numpy_image(image, max_resolution=1024 * 1024, resize_short_edge=None):
h, w = image.shape[:2]
if resize_short_edge is not None:
k = resize_short_edge / min(h, w)
else:
k = max_resolution / (h * w)
k = k**0.5
h = int(np.round(h * k / 64)) * 64
w = int(np.round(w * k / 64)) * 64
image = cv2.resize(image, (w, h), interpolation=cv2.INTER_LANCZOS4)
return image
def get_cond_depth(opt, cond_image, cond_inp_type='image', cond_model=None):
if isinstance(cond_image, str):
depth = cv2.imread(cond_image)
else:
depth = cv2.cvtColor(cond_image, cv2.COLOR_RGB2BGR)
depth = resize_numpy_image(depth, max_resolution=opt.max_resolution, resize_short_edge=opt.resize_short_edge)
opt.H, opt.W = depth.shape[:2]
if cond_inp_type == 'depth':
depth = img2tensor(depth).unsqueeze(0) / 255.
depth = depth.to(opt.device)
elif cond_inp_type == 'image':
depth = img2tensor(depth).unsqueeze(0) / 127.5 - 1.0
depth = cond_model(depth.to(opt.device)).repeat(1, 3, 1, 1)
depth -= torch.min(depth)
depth /= torch.max(depth)
else:
raise NotImplementedError
return depth | null |
161,106 | from enum import Enum, unique
import cv2
import torch
from basicsr.utils import img2tensor
from PIL import Image
from torch import autocast
from Adapter.utils import resize_numpy_image
def resize_numpy_image(image, max_resolution=1024 * 1024, resize_short_edge=None):
def get_cond_zoedepth(opt, cond_image, cond_inp_type='image', cond_model=None):
if isinstance(cond_image, str):
depth = cv2.imread(cond_image)
else:
depth = cv2.cvtColor(cond_image, cv2.COLOR_RGB2BGR)
depth = resize_numpy_image(depth, max_resolution=opt.max_resolution, resize_short_edge=opt.resize_short_edge)
opt.H, opt.W = depth.shape[:2]
if cond_inp_type == 'zoedepth':
depth = img2tensor(depth).unsqueeze(0) / 255.
depth = depth.to(opt.device)
elif cond_inp_type == 'image':
depth = img2tensor(depth).unsqueeze(0) / 255.
with autocast("cuda", dtype=torch.float32):
depth = cond_model.infer(depth.to(opt.device))
depth = depth.repeat(1, 3, 1, 1)
else:
raise NotImplementedError
return depth | null |
161,107 | from enum import Enum, unique
import cv2
import torch
from basicsr.utils import img2tensor
from PIL import Image
from torch import autocast
from Adapter.utils import resize_numpy_image
def resize_numpy_image(image, max_resolution=1024 * 1024, resize_short_edge=None):
def get_cond_canny(opt, cond_image, cond_inp_type='image', cond_model=None):
if isinstance(cond_image, str):
canny = cv2.imread(cond_image)
else:
canny = cv2.cvtColor(cond_image, cv2.COLOR_RGB2BGR)
canny = resize_numpy_image(canny, max_resolution=opt.max_resolution, resize_short_edge=opt.resize_short_edge)
opt.H, opt.W = canny.shape[:2]
if cond_inp_type == 'canny':
canny = img2tensor(canny)[0:1].unsqueeze(0) / 255.
canny = canny.to(opt.device)
elif cond_inp_type == 'image':
canny = cv2.Canny(canny, 100, 200)[..., None]
canny = img2tensor(canny).unsqueeze(0) / 255.
canny = canny.to(opt.device)
else:
raise NotImplementedError
return canny | null |
161,108 | from enum import Enum, unique
import cv2
import torch
from basicsr.utils import img2tensor
from PIL import Image
from torch import autocast
from Adapter.utils import resize_numpy_image
def get_cond_style(opt, cond_image, cond_inp_type='image', cond_model=None):
assert cond_inp_type == 'image'
if isinstance(cond_image, str):
style = Image.open(cond_image)
else:
# numpy image to PIL image
style = Image.fromarray(cond_image)
style_for_clip = cond_model['processor'](images=style, return_tensors="pt")['pixel_values']
style_feat = cond_model['clip_vision_model'](style_for_clip.to(opt.device))['last_hidden_state']
return style_feat | null |
161,109 | from enum import Enum, unique
import cv2
import torch
from basicsr.utils import img2tensor
from PIL import Image
from torch import autocast
from Adapter.utils import resize_numpy_image
def resize_numpy_image(image, max_resolution=1024 * 1024, resize_short_edge=None):
h, w = image.shape[:2]
if resize_short_edge is not None:
k = resize_short_edge / min(h, w)
else:
k = max_resolution / (h * w)
k = k**0.5
h = int(np.round(h * k / 64)) * 64
w = int(np.round(w * k / 64)) * 64
image = cv2.resize(image, (w, h), interpolation=cv2.INTER_LANCZOS4)
return image
def get_cond_color(opt, cond_image, cond_inp_type='image', cond_model=None):
if isinstance(cond_image, str):
color = cv2.imread(cond_image)
else:
color = cv2.cvtColor(cond_image, cv2.COLOR_RGB2BGR)
color = resize_numpy_image(color, max_resolution=opt.max_resolution, resize_short_edge=opt.resize_short_edge)
opt.H, opt.W = color.shape[:2]
if cond_inp_type == 'image':
color = cv2.resize(color, (opt.W // 64, opt.H // 64), interpolation=cv2.INTER_CUBIC)
color = cv2.resize(color, (opt.W, opt.H), interpolation=cv2.INTER_NEAREST)
color = img2tensor(color).unsqueeze(0) / 255.
color = color.to(opt.device)
return color | null |
161,110 | from enum import Enum, unique
import cv2
import torch
from basicsr.utils import img2tensor
from PIL import Image
from torch import autocast
from Adapter.utils import resize_numpy_image
def resize_numpy_image(image, max_resolution=1024 * 1024, resize_short_edge=None):
h, w = image.shape[:2]
if resize_short_edge is not None:
k = resize_short_edge / min(h, w)
else:
k = max_resolution / (h * w)
k = k**0.5
h = int(np.round(h * k / 64)) * 64
w = int(np.round(w * k / 64)) * 64
image = cv2.resize(image, (w, h), interpolation=cv2.INTER_LANCZOS4)
return image
def get_cond_openpose(opt, cond_image, cond_inp_type='image', cond_model=None):
if isinstance(cond_image, str):
openpose_keypose = cv2.imread(cond_image)
else:
openpose_keypose = cv2.cvtColor(cond_image, cv2.COLOR_RGB2BGR)
openpose_keypose = resize_numpy_image(
openpose_keypose, max_resolution=opt.max_resolution, resize_short_edge=opt.resize_short_edge)
opt.H, opt.W = openpose_keypose.shape[:2]
if cond_inp_type == 'openpose':
openpose_keypose = img2tensor(openpose_keypose).unsqueeze(0) / 255.
openpose_keypose = openpose_keypose.to(opt.device)
elif cond_inp_type == 'image':
with autocast('cuda', dtype=torch.float32):
w, h = openpose_keypose.shape[:2]
openpose_keypose = cv2.resize(openpose_keypose, (h//2, w//2))
openpose_keypose = cond_model(openpose_keypose)
openpose_keypose = cv2.resize(openpose_keypose, (h, w))[:,:,::-1]
openpose_keypose = img2tensor(openpose_keypose).unsqueeze(0) / 255.
openpose_keypose = openpose_keypose.to(opt.device)
else:
raise NotImplementedError
return openpose_keypose | null |
161,111 | from enum import Enum, unique
import cv2
import torch
from basicsr.utils import img2tensor
from PIL import Image
from torch import autocast
from Adapter.utils import resize_numpy_image
def resize_numpy_image(image, max_resolution=1024 * 1024, resize_short_edge=None):
def get_cond_edge(opt, cond_image, cond_inp_type='image', cond_model=None):
if isinstance(cond_image, str):
edge = cv2.imread(cond_image)
else:
edge = cv2.cvtColor(cond_image, cv2.COLOR_RGB2BGR)
edge = resize_numpy_image(edge, max_resolution=opt.max_resolution, resize_short_edge=opt.resize_short_edge)
opt.H, opt.W = edge.shape[:2]
if cond_inp_type == 'edge':
edge = img2tensor(edge)[0:1].unsqueeze(0) / 255.
edge = edge.to(opt.device)
elif cond_inp_type == 'image':
edge = cv2.cvtColor(edge, cv2.COLOR_RGB2GRAY) / 1.0
blur = cv2.blur(edge, (4, 4))
edge = ((edge - blur) + 128)[..., None]
edge = img2tensor(edge).unsqueeze(0) / 255.
edge = edge.to(opt.device)
else:
raise NotImplementedError
return edge | null |
161,112 | from enum import Enum, unique
import cv2
import torch
from basicsr.utils import img2tensor
from PIL import Image
from torch import autocast
from Adapter.utils import resize_numpy_image
def get_adapter_feature(inputs, adapters):
ret_feat_map = None
ret_feat_seq = None
if not isinstance(inputs, list):
inputs = [inputs]
adapters = [adapters]
for input, adapter in zip(inputs, adapters):
cur_feature = adapter['model'](input)
if isinstance(cur_feature, list):
if ret_feat_map is None:
ret_feat_map = list(map(lambda x: x * adapter['cond_weight'], cur_feature))
else:
ret_feat_map = list(map(lambda x, y: x + y * adapter['cond_weight'], ret_feat_map, cur_feature))
else:
if ret_feat_seq is None:
ret_feat_seq = cur_feature * adapter['cond_weight']
else:
ret_feat_seq = torch.cat([ret_feat_seq, cur_feature * adapter['cond_weight']], dim=1)
return ret_feat_map, ret_feat_seq | null |
161,114 | import math
import cv2
import matplotlib
import numpy as np
def transfer(model, model_weights):
transfered_model_weights = {}
for weights_name in model.state_dict().keys():
transfered_model_weights[weights_name] = model_weights['.'.join(weights_name.split('.')[1:])]
return transfered_model_weights | null |
161,115 | import math
import cv2
import matplotlib
import numpy as np
def draw_bodypose(canvas, candidate, subset):
stickwidth = 4
limbSeq = [[2, 3], [2, 6], [3, 4], [4, 5], [6, 7], [7, 8], [2, 9], [9, 10], \
[10, 11], [2, 12], [12, 13], [13, 14], [2, 1], [1, 15], [15, 17], \
[1, 16], [16, 18], [3, 17], [6, 18]]
colors = [[255, 0, 0], [255, 85, 0], [255, 170, 0], [255, 255, 0], [170, 255, 0], [85, 255, 0], [0, 255, 0], \
[0, 255, 85], [0, 255, 170], [0, 255, 255], [0, 170, 255], [0, 85, 255], [0, 0, 255], [85, 0, 255], \
[170, 0, 255], [255, 0, 255], [255, 0, 170], [255, 0, 85]]
for i in range(18):
for n in range(len(subset)):
index = int(subset[n][i])
if index == -1:
continue
x, y = candidate[index][0:2]
cv2.circle(canvas, (int(x), int(y)), 4, colors[i], thickness=-1)
for i in range(17):
for n in range(len(subset)):
index = subset[n][np.array(limbSeq[i]) - 1]
if -1 in index:
continue
cur_canvas = canvas.copy()
Y = candidate[index.astype(int), 0]
X = candidate[index.astype(int), 1]
mX = np.mean(X)
mY = np.mean(Y)
length = ((X[0] - X[1])**2 + (Y[0] - Y[1])**2)**0.5
angle = math.degrees(math.atan2(X[0] - X[1], Y[0] - Y[1]))
polygon = cv2.ellipse2Poly((int(mY), int(mX)), (int(length / 2), stickwidth), int(angle), 0, 360, 1)
cv2.fillConvexPoly(cur_canvas, polygon, colors[i])
canvas = cv2.addWeighted(canvas, 0.4, cur_canvas, 0.6, 0)
# plt.imsave("preview.jpg", canvas[:, :, [2, 1, 0]])
# plt.imshow(canvas[:, :, [2, 1, 0]])
return canvas | null |
161,116 | import math
import cv2
import matplotlib
import numpy as np
def draw_handpose(canvas, all_hand_peaks, show_number=False):
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], [17, 18], [18, 19], [19, 20]]
for peaks in all_hand_peaks:
for ie, e in enumerate(edges):
if np.sum(np.all(peaks[e], axis=1) == 0) == 0:
x1, y1 = peaks[e[0]]
x2, y2 = peaks[e[1]]
cv2.line(
canvas, (x1, y1), (x2, y2),
matplotlib.colors.hsv_to_rgb([ie / float(len(edges)), 1.0, 1.0]) * 255,
thickness=2)
for i, keyponit in enumerate(peaks):
x, y = keyponit
cv2.circle(canvas, (x, y), 4, (0, 0, 255), thickness=-1)
if show_number:
cv2.putText(canvas, str(i), (x, y), cv2.FONT_HERSHEY_SIMPLEX, 0.3, (0, 0, 0), lineType=cv2.LINE_AA)
return canvas | null |
161,117 | import math
import cv2
import matplotlib
import numpy as np
The provided code snippet includes necessary dependencies for implementing the `handDetect` function. Write a Python function `def handDetect(candidate, subset, oriImg)` to solve the following problem:
return value: [[x, y, w, True if left hand else False]]. width=height since the network require squared input. x, y is the coordinate of top left
Here is the function:
def handDetect(candidate, subset, oriImg):
# right hand: wrist 4, elbow 3, shoulder 2
# left hand: wrist 7, elbow 6, shoulder 5
ratioWristElbow = 0.33
detect_result = []
image_height, image_width = oriImg.shape[0:2]
for person in subset.astype(int):
# if any of three not detected
has_left = np.sum(person[[5, 6, 7]] == -1) == 0
has_right = np.sum(person[[2, 3, 4]] == -1) == 0
if not (has_left or has_right):
continue
hands = []
#left hand
if has_left:
left_shoulder_index, left_elbow_index, left_wrist_index = person[[5, 6, 7]]
x1, y1 = candidate[left_shoulder_index][:2]
x2, y2 = candidate[left_elbow_index][:2]
x3, y3 = candidate[left_wrist_index][:2]
hands.append([x1, y1, x2, y2, x3, y3, True])
# right hand
if has_right:
right_shoulder_index, right_elbow_index, right_wrist_index = person[[2, 3, 4]]
x1, y1 = candidate[right_shoulder_index][:2]
x2, y2 = candidate[right_elbow_index][:2]
x3, y3 = candidate[right_wrist_index][:2]
hands.append([x1, y1, x2, y2, x3, y3, False])
for x1, y1, x2, y2, x3, y3, is_left in hands:
# pos_hand = pos_wrist + ratio * (pos_wrist - pos_elbox) = (1 + ratio) * pos_wrist - ratio * pos_elbox
# handRectangle.x = posePtr[wrist*3] + ratioWristElbow * (posePtr[wrist*3] - posePtr[elbow*3]);
# handRectangle.y = posePtr[wrist*3+1] + ratioWristElbow * (posePtr[wrist*3+1] - posePtr[elbow*3+1]);
# const auto distanceWristElbow = getDistance(poseKeypoints, person, wrist, elbow);
# const auto distanceElbowShoulder = getDistance(poseKeypoints, person, elbow, shoulder);
# handRectangle.width = 1.5f * fastMax(distanceWristElbow, 0.9f * distanceElbowShoulder);
x = x3 + ratioWristElbow * (x3 - x2)
y = y3 + ratioWristElbow * (y3 - y2)
distanceWristElbow = math.sqrt((x3 - x2)**2 + (y3 - y2)**2)
distanceElbowShoulder = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
width = 1.5 * max(distanceWristElbow, 0.9 * distanceElbowShoulder)
# x-y refers to the center --> offset to topLeft point
# handRectangle.x -= handRectangle.width / 2.f;
# handRectangle.y -= handRectangle.height / 2.f;
x -= width / 2
y -= width / 2 # width = height
# overflow the image
if x < 0: x = 0
if y < 0: y = 0
width1 = width
width2 = width
if x + width > image_width: width1 = image_width - x
if y + width > image_height: width2 = image_height - y
width = min(width1, width2)
# the max hand box value is 20 pixels
if width >= 20:
detect_result.append([int(x), int(y), int(width), is_left])
'''
return value: [[x, y, w, True if left hand else False]].
width=height since the network require squared input.
x, y is the coordinate of top left
'''
return detect_result | return value: [[x, y, w, True if left hand else False]]. width=height since the network require squared input. x, y is the coordinate of top left |
161,119 | import math
import cv2
import matplotlib
import numpy as np
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
if C == 1:
return np.concatenate([x, x, x], axis=2)
if C == 4:
color = x[:, :, 0:3].astype(np.float32)
alpha = x[:, :, 3:4].astype(np.float32) / 255.0
y = color * alpha + 255.0 * (1.0 - alpha)
y = y.clip(0, 255).astype(np.uint8)
return y | null |
161,120 | import math
import cv2
import matplotlib
import numpy as np
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)) * 64
W = int(np.round(W / 64.0)) * 64
img = cv2.resize(input_image, (W, H), interpolation=cv2.INTER_LANCZOS4 if k > 1 else cv2.INTER_AREA)
return img | null |
161,121 | import torch
import torch.nn as nn
from collections import OrderedDict
def make_layers(block, no_relu_layers):
layers = []
for layer_name, v in block.items():
if 'pool' in layer_name:
layer = nn.MaxPool2d(kernel_size=v[0], stride=v[1], padding=v[2])
layers.append((layer_name, layer))
else:
conv2d = nn.Conv2d(in_channels=v[0], out_channels=v[1], kernel_size=v[2], stride=v[3], padding=v[4])
layers.append((layer_name, conv2d))
if layer_name not in no_relu_layers:
layers.append(('relu_' + layer_name, nn.ReLU(inplace=True)))
return nn.Sequential(OrderedDict(layers)) | null |
161,122 | import argparse
import torch
from omegaconf import OmegaConf
DEFAULT_NEGATIVE_PROMPT = 'extra digit, fewer digits, cropped, worst quality, low quality'
The provided code snippet includes necessary dependencies for implementing the `get_base_argument_parser` function. Write a Python function `def get_base_argument_parser() -> argparse.ArgumentParser` to solve the following problem:
get the base argument parser for inference scripts
Here is the function:
def get_base_argument_parser() -> argparse.ArgumentParser:
"""get the base argument parser for inference scripts"""
parser = argparse.ArgumentParser()
parser.add_argument(
'--outdir',
type=str,
help='dir to write results to',
default=None,
)
parser.add_argument(
'--prompt',
type=str,
default='',
help='positive prompt',
)
parser.add_argument(
'--neg_prompt',
type=str,
default=DEFAULT_NEGATIVE_PROMPT,
help='negative prompt',
)
parser.add_argument(
'--cond_path',
type=str,
default=None,
help='condition image path',
)
parser.add_argument(
'--cond_inp_type',
type=str,
default='image',
help='the type of the input condition image, take depth T2I as example, the input can be raw image, '
'which depth will be calculated, or the input can be a directly a depth map image',
)
parser.add_argument(
'--sampler',
type=str,
default='ddim',
choices=['ddim', 'plms'],
help='sampling algorithm, currently, only ddim and plms are supported, more are on the way',
)
parser.add_argument(
'--steps',
type=int,
default=50,
help='number of sampling steps',
)
parser.add_argument(
'--max_resolution',
type=float,
default=1024 * 1024,
help='max image height * width, only for computer with limited vram',
)
parser.add_argument(
'--resize_short_edge',
type=int,
default=None,
help='resize short edge of the input image, if this arg is set, max_resolution will not be used',
)
parser.add_argument(
'--C',
type=int,
default=4,
help='latent channels',
)
parser.add_argument(
'--f',
type=int,
default=8,
help='downsampling factor',
)
parser.add_argument(
'--scale',
type=float,
default=7.5,
help='unconditional guidance scale: eps = eps(x, empty) + scale * (eps(x, cond) - eps(x, empty))',
)
parser.add_argument(
'--cond_tau',
type=float,
default=1.0,
help='timestamp parameter that determines until which step the adapter is applied, '
'similar as Prompt-to-Prompt tau',
)
parser.add_argument(
'--cond_weight',
type=float,
default=1.0,
help='the adapter features are multiplied by the cond_weight. The larger the cond_weight, the more aligned '
'the generated image and condition will be, but the generated quality may be reduced',
)
parser.add_argument(
'--seed',
type=int,
default=42,
)
parser.add_argument(
'--n_samples',
type=int,
default=4,
help='# of samples to generate',
)
return parser | get the base argument parser for inference scripts |
161,125 | import torch
import torch.nn as nn
from collections import OrderedDict
def get_parameter_dtype(parameter: torch.nn.Module):
try:
params = tuple(parameter.parameters())
if len(params) > 0:
return params[0].dtype
buffers = tuple(parameter.buffers())
if len(buffers) > 0:
return buffers[0].dtype
except StopIteration:
# For torch.nn.DataParallel compatibility in PyTorch 1.5
def find_tensor_attributes(module: torch.nn.Module) -> List[Tuple[str, Tensor]]:
tuples = [(k, v) for k, v in module.__dict__.items() if torch.is_tensor(v)]
return tuples
gen = parameter._named_members(get_members_fn=find_tensor_attributes)
first_tuple = next(gen)
return first_tuple[1].dtype | null |
161,126 | import pathlib
from setuptools import setup, find_packages
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:
Load version from file.
Here is the function:
def get_version():
"""Load version from file."""
version_file = open("VERSION")
return version_file.read().strip() | Load version from file. |
161,127 | import pathlib
from setuptools import setup, find_packages
The provided code snippet includes necessary dependencies for implementing the `get_requirements` function. Write a Python function `def get_requirements()` to solve the following problem:
Load requirements from file.
Here is the function:
def get_requirements():
"""Load requirements from file."""
requirements_file = open("requirements.txt")
return requirements_file.readlines() | Load requirements from file. |
161,128 | from colorsys import hsv_to_rgb
def interpolate(weight, x, y):
"""Linear interpolation between x and y, given a weight."""
return x * weight + (1 - weight) * y
The provided code snippet includes necessary dependencies for implementing the `score_to_rgb_color` function. Write a Python function `def score_to_rgb_color(score, score_min, score_max)` to solve the following problem:
Convert a score to a color.
Here is the function:
def score_to_rgb_color(score, score_min, score_max):
"""Convert a score to a color."""
normalized_score = max(0, (score - score_min) / (score_max - score_min))
hsv_color = (interpolate(normalized_score, 0.33, 0), 1, 1)
rgb_color = hsv_to_rgb(*hsv_color)
rgb_color = tuple(int(255 * value) for value in rgb_color)
return f"rgb{rgb_color}" | Convert a score to a color. |
161,129 | import sys
import html
from pylint.interfaces import IReporter
from pylint.reporters import *
from pylint.lint import Run
from utils import score_to_rgb_color
class MyReporterClass(BaseReporter):
"""Report messages and layouts."""
__implements__ = IReporter
name = "myreporter"
extension = "myreporter"
def __init__(self, output=sys.stdout):
BaseReporter.__init__(self, output)
self.messages = []
def handle_message(self, msg):
"""Manage message of different type and in the context of path."""
self.messages.append(
{
"type": msg.category,
"module": msg.module,
"obj": msg.obj,
"line": msg.line,
"column": msg.column,
"path": msg.path,
"symbol": msg.symbol,
"message": html.escape(msg.msg or "", quote=False),
"message-id": msg.msg_id,
}
)
def display_messages(self, layout):
"""Do nothing."""
def display_reports(self, layout):
"""Do nothing."""
def _display(self, layout):
"""Do nothing."""
The provided code snippet includes necessary dependencies for implementing the `register` function. Write a Python function `def register(linter)` to solve the following problem:
Register the reporter classes with the linter.
Here is the function:
def register(linter):
"""Register the reporter classes with the linter."""
linter.register_reporter(MyReporterClass) | Register the reporter classes with the linter. |
161,130 | from time import time
import logging
from functools import wraps
from colorama import Fore, Style
import logging
The provided code snippet includes necessary dependencies for implementing the `log_init_time` function. Write a Python function `def log_init_time(logger: logging.Logger, level=logging.DEBUG)` to solve the following problem:
Decorator for logging a class init time.
Here is the function:
def log_init_time(logger: logging.Logger, level=logging.DEBUG):
"""Decorator for logging a class init time."""
def inner(func):
"""Inner decorator for logging a class init time."""
@wraps(func)
def wrapper_func(self: type, *args, **kwargs):
"""Wrapper for logging a class init time."""
init_time = time()
func(self, *args, **kwargs)
class_name = str(self).split(" ", maxsplit=1)[0].split(".")[-1]
logger.log(
level, "Built %s in %.3fs", class_name, time() - init_time, stacklevel=2
)
return wrapper_func
return inner | Decorator for logging a class init time. |
161,131 | from time import time
import logging
from functools import wraps
from colorama import Fore, Style
import logging
The provided code snippet includes necessary dependencies for implementing the `get_logger` function. Write a Python function `def get_logger(name: str) -> logging.Logger` to solve the following problem:
Get the logger for the current module given it's name. Args: name (str): Name of the module usualy obtained using '__main___' Returns: logging.Logger: Logger for the given module name.
Here is the function:
def get_logger(name: str) -> logging.Logger:
"""Get the logger for the current module given it's name.
Args:
name (str): Name of the module usualy obtained using '__main___'
Returns:
logging.Logger: Logger for the given module name.
"""
return logging.getLogger(name) | Get the logger for the current module given it's name. Args: name (str): Name of the module usualy obtained using '__main___' Returns: logging.Logger: Logger for the given module name. |
161,132 | from time import time
import logging
from functools import wraps
from colorama import Fore, Style
The provided code snippet includes necessary dependencies for implementing the `fill_size` function. Write a Python function `def fill_size(text: str, size: int, filler: str = " ")` to solve the following problem:
Make a text fill a given size using a given filler. Args: text (str): Text to fit in given size. size (int): Given size to fit text in. filler (str, optional): Character to fill with if place there is. Defaults to " ". Raises: ValueError: The given filler is not a single character. Returns: str: A string containing the text and filler of the given size.
Here is the function:
def fill_size(text: str, size: int, filler: str = " "):
"""Make a text fill a given size using a given filler.
Args:
text (str): Text to fit in given size.
size (int): Given size to fit text in.
filler (str, optional): Character to fill with if place there is. Defaults to " ".
Raises:
ValueError: The given filler is not a single character.
Returns:
str: A string containing the text and filler of the given size.
"""
if len(filler) > 1:
raise ValueError(
f"Given filler was more than one character ({len(filler)}>1): {filler}"
)
if len(text) < size:
missing_size = size - len(text)
return filler + text + filler * (missing_size - 1)
return text[:size] | Make a text fill a given size using a given filler. Args: text (str): Text to fit in given size. size (int): Given size to fit text in. filler (str, optional): Character to fill with if place there is. Defaults to " ". Raises: ValueError: The given filler is not a single character. Returns: str: A string containing the text and filler of the given size. |
161,133 | from PyQt5 import QtCore
qt_resource_data = b"\
\x00\x00\x05\x1a\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x0e\x00\x00\x00\x0e\x08\x06\x00\x00\x00\x1f\x48\x2d\xd1\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x76\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x36\x2d\x63\x31\x34\x32\x20\x37\x39\
\x2e\x31\x36\x30\x39\x32\x34\x2c\x20\x32\x30\x31\x37\x2f\x30\x37\
\x2f\x31\x33\x2d\x30\x31\x3a\x30\x36\x3a\x33\x39\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x38\x36\x30\
\x65\x64\x35\x30\x33\x2d\x39\x36\x37\x33\x2d\x32\x30\x34\x31\x2d\
\x62\x65\x61\x65\x2d\x64\x37\x39\x38\x64\x65\x33\x38\x66\x33\x63\
\x63\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x36\x37\x32\
\x43\x34\x33\x30\x30\x32\x45\x45\x35\x31\x31\x45\x39\x38\x30\x41\
\x32\x44\x31\x33\x31\x39\x42\x44\x42\x39\x44\x44\x35\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x36\x37\x32\x43\x34\x32\x46\
\x46\x32\x45\x45\x35\x31\x31\x45\x39\x38\x30\x41\x32\x44\x31\x33\
\x31\x39\x42\x44\x42\x39\x44\x44\x35\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x32\
\x30\x31\x38\x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\
\x3c\x78\x6d\x70\x4d\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\
\x6f\x6d\x20\x73\x74\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\
\x65\x49\x44\x3d\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x33\x61\x65\
\x34\x35\x31\x63\x30\x2d\x62\x37\x63\x35\x2d\x64\x65\x34\x37\x2d\
\x39\x31\x33\x61\x2d\x64\x36\x64\x36\x37\x39\x61\x30\x34\x35\x33\
\x31\x22\x20\x73\x74\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x38\x36\x30\
\x65\x64\x35\x30\x33\x2d\x39\x36\x37\x33\x2d\x32\x30\x34\x31\x2d\
\x62\x65\x61\x65\x2d\x64\x37\x39\x38\x64\x65\x33\x38\x66\x33\x63\
\x63\x22\x2f\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\
\x69\x70\x74\x69\x6f\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\
\x46\x3e\x20\x3c\x2f\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\
\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\
\x22\x3f\x3e\x58\x7e\x03\x34\x00\x00\x01\x3a\x49\x44\x41\x54\x78\
\xda\x9c\x52\x3d\x8a\x83\x50\x10\x1e\x7f\x50\x0c\x49\xa1\x78\x00\
\x2b\x0b\xbb\x14\x39\x83\x39\x8d\x44\x6f\x60\x61\xe5\x85\xbc\x81\
\xbd\xa8\x85\x58\xa4\x11\x2b\xed\x42\x40\x50\x97\x6f\x96\x27\xca\
\x86\x65\xd9\x81\xe1\x0d\xdf\xcc\xf7\xe6\x57\x5a\xd7\x95\xee\xf7\
\xfb\x3a\x8e\x23\xfd\x45\x2c\xcb\xa2\x2c\xcb\x24\xc9\xf7\xfd\xd5\
\xb6\x6d\xba\x5c\x2e\xa4\x69\xda\xaf\xa4\x61\x18\xe8\xf5\x7a\xd1\
\xfb\xfd\x26\x15\x99\x3c\xcf\xa3\xe7\xf3\x49\x8a\xa2\xb0\x7e\x92\
\x79\x9e\x59\x4d\xd3\xa4\xae\xeb\x48\x16\x0e\x64\xd3\x75\x9d\x6e\
\xb7\x1b\x3b\x61\x43\x61\x03\x83\x8d\x18\xc3\x30\x38\x9e\x89\xaa\
\xaa\xb2\x5e\xaf\x57\x7a\x3c\x1e\x14\x04\x01\x9d\xcf\x67\x56\xd8\
\xc0\xe0\x13\x71\xcc\xd9\x97\x53\x55\x15\x35\x4d\x43\xae\xeb\x52\
\x14\x45\x8c\x39\x8e\xc3\x18\x7c\x7b\xd9\x4a\x45\x6f\xd3\x34\x51\
\x92\x24\x1c\x08\x82\x20\x01\x83\x6f\xdf\xbf\xbc\xff\x05\x8e\xd3\
\xe9\xf4\x63\x30\xc0\x04\x49\xbc\x07\x22\x7a\x0a\xc3\x90\x4b\x45\
\x26\x51\x36\x30\xf8\x3e\x96\x0a\x41\x10\xb4\x2c\x4b\x8a\xe3\x98\
\x15\xb6\xc0\xc5\x5a\x0e\xc3\x01\x90\xe7\x39\x2f\xb8\xae\xeb\xed\
\xb3\x34\x4d\x79\xcf\x45\x51\x6c\x13\xdd\x32\x22\x58\xac\x05\x01\
\x10\xb1\x47\xc8\x9e\x24\x7a\x54\x71\x7b\x7d\xdf\xf3\x00\x70\x76\
\xdb\x8f\xf2\x77\x17\xcb\xb2\x1c\x7a\x6b\xdb\x96\xef\x55\xfa\xef\
\x91\x7f\x09\x30\x00\x65\xad\x88\x4d\x91\x3a\xf7\xaf\x00\x00\x00\
\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x06\x12\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
\x01\x00\x9a\x9c\x18\x00\x00\x05\x1c\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x36\x2d\x63\x31\x34\x32\x20\x37\x39\
\x2e\x31\x36\x30\x39\x32\x34\x2c\x20\x32\x30\x31\x37\x2f\x30\x37\
\x2f\x31\x33\x2d\x30\x31\x3a\x30\x36\x3a\x33\x39\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\
\x78\x6d\x6c\x6e\x73\x3a\x64\x63\x3d\x22\x68\x74\x74\x70\x3a\x2f\
\x2f\x70\x75\x72\x6c\x2e\x6f\x72\x67\x2f\x64\x63\x2f\x65\x6c\x65\
\x6d\x65\x6e\x74\x73\x2f\x31\x2e\x31\x2f\x22\x20\x78\x6d\x6c\x6e\
\x73\x3a\x70\x68\x6f\x74\x6f\x73\x68\x6f\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x70\x68\x6f\x74\x6f\x73\x68\x6f\x70\x2f\x31\x2e\x30\x2f\x22\
\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x4d\x4d\x3d\x22\x68\x74\
\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\
\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x6d\x6d\x2f\x22\x20\x78\
\x6d\x6c\x6e\x73\x3a\x73\x74\x45\x76\x74\x3d\x22\x68\x74\x74\x70\
\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\
\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\x79\x70\x65\x2f\x52\x65\
\x73\x6f\x75\x72\x63\x65\x45\x76\x65\x6e\x74\x23\x22\x20\x78\x6d\
\x70\x3a\x43\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\
\x64\x6f\x62\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\
\x43\x20\x32\x30\x31\x38\x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\
\x22\x20\x78\x6d\x70\x3a\x43\x72\x65\x61\x74\x65\x44\x61\x74\x65\
\x3d\x22\x32\x30\x31\x39\x2d\x30\x32\x2d\x31\x32\x54\x31\x37\x3a\
\x32\x31\x3a\x34\x31\x2b\x30\x31\x3a\x30\x30\x22\x20\x78\x6d\x70\
\x3a\x4d\x6f\x64\x69\x66\x79\x44\x61\x74\x65\x3d\x22\x32\x30\x31\
\x39\x2d\x30\x32\x2d\x31\x32\x54\x31\x37\x3a\x32\x34\x3a\x32\x33\
\x2b\x30\x31\x3a\x30\x30\x22\x20\x78\x6d\x70\x3a\x4d\x65\x74\x61\
\x64\x61\x74\x61\x44\x61\x74\x65\x3d\x22\x32\x30\x31\x39\x2d\x30\
\x32\x2d\x31\x32\x54\x31\x37\x3a\x32\x34\x3a\x32\x33\x2b\x30\x31\
\x3a\x30\x30\x22\x20\x64\x63\x3a\x66\x6f\x72\x6d\x61\x74\x3d\x22\
\x69\x6d\x61\x67\x65\x2f\x70\x6e\x67\x22\x20\x70\x68\x6f\x74\x6f\
\x73\x68\x6f\x70\x3a\x43\x6f\x6c\x6f\x72\x4d\x6f\x64\x65\x3d\x22\
\x33\x22\x20\x70\x68\x6f\x74\x6f\x73\x68\x6f\x70\x3a\x49\x43\x43\
\x50\x72\x6f\x66\x69\x6c\x65\x3d\x22\x73\x52\x47\x42\x20\x49\x45\
\x43\x36\x31\x39\x36\x36\x2d\x32\x2e\x31\x22\x20\x78\x6d\x70\x4d\
\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\x78\x6d\
\x70\x2e\x69\x69\x64\x3a\x35\x30\x36\x35\x39\x31\x38\x61\x2d\x39\
\x36\x66\x34\x2d\x35\x35\x34\x62\x2d\x62\x30\x32\x38\x2d\x62\x33\
\x61\x33\x38\x32\x65\x63\x65\x38\x35\x32\x22\x20\x78\x6d\x70\x4d\
\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\x78\x6d\
\x70\x2e\x64\x69\x64\x3a\x35\x30\x36\x35\x39\x31\x38\x61\x2d\x39\
\x36\x66\x34\x2d\x35\x35\x34\x62\x2d\x62\x30\x32\x38\x2d\x62\x33\
\x61\x33\x38\x32\x65\x63\x65\x38\x35\x32\x22\x20\x78\x6d\x70\x4d\
\x4d\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\
\x6e\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x35\x30\
\x36\x35\x39\x31\x38\x61\x2d\x39\x36\x66\x34\x2d\x35\x35\x34\x62\
\x2d\x62\x30\x32\x38\x2d\x62\x33\x61\x33\x38\x32\x65\x63\x65\x38\
\x35\x32\x22\x3e\x20\x3c\x78\x6d\x70\x4d\x4d\x3a\x48\x69\x73\x74\
\x6f\x72\x79\x3e\x20\x3c\x72\x64\x66\x3a\x53\x65\x71\x3e\x20\x3c\
\x72\x64\x66\x3a\x6c\x69\x20\x73\x74\x45\x76\x74\x3a\x61\x63\x74\
\x69\x6f\x6e\x3d\x22\x63\x72\x65\x61\x74\x65\x64\x22\x20\x73\x74\
\x45\x76\x74\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x35\x30\x36\x35\x39\x31\x38\x61\
\x2d\x39\x36\x66\x34\x2d\x35\x35\x34\x62\x2d\x62\x30\x32\x38\x2d\
\x62\x33\x61\x33\x38\x32\x65\x63\x65\x38\x35\x32\x22\x20\x73\x74\
\x45\x76\x74\x3a\x77\x68\x65\x6e\x3d\x22\x32\x30\x31\x39\x2d\x30\
\x32\x2d\x31\x32\x54\x31\x37\x3a\x32\x31\x3a\x34\x31\x2b\x30\x31\
\x3a\x30\x30\x22\x20\x73\x74\x45\x76\x74\x3a\x73\x6f\x66\x74\x77\
\x61\x72\x65\x41\x67\x65\x6e\x74\x3d\x22\x41\x64\x6f\x62\x65\x20\
\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x32\x30\x31\
\x38\x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x2f\x3e\x20\x3c\
\x2f\x72\x64\x66\x3a\x53\x65\x71\x3e\x20\x3c\x2f\x78\x6d\x70\x4d\
\x4d\x3a\x48\x69\x73\x74\x6f\x72\x79\x3e\x20\x3c\x2f\x72\x64\x66\
\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x3e\x20\x3c\x2f\
\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\x78\x3a\x78\x6d\x70\
\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\
\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x5b\xd4\x83\xe3\x00\x00\x00\
\x9c\x49\x44\x41\x54\x38\x8d\xed\x93\x2d\x0e\x02\x31\x10\x85\xdf\
\x90\x35\x35\x18\xba\x28\x24\x08\x14\x97\xa8\xef\x3d\x2b\x6b\xeb\
\x10\xf4\x0a\x24\x35\x1c\xa0\x02\x53\xd3\xd9\x30\x5c\xa0\x74\xb3\
\xac\x41\xf0\x92\x51\xf3\xe6\x9b\x9f\x64\x48\x44\xb0\x46\x9b\x55\
\xd5\xbf\x0f\x88\x31\x3e\xa7\x69\x3a\x32\xf3\x99\x99\x77\x8b\x01\
\x29\xa5\x6d\x08\xe1\x06\xe0\x05\xa0\x79\xed\xb9\x15\x28\xe7\x3c\
\x7a\xef\xaf\x00\xc6\xc5\x00\x22\x82\x88\xa0\x94\xb2\x77\xce\xdd\
\xbf\x99\x60\x56\x43\x2f\x29\x22\x20\x22\x28\xa5\x60\xad\x6d\x7a\
\xbb\x00\x22\x82\xd6\x1a\xc6\x98\x53\xb7\xcb\xa7\x88\x31\x3e\x98\
\xf9\x52\x6b\x3d\xd4\x5a\x87\x96\x87\xfe\xbf\x80\x37\xe7\x76\x5e\
\x24\x35\x48\x32\xb8\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\
\x82\
\x00\x00\x01\x32\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x0b\x00\x00\x00\x0b\x08\x06\x00\x00\x00\xa9\xac\x77\x26\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x00\xd4\x49\x44\x41\x54\x78\xda\x6c\
\xd0\xbd\x8a\xc2\x40\x14\x86\xe1\x64\xfc\x41\x0b\x41\xac\x5c\x11\
\x0b\x0b\x1b\x2d\xd7\x1b\xd8\xeb\xd0\x42\x17\x6b\x2b\x2d\x14\x9b\
\x14\x82\x7a\x0b\xb1\x30\x8b\xd7\x23\x6c\x21\x08\xb6\x62\xa5\xa2\
\x60\x27\xb8\xef\xc8\x27\x0c\xab\x03\x4f\x26\xe4\x7c\x9c\xc9\x1c\
\x3f\x8a\xa2\xa4\xe7\x79\x33\x34\x90\xf3\x5e\xd7\x09\x3f\xe8\x19\
\x1e\x53\x54\x50\x83\xff\x46\x55\xf5\xc0\x86\x9b\x68\x63\xaf\x4e\
\xdf\xb8\xe0\x8e\x2b\x5a\xaa\x77\x8c\x8e\xde\x3b\xc7\x06\xf8\x54\
\xd7\x12\xfa\xaa\xe7\x8c\x13\x7a\x76\x2c\x60\x85\x01\x0e\x48\x3c\
\x03\x6e\x78\x8c\x3a\x62\x4e\xc7\x0f\x5d\xf0\xb1\xe2\x4e\x38\x83\
\x8d\xde\x6d\x47\x3b\xa5\x25\x86\xef\xc2\x37\xfd\xff\x11\x65\xed\
\x5f\xee\x0c\xe3\xfa\x68\x8f\x9b\x60\x87\x14\xce\xe8\x3a\xb9\xbc\
\xcd\x19\x0d\x3c\xc4\x1c\x69\x4d\x21\x8b\x85\x82\x45\xd5\x42\xa3\
\x8b\x6c\xb1\xd6\x6c\xff\xfb\x55\x7d\xf4\x27\xc0\x00\x21\x29\x2e\
\x78\x26\x38\xb6\x10\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\
\x82\
\x00\x00\x05\x41\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x0e\x00\x00\x00\x0e\x08\x06\x00\x00\x00\x1f\x48\x2d\xd1\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x26\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x36\x2d\x63\x31\x34\x32\x20\x37\x39\
\x2e\x31\x36\x30\x39\x32\x34\x2c\x20\x32\x30\x31\x37\x2f\x30\x37\
\x2f\x31\x33\x2d\x30\x31\x3a\x30\x36\x3a\x33\x39\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\
\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x4d\x4d\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x6d\x6d\x2f\x22\x20\x78\x6d\
\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\
\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\x79\x70\x65\x2f\x52\x65\x73\
\x6f\x75\x72\x63\x65\x52\x65\x66\x23\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x32\
\x30\x31\x38\x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x30\x32\x31\x42\x34\x33\x42\
\x44\x32\x45\x45\x35\x31\x31\x45\x39\x39\x36\x41\x46\x44\x44\x31\
\x36\x37\x37\x37\x46\x37\x39\x46\x38\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x44\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\x78\x6d\x70\
\x2e\x64\x69\x64\x3a\x30\x32\x31\x42\x34\x33\x42\x45\x32\x45\x45\
\x35\x31\x31\x45\x39\x39\x36\x41\x46\x44\x44\x31\x36\x37\x37\x37\
\x46\x37\x39\x46\x38\x22\x3e\x20\x3c\x78\x6d\x70\x4d\x4d\x3a\x44\
\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\x52\x65\x66\
\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\x78\x6d\x70\
\x2e\x69\x69\x64\x3a\x30\x32\x31\x42\x34\x33\x42\x42\x32\x45\x45\
\x35\x31\x31\x45\x39\x39\x36\x41\x46\x44\x44\x31\x36\x37\x37\x37\
\x46\x37\x39\x46\x38\x22\x20\x73\x74\x52\x65\x66\x3a\x64\x6f\x63\
\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\
\x3a\x30\x32\x31\x42\x34\x33\x42\x43\x32\x45\x45\x35\x31\x31\x45\
\x39\x39\x36\x41\x46\x44\x44\x31\x36\x37\x37\x37\x46\x37\x39\x46\
\x38\x22\x2f\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\
\x69\x70\x74\x69\x6f\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\
\x46\x3e\x20\x3c\x2f\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\
\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\
\x22\x3f\x3e\xf6\x1b\x54\x2f\x00\x00\x01\xb1\x49\x44\x41\x54\x78\
\xda\x9c\x52\xbb\x4e\x5b\x41\x10\x3d\xb3\xde\xf5\xc5\x8f\x5c\xc9\
\x0e\x4e\x6c\x39\xd0\xc4\x1f\x80\x84\x84\x1c\xc9\x5f\x60\x9c\x0f\
\x00\x94\x2a\xa2\xa7\x81\xda\x45\x94\x22\x55\xc4\x3f\x24\x1f\x90\
\x47\x91\x16\x51\x90\x22\x12\x25\x42\x89\x14\x25\x01\x5b\xa4\x01\
\x6c\x63\x73\xb9\xd7\xcb\xce\x5c\xc7\xd8\x20\xa5\x60\xa5\xd5\x8e\
\xce\x9c\x33\x3b\x2f\xb2\xd6\xe2\xf7\xea\x73\xdb\xfd\xf1\x1d\x44\
\x16\xff\x3b\xd6\x12\xb2\x4f\x2b\x98\x7b\xff\x91\xe8\xd7\x4a\xc3\
\xda\xf9\x12\x12\x7e\x1a\x94\x4e\x0a\x81\x14\x4d\x0b\x86\x71\xc0\
\xb0\xd5\x46\x74\xda\x83\xee\x04\xd0\xfc\x53\xae\xb6\x88\xfe\xe1\
\x57\x20\xa9\x59\x15\xb3\xf5\x48\x15\x8e\xd5\x40\x10\x42\x3f\x99\
\x47\xf7\xd3\x0e\x14\xa7\x67\x87\x7d\xc0\x4b\x82\x92\x09\xf8\xb5\
\x3a\x74\x21\x0f\xf2\x8c\x5c\xb6\x19\x63\x1f\x73\x54\x66\x46\x4a\
\x8a\xe3\x1a\x0d\x32\x84\x07\xd5\x65\x3c\x6c\xac\xc3\x7f\xd6\x40\
\xfb\x5d\x53\x5c\xc5\xb5\x26\xcc\x6c\x59\x32\xe9\xec\x7d\x76\x99\
\xe8\xa9\x84\xc4\xba\xd8\xdf\x85\xbf\x54\x87\x79\x54\x46\xf1\xc5\
\xab\x38\x66\xfe\x31\xae\x4e\x8e\xc4\x27\x6c\x8a\xeb\x57\x63\xa1\
\x8b\x18\x0d\xce\xd0\x7a\xbb\x89\xab\xbf\x2d\x11\x88\xc8\xd9\x8c\
\xb1\x6f\x5c\xff\xd4\x8f\x0c\xa6\x14\x28\x61\xee\x8c\x81\x7c\x87\
\x45\x8e\x1a\xdd\x28\xd4\x24\x21\x91\xcd\xa1\xf8\xf2\x35\x4c\xa1\
\xe4\xd2\x6b\xc9\x65\x9b\x31\xf6\x4d\x1e\x35\x31\x2c\xa4\x2b\x55\
\x47\x2c\x23\x68\xff\xc1\xf1\x9b\x0d\xb9\x6c\x33\xc6\x3e\x19\x49\
\x78\x3b\x55\x07\x9e\xef\x7c\x80\xed\x5d\x4a\x23\x86\xde\x40\xe0\
\xf6\xf6\x16\xd2\x0b\x35\x74\xbe\x7d\x01\xa5\x6e\x16\x43\xf3\x1a\
\xd9\xde\x40\x22\xf1\x48\x84\xe0\x5e\x4a\xc5\xb5\x0e\xfb\x17\x63\
\x8c\x39\x4a\x79\xb2\x7a\xb2\x72\x91\xef\x81\x72\x06\x2a\x9f\x71\
\x85\x8e\x5a\xfe\xaf\x83\x9c\x9e\xdb\x67\x6e\x0c\x45\x1e\x82\x83\
\x9f\x30\x81\x6b\xe2\x7d\x97\xfc\x5a\x80\x01\x00\xf9\x5d\xa7\x18\
\xdc\xa1\xb6\x98\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\
\x00\x00\x06\x0b\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
\x01\x00\x9a\x9c\x18\x00\x00\x05\x1c\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x36\x2d\x63\x31\x34\x32\x20\x37\x39\
\x2e\x31\x36\x30\x39\x32\x34\x2c\x20\x32\x30\x31\x37\x2f\x30\x37\
\x2f\x31\x33\x2d\x30\x31\x3a\x30\x36\x3a\x33\x39\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\
\x78\x6d\x6c\x6e\x73\x3a\x64\x63\x3d\x22\x68\x74\x74\x70\x3a\x2f\
\x2f\x70\x75\x72\x6c\x2e\x6f\x72\x67\x2f\x64\x63\x2f\x65\x6c\x65\
\x6d\x65\x6e\x74\x73\x2f\x31\x2e\x31\x2f\x22\x20\x78\x6d\x6c\x6e\
\x73\x3a\x70\x68\x6f\x74\x6f\x73\x68\x6f\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x70\x68\x6f\x74\x6f\x73\x68\x6f\x70\x2f\x31\x2e\x30\x2f\x22\
\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x4d\x4d\x3d\x22\x68\x74\
\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\
\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x6d\x6d\x2f\x22\x20\x78\
\x6d\x6c\x6e\x73\x3a\x73\x74\x45\x76\x74\x3d\x22\x68\x74\x74\x70\
\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\
\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\x79\x70\x65\x2f\x52\x65\
\x73\x6f\x75\x72\x63\x65\x45\x76\x65\x6e\x74\x23\x22\x20\x78\x6d\
\x70\x3a\x43\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\
\x64\x6f\x62\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\
\x43\x20\x32\x30\x31\x38\x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\
\x22\x20\x78\x6d\x70\x3a\x43\x72\x65\x61\x74\x65\x44\x61\x74\x65\
\x3d\x22\x32\x30\x31\x39\x2d\x30\x32\x2d\x31\x32\x54\x31\x37\x3a\
\x32\x31\x3a\x34\x31\x2b\x30\x31\x3a\x30\x30\x22\x20\x78\x6d\x70\
\x3a\x4d\x6f\x64\x69\x66\x79\x44\x61\x74\x65\x3d\x22\x32\x30\x31\
\x39\x2d\x30\x32\x2d\x31\x32\x54\x31\x37\x3a\x32\x34\x3a\x33\x39\
\x2b\x30\x31\x3a\x30\x30\x22\x20\x78\x6d\x70\x3a\x4d\x65\x74\x61\
\x64\x61\x74\x61\x44\x61\x74\x65\x3d\x22\x32\x30\x31\x39\x2d\x30\
\x32\x2d\x31\x32\x54\x31\x37\x3a\x32\x34\x3a\x33\x39\x2b\x30\x31\
\x3a\x30\x30\x22\x20\x64\x63\x3a\x66\x6f\x72\x6d\x61\x74\x3d\x22\
\x69\x6d\x61\x67\x65\x2f\x70\x6e\x67\x22\x20\x70\x68\x6f\x74\x6f\
\x73\x68\x6f\x70\x3a\x43\x6f\x6c\x6f\x72\x4d\x6f\x64\x65\x3d\x22\
\x33\x22\x20\x70\x68\x6f\x74\x6f\x73\x68\x6f\x70\x3a\x49\x43\x43\
\x50\x72\x6f\x66\x69\x6c\x65\x3d\x22\x73\x52\x47\x42\x20\x49\x45\
\x43\x36\x31\x39\x36\x36\x2d\x32\x2e\x31\x22\x20\x78\x6d\x70\x4d\
\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\x78\x6d\
\x70\x2e\x69\x69\x64\x3a\x34\x66\x61\x30\x33\x66\x64\x34\x2d\x38\
\x63\x32\x66\x2d\x64\x31\x34\x31\x2d\x62\x37\x63\x62\x2d\x35\x32\
\x38\x33\x39\x63\x30\x37\x32\x37\x39\x32\x22\x20\x78\x6d\x70\x4d\
\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\x78\x6d\
\x70\x2e\x64\x69\x64\x3a\x34\x66\x61\x30\x33\x66\x64\x34\x2d\x38\
\x63\x32\x66\x2d\x64\x31\x34\x31\x2d\x62\x37\x63\x62\x2d\x35\x32\
\x38\x33\x39\x63\x30\x37\x32\x37\x39\x32\x22\x20\x78\x6d\x70\x4d\
\x4d\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\
\x6e\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x34\x66\
\x61\x30\x33\x66\x64\x34\x2d\x38\x63\x32\x66\x2d\x64\x31\x34\x31\
\x2d\x62\x37\x63\x62\x2d\x35\x32\x38\x33\x39\x63\x30\x37\x32\x37\
\x39\x32\x22\x3e\x20\x3c\x78\x6d\x70\x4d\x4d\x3a\x48\x69\x73\x74\
\x6f\x72\x79\x3e\x20\x3c\x72\x64\x66\x3a\x53\x65\x71\x3e\x20\x3c\
\x72\x64\x66\x3a\x6c\x69\x20\x73\x74\x45\x76\x74\x3a\x61\x63\x74\
\x69\x6f\x6e\x3d\x22\x63\x72\x65\x61\x74\x65\x64\x22\x20\x73\x74\
\x45\x76\x74\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x34\x66\x61\x30\x33\x66\x64\x34\
\x2d\x38\x63\x32\x66\x2d\x64\x31\x34\x31\x2d\x62\x37\x63\x62\x2d\
\x35\x32\x38\x33\x39\x63\x30\x37\x32\x37\x39\x32\x22\x20\x73\x74\
\x45\x76\x74\x3a\x77\x68\x65\x6e\x3d\x22\x32\x30\x31\x39\x2d\x30\
\x32\x2d\x31\x32\x54\x31\x37\x3a\x32\x31\x3a\x34\x31\x2b\x30\x31\
\x3a\x30\x30\x22\x20\x73\x74\x45\x76\x74\x3a\x73\x6f\x66\x74\x77\
\x61\x72\x65\x41\x67\x65\x6e\x74\x3d\x22\x41\x64\x6f\x62\x65\x20\
\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x32\x30\x31\
\x38\x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x2f\x3e\x20\x3c\
\x2f\x72\x64\x66\x3a\x53\x65\x71\x3e\x20\x3c\x2f\x78\x6d\x70\x4d\
\x4d\x3a\x48\x69\x73\x74\x6f\x72\x79\x3e\x20\x3c\x2f\x72\x64\x66\
\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x3e\x20\x3c\x2f\
\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\x78\x3a\x78\x6d\x70\
\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\
\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\xef\xbc\xde\xce\x00\x00\x00\
\x95\x49\x44\x41\x54\x38\x8d\xed\x93\x21\x0e\x82\x31\x0c\x85\x5f\
\xc9\xd4\x04\x86\xfd\x0e\x09\x02\xc5\x51\xe6\x76\xc8\xc9\xd9\x39\
\x04\xbb\x02\xc9\x0c\x47\x40\x4d\xac\x1b\xe5\x02\x6c\x82\x3f\x24\
\x08\x9a\xd4\xbd\x7e\x79\x7d\x69\x49\x44\xb0\xa6\x36\xab\xa6\x7f\
\x1b\xc0\xcc\x3b\x66\x3e\xb5\xd6\x0e\x29\xa5\xc7\x27\x0e\x04\xc0\
\x33\xc6\x78\xcd\x39\x6f\x47\x22\x35\x01\x2c\x21\x84\x4b\x29\x65\
\x99\x68\xc6\x00\xef\xfd\xad\xf7\x0e\x00\x20\xa2\x21\xe0\x7b\x21\
\x3a\xe7\x94\xd6\x1a\x44\x84\xd9\xb1\x4d\x1d\x58\x6b\x8f\xc6\x98\
\xe9\x0a\x10\x91\xb7\x5d\x6b\x55\xb5\xd6\x3d\x33\x9f\x53\x4a\xf7\
\x91\x8e\xfe\xbf\x80\x17\xa8\xc0\x5b\x7f\x18\x53\x58\x4b\x00\x00\
\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x01\x39\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x0b\x00\x00\x00\x0b\x08\x06\x00\x00\x00\xa9\xac\x77\x26\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x00\xdb\x49\x44\x41\x54\x78\xda\x6c\
\xd0\xb1\xab\x41\x61\x18\xc7\xf1\x73\x4e\xb7\x3b\xdc\x85\x4c\xb8\
\xca\x66\x61\xb9\x56\x29\x49\xd9\x4d\x12\x29\x32\x2b\x45\x49\x16\
\x23\x77\xb8\x7f\xc0\x95\x3a\x0c\xfe\x08\x26\x83\xdd\x60\x61\x12\
\x19\x84\xe4\x0f\x38\xbe\x6f\x3d\x74\xca\x7b\xea\x73\xde\xde\xf7\
\xf9\xf5\xbc\x4f\xaf\x69\xdb\xf6\xa7\x61\x18\x03\x14\xe1\x33\xde\
\xbf\x2b\xc6\x68\x5a\xfc\xfa\x88\x20\x06\x53\x23\x2a\xf5\x9e\x0a\
\x97\x50\x41\x1a\x7b\xc4\xa5\xe3\x0f\x0e\x48\x4a\xbd\x66\xc9\xd5\
\x47\xfc\xe1\x1b\x73\x94\x31\x43\x50\x46\x54\x75\x9f\xe5\x9a\x2d\
\x87\x3b\xbc\x18\x49\x93\x1b\xf2\xcf\x80\x3b\xbc\x40\x03\x8e\xcc\
\xaa\xd6\x36\x96\xba\x70\x02\xbf\xae\xa0\x29\xfb\xac\x2e\x3c\x81\
\x07\x67\x14\x70\xc2\x97\x9c\xbf\xc2\x17\x04\xd0\xc1\x0e\x19\x4c\
\x91\xc2\x06\x75\xf8\x55\xee\x43\x1e\xfc\x1f\x55\x84\x5d\x37\xad\
\xe5\x7d\x43\x18\xaa\x8c\xea\xdc\xc2\x56\x8a\x8e\xc6\x4a\xea\xdd\
\x87\x00\x03\x00\xa6\x62\x31\x34\x9c\xff\x4d\x8d\x00\x00\x00\x00\
\x49\x45\x4e\x44\xae\x42\x60\x82\
"
qt_resource_name = b"\
\x00\x05\
\x00\x6f\xa6\x53\
\x00\x69\
\x00\x63\x00\x6f\x00\x6e\x00\x73\
\x00\x1d\
\x0d\x61\x33\xc7\
\x00\x74\
\x00\x61\x00\x62\x00\x5f\x00\x63\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x5f\x00\x6e\x00\x6f\x00\x6e\x00\x73\x00\x65\x00\x6c\x00\x65\
\x00\x63\x00\x74\x00\x65\x00\x64\x00\x5f\x00\x62\x00\x74\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1b\
\x02\x39\x96\x07\
\x00\x73\
\x00\x6d\x00\x61\x00\x6c\x00\x6c\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x5f\x00\x72\x00\x69\x00\x67\x00\x68\x00\x74\
\x00\x2d\x00\x6c\x00\x69\x00\x67\x00\x68\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1e\
\x0a\x11\x67\x27\
\x00\x64\
\x00\x6f\x00\x63\x00\x6b\x00\x74\x00\x69\x00\x74\x00\x6c\x00\x65\x00\x2d\x00\x6e\x00\x6f\x00\x72\x00\x6d\x00\x61\x00\x6c\x00\x2d\
\x00\x62\x00\x74\x00\x6e\x00\x2d\x00\x6c\x00\x69\x00\x67\x00\x68\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x11\
\x0c\x35\x80\x87\
\x00\x74\
\x00\x61\x00\x62\x00\x5f\x00\x63\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x5f\x00\x62\x00\x74\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
\
\x00\x1a\
\x00\x1b\xdc\x67\
\x00\x73\
\x00\x6d\x00\x61\x00\x6c\x00\x6c\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x5f\x00\x6c\x00\x65\x00\x66\x00\x74\x00\x2d\
\x00\x6c\x00\x69\x00\x67\x00\x68\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1d\
\x08\xa2\xd1\xc7\
\x00\x64\
\x00\x6f\x00\x63\x00\x6b\x00\x74\x00\x69\x00\x74\x00\x6c\x00\x65\x00\x2d\x00\x63\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x2d\x00\x62\
\x00\x74\x00\x6e\x00\x2d\x00\x6c\x00\x69\x00\x67\x00\x68\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\
"
The provided code snippet includes necessary dependencies for implementing the `qInitResources` function. Write a Python function `def qInitResources()` to solve the following problem:
Initialize the qt resources.
Here is the function:
def qInitResources():
"""Initialize the qt resources."""
QtCore.qRegisterResourceData(
rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data
) | Initialize the qt resources. |
161,134 | from PyQt5 import QtCore
qt_resource_data = b"\
\x00\x00\x05\x1a\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x0e\x00\x00\x00\x0e\x08\x06\x00\x00\x00\x1f\x48\x2d\xd1\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x76\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x36\x2d\x63\x31\x34\x32\x20\x37\x39\
\x2e\x31\x36\x30\x39\x32\x34\x2c\x20\x32\x30\x31\x37\x2f\x30\x37\
\x2f\x31\x33\x2d\x30\x31\x3a\x30\x36\x3a\x33\x39\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x4d\x4d\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\
\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\
\x6d\x6d\x2f\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\
\x79\x70\x65\x2f\x52\x65\x73\x6f\x75\x72\x63\x65\x52\x65\x66\x23\
\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x38\x36\x30\
\x65\x64\x35\x30\x33\x2d\x39\x36\x37\x33\x2d\x32\x30\x34\x31\x2d\
\x62\x65\x61\x65\x2d\x64\x37\x39\x38\x64\x65\x33\x38\x66\x33\x63\
\x63\x22\x20\x78\x6d\x70\x4d\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x36\x37\x32\
\x43\x34\x33\x30\x30\x32\x45\x45\x35\x31\x31\x45\x39\x38\x30\x41\
\x32\x44\x31\x33\x31\x39\x42\x44\x42\x39\x44\x44\x35\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x36\x37\x32\x43\x34\x32\x46\
\x46\x32\x45\x45\x35\x31\x31\x45\x39\x38\x30\x41\x32\x44\x31\x33\
\x31\x39\x42\x44\x42\x39\x44\x44\x35\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x32\
\x30\x31\x38\x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x3e\x20\
\x3c\x78\x6d\x70\x4d\x4d\x3a\x44\x65\x72\x69\x76\x65\x64\x46\x72\
\x6f\x6d\x20\x73\x74\x52\x65\x66\x3a\x69\x6e\x73\x74\x61\x6e\x63\
\x65\x49\x44\x3d\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x33\x61\x65\
\x34\x35\x31\x63\x30\x2d\x62\x37\x63\x35\x2d\x64\x65\x34\x37\x2d\
\x39\x31\x33\x61\x2d\x64\x36\x64\x36\x37\x39\x61\x30\x34\x35\x33\
\x31\x22\x20\x73\x74\x52\x65\x66\x3a\x64\x6f\x63\x75\x6d\x65\x6e\
\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x38\x36\x30\
\x65\x64\x35\x30\x33\x2d\x39\x36\x37\x33\x2d\x32\x30\x34\x31\x2d\
\x62\x65\x61\x65\x2d\x64\x37\x39\x38\x64\x65\x33\x38\x66\x33\x63\
\x63\x22\x2f\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\
\x69\x70\x74\x69\x6f\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\
\x46\x3e\x20\x3c\x2f\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\
\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\
\x22\x3f\x3e\x58\x7e\x03\x34\x00\x00\x01\x3a\x49\x44\x41\x54\x78\
\xda\x9c\x52\x3d\x8a\x83\x50\x10\x1e\x7f\x50\x0c\x49\xa1\x78\x00\
\x2b\x0b\xbb\x14\x39\x83\x39\x8d\x44\x6f\x60\x61\xe5\x85\xbc\x81\
\xbd\xa8\x85\x58\xa4\x11\x2b\xed\x42\x40\x50\x97\x6f\x96\x27\xca\
\x86\x65\xd9\x81\xe1\x0d\xdf\xcc\xf7\xe6\x57\x5a\xd7\x95\xee\xf7\
\xfb\x3a\x8e\x23\xfd\x45\x2c\xcb\xa2\x2c\xcb\x24\xc9\xf7\xfd\xd5\
\xb6\x6d\xba\x5c\x2e\xa4\x69\xda\xaf\xa4\x61\x18\xe8\xf5\x7a\xd1\
\xfb\xfd\x26\x15\x99\x3c\xcf\xa3\xe7\xf3\x49\x8a\xa2\xb0\x7e\x92\
\x79\x9e\x59\x4d\xd3\xa4\xae\xeb\x48\x16\x0e\x64\xd3\x75\x9d\x6e\
\xb7\x1b\x3b\x61\x43\x61\x03\x83\x8d\x18\xc3\x30\x38\x9e\x89\xaa\
\xaa\xb2\x5e\xaf\x57\x7a\x3c\x1e\x14\x04\x01\x9d\xcf\x67\x56\xd8\
\xc0\xe0\x13\x71\xcc\xd9\x97\x53\x55\x15\x35\x4d\x43\xae\xeb\x52\
\x14\x45\x8c\x39\x8e\xc3\x18\x7c\x7b\xd9\x4a\x45\x6f\xd3\x34\x51\
\x92\x24\x1c\x08\x82\x20\x01\x83\x6f\xdf\xbf\xbc\xff\x05\x8e\xd3\
\xe9\xf4\x63\x30\xc0\x04\x49\xbc\x07\x22\x7a\x0a\xc3\x90\x4b\x45\
\x26\x51\x36\x30\xf8\x3e\x96\x0a\x41\x10\xb4\x2c\x4b\x8a\xe3\x98\
\x15\xb6\xc0\xc5\x5a\x0e\xc3\x01\x90\xe7\x39\x2f\xb8\xae\xeb\xed\
\xb3\x34\x4d\x79\xcf\x45\x51\x6c\x13\xdd\x32\x22\x58\xac\x05\x01\
\x10\xb1\x47\xc8\x9e\x24\x7a\x54\x71\x7b\x7d\xdf\xf3\x00\x70\x76\
\xdb\x8f\xf2\x77\x17\xcb\xb2\x1c\x7a\x6b\xdb\x96\xef\x55\xfa\xef\
\x91\x7f\x09\x30\x00\x65\xad\x88\x4d\x91\x3a\xf7\xaf\x00\x00\x00\
\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x06\x12\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
\x01\x00\x9a\x9c\x18\x00\x00\x05\x1c\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x36\x2d\x63\x31\x34\x32\x20\x37\x39\
\x2e\x31\x36\x30\x39\x32\x34\x2c\x20\x32\x30\x31\x37\x2f\x30\x37\
\x2f\x31\x33\x2d\x30\x31\x3a\x30\x36\x3a\x33\x39\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\
\x78\x6d\x6c\x6e\x73\x3a\x64\x63\x3d\x22\x68\x74\x74\x70\x3a\x2f\
\x2f\x70\x75\x72\x6c\x2e\x6f\x72\x67\x2f\x64\x63\x2f\x65\x6c\x65\
\x6d\x65\x6e\x74\x73\x2f\x31\x2e\x31\x2f\x22\x20\x78\x6d\x6c\x6e\
\x73\x3a\x70\x68\x6f\x74\x6f\x73\x68\x6f\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x70\x68\x6f\x74\x6f\x73\x68\x6f\x70\x2f\x31\x2e\x30\x2f\x22\
\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x4d\x4d\x3d\x22\x68\x74\
\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\
\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x6d\x6d\x2f\x22\x20\x78\
\x6d\x6c\x6e\x73\x3a\x73\x74\x45\x76\x74\x3d\x22\x68\x74\x74\x70\
\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\
\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\x79\x70\x65\x2f\x52\x65\
\x73\x6f\x75\x72\x63\x65\x45\x76\x65\x6e\x74\x23\x22\x20\x78\x6d\
\x70\x3a\x43\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\
\x64\x6f\x62\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\
\x43\x20\x32\x30\x31\x38\x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\
\x22\x20\x78\x6d\x70\x3a\x43\x72\x65\x61\x74\x65\x44\x61\x74\x65\
\x3d\x22\x32\x30\x31\x39\x2d\x30\x32\x2d\x31\x32\x54\x31\x37\x3a\
\x32\x31\x3a\x34\x31\x2b\x30\x31\x3a\x30\x30\x22\x20\x78\x6d\x70\
\x3a\x4d\x6f\x64\x69\x66\x79\x44\x61\x74\x65\x3d\x22\x32\x30\x31\
\x39\x2d\x30\x32\x2d\x31\x32\x54\x31\x37\x3a\x32\x34\x3a\x32\x33\
\x2b\x30\x31\x3a\x30\x30\x22\x20\x78\x6d\x70\x3a\x4d\x65\x74\x61\
\x64\x61\x74\x61\x44\x61\x74\x65\x3d\x22\x32\x30\x31\x39\x2d\x30\
\x32\x2d\x31\x32\x54\x31\x37\x3a\x32\x34\x3a\x32\x33\x2b\x30\x31\
\x3a\x30\x30\x22\x20\x64\x63\x3a\x66\x6f\x72\x6d\x61\x74\x3d\x22\
\x69\x6d\x61\x67\x65\x2f\x70\x6e\x67\x22\x20\x70\x68\x6f\x74\x6f\
\x73\x68\x6f\x70\x3a\x43\x6f\x6c\x6f\x72\x4d\x6f\x64\x65\x3d\x22\
\x33\x22\x20\x70\x68\x6f\x74\x6f\x73\x68\x6f\x70\x3a\x49\x43\x43\
\x50\x72\x6f\x66\x69\x6c\x65\x3d\x22\x73\x52\x47\x42\x20\x49\x45\
\x43\x36\x31\x39\x36\x36\x2d\x32\x2e\x31\x22\x20\x78\x6d\x70\x4d\
\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\x78\x6d\
\x70\x2e\x69\x69\x64\x3a\x35\x30\x36\x35\x39\x31\x38\x61\x2d\x39\
\x36\x66\x34\x2d\x35\x35\x34\x62\x2d\x62\x30\x32\x38\x2d\x62\x33\
\x61\x33\x38\x32\x65\x63\x65\x38\x35\x32\x22\x20\x78\x6d\x70\x4d\
\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\x78\x6d\
\x70\x2e\x64\x69\x64\x3a\x35\x30\x36\x35\x39\x31\x38\x61\x2d\x39\
\x36\x66\x34\x2d\x35\x35\x34\x62\x2d\x62\x30\x32\x38\x2d\x62\x33\
\x61\x33\x38\x32\x65\x63\x65\x38\x35\x32\x22\x20\x78\x6d\x70\x4d\
\x4d\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\
\x6e\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x35\x30\
\x36\x35\x39\x31\x38\x61\x2d\x39\x36\x66\x34\x2d\x35\x35\x34\x62\
\x2d\x62\x30\x32\x38\x2d\x62\x33\x61\x33\x38\x32\x65\x63\x65\x38\
\x35\x32\x22\x3e\x20\x3c\x78\x6d\x70\x4d\x4d\x3a\x48\x69\x73\x74\
\x6f\x72\x79\x3e\x20\x3c\x72\x64\x66\x3a\x53\x65\x71\x3e\x20\x3c\
\x72\x64\x66\x3a\x6c\x69\x20\x73\x74\x45\x76\x74\x3a\x61\x63\x74\
\x69\x6f\x6e\x3d\x22\x63\x72\x65\x61\x74\x65\x64\x22\x20\x73\x74\
\x45\x76\x74\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x35\x30\x36\x35\x39\x31\x38\x61\
\x2d\x39\x36\x66\x34\x2d\x35\x35\x34\x62\x2d\x62\x30\x32\x38\x2d\
\x62\x33\x61\x33\x38\x32\x65\x63\x65\x38\x35\x32\x22\x20\x73\x74\
\x45\x76\x74\x3a\x77\x68\x65\x6e\x3d\x22\x32\x30\x31\x39\x2d\x30\
\x32\x2d\x31\x32\x54\x31\x37\x3a\x32\x31\x3a\x34\x31\x2b\x30\x31\
\x3a\x30\x30\x22\x20\x73\x74\x45\x76\x74\x3a\x73\x6f\x66\x74\x77\
\x61\x72\x65\x41\x67\x65\x6e\x74\x3d\x22\x41\x64\x6f\x62\x65\x20\
\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x32\x30\x31\
\x38\x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x2f\x3e\x20\x3c\
\x2f\x72\x64\x66\x3a\x53\x65\x71\x3e\x20\x3c\x2f\x78\x6d\x70\x4d\
\x4d\x3a\x48\x69\x73\x74\x6f\x72\x79\x3e\x20\x3c\x2f\x72\x64\x66\
\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x3e\x20\x3c\x2f\
\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\x78\x3a\x78\x6d\x70\
\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\
\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\x5b\xd4\x83\xe3\x00\x00\x00\
\x9c\x49\x44\x41\x54\x38\x8d\xed\x93\x2d\x0e\x02\x31\x10\x85\xdf\
\x90\x35\x35\x18\xba\x28\x24\x08\x14\x97\xa8\xef\x3d\x2b\x6b\xeb\
\x10\xf4\x0a\x24\x35\x1c\xa0\x02\x53\xd3\xd9\x30\x5c\xa0\x74\xb3\
\xac\x41\xf0\x92\x51\xf3\xe6\x9b\x9f\x64\x48\x44\xb0\x46\x9b\x55\
\xd5\xbf\x0f\x88\x31\x3e\xa7\x69\x3a\x32\xf3\x99\x99\x77\x8b\x01\
\x29\xa5\x6d\x08\xe1\x06\xe0\x05\xa0\x79\xed\xb9\x15\x28\xe7\x3c\
\x7a\xef\xaf\x00\xc6\xc5\x00\x22\x82\x88\xa0\x94\xb2\x77\xce\xdd\
\xbf\x99\x60\x56\x43\x2f\x29\x22\x20\x22\x28\xa5\x60\xad\x6d\x7a\
\xbb\x00\x22\x82\xd6\x1a\xc6\x98\x53\xb7\xcb\xa7\x88\x31\x3e\x98\
\xf9\x52\x6b\x3d\xd4\x5a\x87\x96\x87\xfe\xbf\x80\x37\xe7\x76\x5e\
\x24\x35\x48\x32\xb8\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\
\x82\
\x00\x00\x01\x32\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x0b\x00\x00\x00\x0b\x08\x06\x00\x00\x00\xa9\xac\x77\x26\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x00\xd4\x49\x44\x41\x54\x78\xda\x6c\
\xd0\xbd\x8a\xc2\x40\x14\x86\xe1\x64\xfc\x41\x0b\x41\xac\x5c\x11\
\x0b\x0b\x1b\x2d\xd7\x1b\xd8\xeb\xd0\x42\x17\x6b\x2b\x2d\x14\x9b\
\x14\x82\x7a\x0b\xb1\x30\x8b\xd7\x23\x6c\x21\x08\xb6\x62\xa5\xa2\
\x60\x27\xb8\xef\xc8\x27\x0c\xab\x03\x4f\x26\xe4\x7c\x9c\xc9\x1c\
\x3f\x8a\xa2\xa4\xe7\x79\x33\x34\x90\xf3\x5e\xd7\x09\x3f\xe8\x19\
\x1e\x53\x54\x50\x83\xff\x46\x55\xf5\xc0\x86\x9b\x68\x63\xaf\x4e\
\xdf\xb8\xe0\x8e\x2b\x5a\xaa\x77\x8c\x8e\xde\x3b\xc7\x06\xf8\x54\
\xd7\x12\xfa\xaa\xe7\x8c\x13\x7a\x76\x2c\x60\x85\x01\x0e\x48\x3c\
\x03\x6e\x78\x8c\x3a\x62\x4e\xc7\x0f\x5d\xf0\xb1\xe2\x4e\x38\x83\
\x8d\xde\x6d\x47\x3b\xa5\x25\x86\xef\xc2\x37\xfd\xff\x11\x65\xed\
\x5f\xee\x0c\xe3\xfa\x68\x8f\x9b\x60\x87\x14\xce\xe8\x3a\xb9\xbc\
\xcd\x19\x0d\x3c\xc4\x1c\x69\x4d\x21\x8b\x85\x82\x45\xd5\x42\xa3\
\x8b\x6c\xb1\xd6\x6c\xff\xfb\x55\x7d\xf4\x27\xc0\x00\x21\x29\x2e\
\x78\x26\x38\xb6\x10\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\
\x82\
\x00\x00\x05\x41\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x0e\x00\x00\x00\x0e\x08\x06\x00\x00\x00\x1f\x48\x2d\xd1\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x03\x26\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x36\x2d\x63\x31\x34\x32\x20\x37\x39\
\x2e\x31\x36\x30\x39\x32\x34\x2c\x20\x32\x30\x31\x37\x2f\x30\x37\
\x2f\x31\x33\x2d\x30\x31\x3a\x30\x36\x3a\x33\x39\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\
\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x4d\x4d\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x6d\x6d\x2f\x22\x20\x78\x6d\
\x6c\x6e\x73\x3a\x73\x74\x52\x65\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\x78\
\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\x79\x70\x65\x2f\x52\x65\x73\
\x6f\x75\x72\x63\x65\x52\x65\x66\x23\x22\x20\x78\x6d\x70\x3a\x43\
\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\x64\x6f\x62\
\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x32\
\x30\x31\x38\x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x20\x78\
\x6d\x70\x4d\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\
\x22\x78\x6d\x70\x2e\x69\x69\x64\x3a\x30\x32\x31\x42\x34\x33\x42\
\x44\x32\x45\x45\x35\x31\x31\x45\x39\x39\x36\x41\x46\x44\x44\x31\
\x36\x37\x37\x37\x46\x37\x39\x46\x38\x22\x20\x78\x6d\x70\x4d\x4d\
\x3a\x44\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\x78\x6d\x70\
\x2e\x64\x69\x64\x3a\x30\x32\x31\x42\x34\x33\x42\x45\x32\x45\x45\
\x35\x31\x31\x45\x39\x39\x36\x41\x46\x44\x44\x31\x36\x37\x37\x37\
\x46\x37\x39\x46\x38\x22\x3e\x20\x3c\x78\x6d\x70\x4d\x4d\x3a\x44\
\x65\x72\x69\x76\x65\x64\x46\x72\x6f\x6d\x20\x73\x74\x52\x65\x66\
\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\x78\x6d\x70\
\x2e\x69\x69\x64\x3a\x30\x32\x31\x42\x34\x33\x42\x42\x32\x45\x45\
\x35\x31\x31\x45\x39\x39\x36\x41\x46\x44\x44\x31\x36\x37\x37\x37\
\x46\x37\x39\x46\x38\x22\x20\x73\x74\x52\x65\x66\x3a\x64\x6f\x63\
\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\
\x3a\x30\x32\x31\x42\x34\x33\x42\x43\x32\x45\x45\x35\x31\x31\x45\
\x39\x39\x36\x41\x46\x44\x44\x31\x36\x37\x37\x37\x46\x37\x39\x46\
\x38\x22\x2f\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x44\x65\x73\x63\x72\
\x69\x70\x74\x69\x6f\x6e\x3e\x20\x3c\x2f\x72\x64\x66\x3a\x52\x44\
\x46\x3e\x20\x3c\x2f\x78\x3a\x78\x6d\x70\x6d\x65\x74\x61\x3e\x20\
\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x65\x6e\x64\x3d\x22\x72\
\x22\x3f\x3e\xf6\x1b\x54\x2f\x00\x00\x01\xb1\x49\x44\x41\x54\x78\
\xda\x9c\x52\xbb\x4e\x5b\x41\x10\x3d\xb3\xde\xf5\xc5\x8f\x5c\xc9\
\x0e\x4e\x6c\x39\xd0\xc4\x1f\x80\x84\x84\x1c\xc9\x5f\x60\x9c\x0f\
\x00\x94\x2a\xa2\xa7\x81\xda\x45\x94\x22\x55\xc4\x3f\x24\x1f\x90\
\x47\x91\x16\x51\x90\x22\x12\x25\x42\x89\x14\x25\x01\x5b\xa4\x01\
\x6c\x63\x73\xb9\xd7\xcb\xce\x5c\xc7\xd8\x20\xa5\x60\xa5\xd5\x8e\
\xce\x9c\x33\x3b\x2f\xb2\xd6\xe2\xf7\xea\x73\xdb\xfd\xf1\x1d\x44\
\x16\xff\x3b\xd6\x12\xb2\x4f\x2b\x98\x7b\xff\x91\xe8\xd7\x4a\xc3\
\xda\xf9\x12\x12\x7e\x1a\x94\x4e\x0a\x81\x14\x4d\x0b\x86\x71\xc0\
\xb0\xd5\x46\x74\xda\x83\xee\x04\xd0\xfc\x53\xae\xb6\x88\xfe\xe1\
\x57\x20\xa9\x59\x15\xb3\xf5\x48\x15\x8e\xd5\x40\x10\x42\x3f\x99\
\x47\xf7\xd3\x0e\x14\xa7\x67\x87\x7d\xc0\x4b\x82\x92\x09\xf8\xb5\
\x3a\x74\x21\x0f\xf2\x8c\x5c\xb6\x19\x63\x1f\x73\x54\x66\x46\x4a\
\x8a\xe3\x1a\x0d\x32\x84\x07\xd5\x65\x3c\x6c\xac\xc3\x7f\xd6\x40\
\xfb\x5d\x53\x5c\xc5\xb5\x26\xcc\x6c\x59\x32\xe9\xec\x7d\x76\x99\
\xe8\xa9\x84\xc4\xba\xd8\xdf\x85\xbf\x54\x87\x79\x54\x46\xf1\xc5\
\xab\x38\x66\xfe\x31\xae\x4e\x8e\xc4\x27\x6c\x8a\xeb\x57\x63\xa1\
\x8b\x18\x0d\xce\xd0\x7a\xbb\x89\xab\xbf\x2d\x11\x88\xc8\xd9\x8c\
\xb1\x6f\x5c\xff\xd4\x8f\x0c\xa6\x14\x28\x61\xee\x8c\x81\x7c\x87\
\x45\x8e\x1a\xdd\x28\xd4\x24\x21\x91\xcd\xa1\xf8\xf2\x35\x4c\xa1\
\xe4\xd2\x6b\xc9\x65\x9b\x31\xf6\x4d\x1e\x35\x31\x2c\xa4\x2b\x55\
\x47\x2c\x23\x68\xff\xc1\xf1\x9b\x0d\xb9\x6c\x33\xc6\x3e\x19\x49\
\x78\x3b\x55\x07\x9e\xef\x7c\x80\xed\x5d\x4a\x23\x86\xde\x40\xe0\
\xf6\xf6\x16\xd2\x0b\x35\x74\xbe\x7d\x01\xa5\x6e\x16\x43\xf3\x1a\
\xd9\xde\x40\x22\xf1\x48\x84\xe0\x5e\x4a\xc5\xb5\x0e\xfb\x17\x63\
\x8c\x39\x4a\x79\xb2\x7a\xb2\x72\x91\xef\x81\x72\x06\x2a\x9f\x71\
\x85\x8e\x5a\xfe\xaf\x83\x9c\x9e\xdb\x67\x6e\x0c\x45\x1e\x82\x83\
\x9f\x30\x81\x6b\xe2\x7d\x97\xfc\x5a\x80\x01\x00\xf9\x5d\xa7\x18\
\xdc\xa1\xb6\x98\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\
\x00\x00\x06\x0b\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x10\x00\x00\x00\x10\x08\x06\x00\x00\x00\x1f\xf3\xff\x61\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
\x01\x00\x9a\x9c\x18\x00\x00\x05\x1c\x69\x54\x58\x74\x58\x4d\x4c\
\x3a\x63\x6f\x6d\x2e\x61\x64\x6f\x62\x65\x2e\x78\x6d\x70\x00\x00\
\x00\x00\x00\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\x62\x65\x67\
\x69\x6e\x3d\x22\xef\xbb\xbf\x22\x20\x69\x64\x3d\x22\x57\x35\x4d\
\x30\x4d\x70\x43\x65\x68\x69\x48\x7a\x72\x65\x53\x7a\x4e\x54\x63\
\x7a\x6b\x63\x39\x64\x22\x3f\x3e\x20\x3c\x78\x3a\x78\x6d\x70\x6d\
\x65\x74\x61\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x3d\x22\x61\x64\x6f\
\x62\x65\x3a\x6e\x73\x3a\x6d\x65\x74\x61\x2f\x22\x20\x78\x3a\x78\
\x6d\x70\x74\x6b\x3d\x22\x41\x64\x6f\x62\x65\x20\x58\x4d\x50\x20\
\x43\x6f\x72\x65\x20\x35\x2e\x36\x2d\x63\x31\x34\x32\x20\x37\x39\
\x2e\x31\x36\x30\x39\x32\x34\x2c\x20\x32\x30\x31\x37\x2f\x30\x37\
\x2f\x31\x33\x2d\x30\x31\x3a\x30\x36\x3a\x33\x39\x20\x20\x20\x20\
\x20\x20\x20\x20\x22\x3e\x20\x3c\x72\x64\x66\x3a\x52\x44\x46\x20\
\x78\x6d\x6c\x6e\x73\x3a\x72\x64\x66\x3d\x22\x68\x74\x74\x70\x3a\
\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\
\x39\x2f\x30\x32\x2f\x32\x32\x2d\x72\x64\x66\x2d\x73\x79\x6e\x74\
\x61\x78\x2d\x6e\x73\x23\x22\x3e\x20\x3c\x72\x64\x66\x3a\x44\x65\
\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x20\x72\x64\x66\x3a\x61\x62\
\x6f\x75\x74\x3d\x22\x22\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\
\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\
\x65\x2e\x63\x6f\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x22\x20\
\x78\x6d\x6c\x6e\x73\x3a\x64\x63\x3d\x22\x68\x74\x74\x70\x3a\x2f\
\x2f\x70\x75\x72\x6c\x2e\x6f\x72\x67\x2f\x64\x63\x2f\x65\x6c\x65\
\x6d\x65\x6e\x74\x73\x2f\x31\x2e\x31\x2f\x22\x20\x78\x6d\x6c\x6e\
\x73\x3a\x70\x68\x6f\x74\x6f\x73\x68\x6f\x70\x3d\x22\x68\x74\x74\
\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\
\x2f\x70\x68\x6f\x74\x6f\x73\x68\x6f\x70\x2f\x31\x2e\x30\x2f\x22\
\x20\x78\x6d\x6c\x6e\x73\x3a\x78\x6d\x70\x4d\x4d\x3d\x22\x68\x74\
\x74\x70\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\
\x6d\x2f\x78\x61\x70\x2f\x31\x2e\x30\x2f\x6d\x6d\x2f\x22\x20\x78\
\x6d\x6c\x6e\x73\x3a\x73\x74\x45\x76\x74\x3d\x22\x68\x74\x74\x70\
\x3a\x2f\x2f\x6e\x73\x2e\x61\x64\x6f\x62\x65\x2e\x63\x6f\x6d\x2f\
\x78\x61\x70\x2f\x31\x2e\x30\x2f\x73\x54\x79\x70\x65\x2f\x52\x65\
\x73\x6f\x75\x72\x63\x65\x45\x76\x65\x6e\x74\x23\x22\x20\x78\x6d\
\x70\x3a\x43\x72\x65\x61\x74\x6f\x72\x54\x6f\x6f\x6c\x3d\x22\x41\
\x64\x6f\x62\x65\x20\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\
\x43\x20\x32\x30\x31\x38\x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\
\x22\x20\x78\x6d\x70\x3a\x43\x72\x65\x61\x74\x65\x44\x61\x74\x65\
\x3d\x22\x32\x30\x31\x39\x2d\x30\x32\x2d\x31\x32\x54\x31\x37\x3a\
\x32\x31\x3a\x34\x31\x2b\x30\x31\x3a\x30\x30\x22\x20\x78\x6d\x70\
\x3a\x4d\x6f\x64\x69\x66\x79\x44\x61\x74\x65\x3d\x22\x32\x30\x31\
\x39\x2d\x30\x32\x2d\x31\x32\x54\x31\x37\x3a\x32\x34\x3a\x33\x39\
\x2b\x30\x31\x3a\x30\x30\x22\x20\x78\x6d\x70\x3a\x4d\x65\x74\x61\
\x64\x61\x74\x61\x44\x61\x74\x65\x3d\x22\x32\x30\x31\x39\x2d\x30\
\x32\x2d\x31\x32\x54\x31\x37\x3a\x32\x34\x3a\x33\x39\x2b\x30\x31\
\x3a\x30\x30\x22\x20\x64\x63\x3a\x66\x6f\x72\x6d\x61\x74\x3d\x22\
\x69\x6d\x61\x67\x65\x2f\x70\x6e\x67\x22\x20\x70\x68\x6f\x74\x6f\
\x73\x68\x6f\x70\x3a\x43\x6f\x6c\x6f\x72\x4d\x6f\x64\x65\x3d\x22\
\x33\x22\x20\x70\x68\x6f\x74\x6f\x73\x68\x6f\x70\x3a\x49\x43\x43\
\x50\x72\x6f\x66\x69\x6c\x65\x3d\x22\x73\x52\x47\x42\x20\x49\x45\
\x43\x36\x31\x39\x36\x36\x2d\x32\x2e\x31\x22\x20\x78\x6d\x70\x4d\
\x4d\x3a\x49\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\x78\x6d\
\x70\x2e\x69\x69\x64\x3a\x34\x66\x61\x30\x33\x66\x64\x34\x2d\x38\
\x63\x32\x66\x2d\x64\x31\x34\x31\x2d\x62\x37\x63\x62\x2d\x35\x32\
\x38\x33\x39\x63\x30\x37\x32\x37\x39\x32\x22\x20\x78\x6d\x70\x4d\
\x4d\x3a\x44\x6f\x63\x75\x6d\x65\x6e\x74\x49\x44\x3d\x22\x78\x6d\
\x70\x2e\x64\x69\x64\x3a\x34\x66\x61\x30\x33\x66\x64\x34\x2d\x38\
\x63\x32\x66\x2d\x64\x31\x34\x31\x2d\x62\x37\x63\x62\x2d\x35\x32\
\x38\x33\x39\x63\x30\x37\x32\x37\x39\x32\x22\x20\x78\x6d\x70\x4d\
\x4d\x3a\x4f\x72\x69\x67\x69\x6e\x61\x6c\x44\x6f\x63\x75\x6d\x65\
\x6e\x74\x49\x44\x3d\x22\x78\x6d\x70\x2e\x64\x69\x64\x3a\x34\x66\
\x61\x30\x33\x66\x64\x34\x2d\x38\x63\x32\x66\x2d\x64\x31\x34\x31\
\x2d\x62\x37\x63\x62\x2d\x35\x32\x38\x33\x39\x63\x30\x37\x32\x37\
\x39\x32\x22\x3e\x20\x3c\x78\x6d\x70\x4d\x4d\x3a\x48\x69\x73\x74\
\x6f\x72\x79\x3e\x20\x3c\x72\x64\x66\x3a\x53\x65\x71\x3e\x20\x3c\
\x72\x64\x66\x3a\x6c\x69\x20\x73\x74\x45\x76\x74\x3a\x61\x63\x74\
\x69\x6f\x6e\x3d\x22\x63\x72\x65\x61\x74\x65\x64\x22\x20\x73\x74\
\x45\x76\x74\x3a\x69\x6e\x73\x74\x61\x6e\x63\x65\x49\x44\x3d\x22\
\x78\x6d\x70\x2e\x69\x69\x64\x3a\x34\x66\x61\x30\x33\x66\x64\x34\
\x2d\x38\x63\x32\x66\x2d\x64\x31\x34\x31\x2d\x62\x37\x63\x62\x2d\
\x35\x32\x38\x33\x39\x63\x30\x37\x32\x37\x39\x32\x22\x20\x73\x74\
\x45\x76\x74\x3a\x77\x68\x65\x6e\x3d\x22\x32\x30\x31\x39\x2d\x30\
\x32\x2d\x31\x32\x54\x31\x37\x3a\x32\x31\x3a\x34\x31\x2b\x30\x31\
\x3a\x30\x30\x22\x20\x73\x74\x45\x76\x74\x3a\x73\x6f\x66\x74\x77\
\x61\x72\x65\x41\x67\x65\x6e\x74\x3d\x22\x41\x64\x6f\x62\x65\x20\
\x50\x68\x6f\x74\x6f\x73\x68\x6f\x70\x20\x43\x43\x20\x32\x30\x31\
\x38\x20\x28\x57\x69\x6e\x64\x6f\x77\x73\x29\x22\x2f\x3e\x20\x3c\
\x2f\x72\x64\x66\x3a\x53\x65\x71\x3e\x20\x3c\x2f\x78\x6d\x70\x4d\
\x4d\x3a\x48\x69\x73\x74\x6f\x72\x79\x3e\x20\x3c\x2f\x72\x64\x66\
\x3a\x44\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x3e\x20\x3c\x2f\
\x72\x64\x66\x3a\x52\x44\x46\x3e\x20\x3c\x2f\x78\x3a\x78\x6d\x70\
\x6d\x65\x74\x61\x3e\x20\x3c\x3f\x78\x70\x61\x63\x6b\x65\x74\x20\
\x65\x6e\x64\x3d\x22\x72\x22\x3f\x3e\xef\xbc\xde\xce\x00\x00\x00\
\x95\x49\x44\x41\x54\x38\x8d\xed\x93\x21\x0e\x82\x31\x0c\x85\x5f\
\xc9\xd4\x04\x86\xfd\x0e\x09\x02\xc5\x51\xe6\x76\xc8\xc9\xd9\x39\
\x04\xbb\x02\xc9\x0c\x47\x40\x4d\xac\x1b\xe5\x02\x6c\x82\x3f\x24\
\x08\x9a\xd4\xbd\x7e\x79\x7d\x69\x49\x44\xb0\xa6\x36\xab\xa6\x7f\
\x1b\xc0\xcc\x3b\x66\x3e\xb5\xd6\x0e\x29\xa5\xc7\x27\x0e\x04\xc0\
\x33\xc6\x78\xcd\x39\x6f\x47\x22\x35\x01\x2c\x21\x84\x4b\x29\x65\
\x99\x68\xc6\x00\xef\xfd\xad\xf7\x0e\x00\x20\xa2\x21\xe0\x7b\x21\
\x3a\xe7\x94\xd6\x1a\x44\x84\xd9\xb1\x4d\x1d\x58\x6b\x8f\xc6\x98\
\xe9\x0a\x10\x91\xb7\x5d\x6b\x55\xb5\xd6\x3d\x33\x9f\x53\x4a\xf7\
\x91\x8e\xfe\xbf\x80\x17\xa8\xc0\x5b\x7f\x18\x53\x58\x4b\x00\x00\
\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x01\x39\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x0b\x00\x00\x00\x0b\x08\x06\x00\x00\x00\xa9\xac\x77\x26\
\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\
\x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\
\x79\x71\xc9\x65\x3c\x00\x00\x00\xdb\x49\x44\x41\x54\x78\xda\x6c\
\xd0\xb1\xab\x41\x61\x18\xc7\xf1\x73\x4e\xb7\x3b\xdc\x85\x4c\xb8\
\xca\x66\x61\xb9\x56\x29\x49\xd9\x4d\x12\x29\x32\x2b\x45\x49\x16\
\x23\x77\xb8\x7f\xc0\x95\x3a\x0c\xfe\x08\x26\x83\xdd\x60\x61\x12\
\x19\x84\xe4\x0f\x38\xbe\x6f\x3d\x74\xca\x7b\xea\x73\xde\xde\xf7\
\xf9\xf5\xbc\x4f\xaf\x69\xdb\xf6\xa7\x61\x18\x03\x14\xe1\x33\xde\
\xbf\x2b\xc6\x68\x5a\xfc\xfa\x88\x20\x06\x53\x23\x2a\xf5\x9e\x0a\
\x97\x50\x41\x1a\x7b\xc4\xa5\xe3\x0f\x0e\x48\x4a\xbd\x66\xc9\xd5\
\x47\xfc\xe1\x1b\x73\x94\x31\x43\x50\x46\x54\x75\x9f\xe5\x9a\x2d\
\x87\x3b\xbc\x18\x49\x93\x1b\xf2\xcf\x80\x3b\xbc\x40\x03\x8e\xcc\
\xaa\xd6\x36\x96\xba\x70\x02\xbf\xae\xa0\x29\xfb\xac\x2e\x3c\x81\
\x07\x67\x14\x70\xc2\x97\x9c\xbf\xc2\x17\x04\xd0\xc1\x0e\x19\x4c\
\x91\xc2\x06\x75\xf8\x55\xee\x43\x1e\xfc\x1f\x55\x84\x5d\x37\xad\
\xe5\x7d\x43\x18\xaa\x8c\xea\xdc\xc2\x56\x8a\x8e\xc6\x4a\xea\xdd\
\x87\x00\x03\x00\xa6\x62\x31\x34\x9c\xff\x4d\x8d\x00\x00\x00\x00\
\x49\x45\x4e\x44\xae\x42\x60\x82\
"
qt_resource_name = b"\
\x00\x05\
\x00\x6f\xa6\x53\
\x00\x69\
\x00\x63\x00\x6f\x00\x6e\x00\x73\
\x00\x1d\
\x0d\x61\x33\xc7\
\x00\x74\
\x00\x61\x00\x62\x00\x5f\x00\x63\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x5f\x00\x6e\x00\x6f\x00\x6e\x00\x73\x00\x65\x00\x6c\x00\x65\
\x00\x63\x00\x74\x00\x65\x00\x64\x00\x5f\x00\x62\x00\x74\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1b\
\x02\x39\x96\x07\
\x00\x73\
\x00\x6d\x00\x61\x00\x6c\x00\x6c\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x5f\x00\x72\x00\x69\x00\x67\x00\x68\x00\x74\
\x00\x2d\x00\x6c\x00\x69\x00\x67\x00\x68\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1e\
\x0a\x11\x67\x27\
\x00\x64\
\x00\x6f\x00\x63\x00\x6b\x00\x74\x00\x69\x00\x74\x00\x6c\x00\x65\x00\x2d\x00\x6e\x00\x6f\x00\x72\x00\x6d\x00\x61\x00\x6c\x00\x2d\
\x00\x62\x00\x74\x00\x6e\x00\x2d\x00\x6c\x00\x69\x00\x67\x00\x68\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x11\
\x0c\x35\x80\x87\
\x00\x74\
\x00\x61\x00\x62\x00\x5f\x00\x63\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x5f\x00\x62\x00\x74\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
\
\x00\x1a\
\x00\x1b\xdc\x67\
\x00\x73\
\x00\x6d\x00\x61\x00\x6c\x00\x6c\x00\x5f\x00\x61\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x5f\x00\x6c\x00\x65\x00\x66\x00\x74\x00\x2d\
\x00\x6c\x00\x69\x00\x67\x00\x68\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x1d\
\x08\xa2\xd1\xc7\
\x00\x64\
\x00\x6f\x00\x63\x00\x6b\x00\x74\x00\x69\x00\x74\x00\x6c\x00\x65\x00\x2d\x00\x63\x00\x6c\x00\x6f\x00\x73\x00\x65\x00\x2d\x00\x62\
\x00\x74\x00\x6e\x00\x2d\x00\x6c\x00\x69\x00\x67\x00\x68\x00\x74\x00\x2e\x00\x70\x00\x6e\x00\x67\
"
The provided code snippet includes necessary dependencies for implementing the `qCleanupResources` function. Write a Python function `def qCleanupResources()` to solve the following problem:
Cleanup the qt resources.
Here is the function:
def qCleanupResources():
"""Cleanup the qt resources."""
QtCore.qUnregisterResourceData(
rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data
) | Cleanup the qt resources. |
161,135 | from typing import OrderedDict, List
from PyQt5.QtGui import QFontMetrics, QFont
from pyflow.scene.ipynb_conversion_constants import *
from pyflow.graphics.theme_manager import theme_manager
from pyflow.blocks.pyeditor import POINT_SIZE
def get_blocks_data(
data: OrderedDict, use_theme_font: bool = True
) -> List[OrderedDict]:
"""
Get the blocks corresponding to a ipynb file,
Returns them in the ipyg ordered dict format
"""
if "cells" not in data:
return []
# Get the font metrics to determine the size fo the blocks
fontmetrics = None
if use_theme_font:
font = QFont()
font.setFamily(theme_manager().recommended_font_family)
font.setFixedPitch(True)
font.setPointSize(POINT_SIZE)
fontmetrics = QFontMetrics(font)
blocks_data: List[OrderedDict] = []
next_block_x_pos: float = 0
next_block_y_pos: float = 0
next_block_id = 0
for cell in data["cells"]:
if "cell_type" not in cell or cell["cell_type"] not in ["code", "markdown"]:
pass
else:
block_type: str = cell["cell_type"]
text: List[str] = []
if isinstance(cell["source"], list):
text: str = cell["source"]
elif isinstance(cell["source"], str):
text = [line + "\n" for line in cell["source"].split("\n")]
else:
raise TypeError("A cell's source is not of the right type")
lineSpacing = DEFAULT_LINE_SPACING
lineHeight = DEFAULT_LINE_HEIGHT
if use_theme_font:
lineSpacing = fontmetrics.lineSpacing()
lineHeight = fontmetrics.lineWidth()
text_height: float = len(text) * (lineSpacing + lineHeight)
block_height: float = text_height + MARGIN_Y
block_data = {
"id": next_block_id,
"block_type": BLOCK_TYPE_TO_NAME[block_type],
"width": BLOCK_WIDTH,
"height": block_height,
"position": [
next_block_x_pos,
next_block_y_pos,
],
"sockets": [],
}
if block_type == "code":
block_data["source"] = "".join(text)
if len(blocks_data) > 0 and is_title(blocks_data[-1]):
block_title: OrderedDict = blocks_data.pop()
block_data["title"] = block_title["text"]
# Revert position effect of the markdown block
next_block_y_pos -= (
block_data["position"][1] - block_title["position"][1]
)
block_data["position"] = block_title["position"]
elif block_type == "markdown":
block_data.update(
{
"text": "".join(text),
}
)
next_block_y_pos += block_height + MARGIN_BETWEEN_BLOCKS_Y
blocks_data.append(block_data)
next_block_id += 1
# adujst_markdown_blocks_width(blocks_data)
return blocks_data
def get_edges_data(blocks_data: OrderedDict) -> OrderedDict:
"""Add sockets to the blocks (in place) and returns the edge list."""
code_blocks: List[OrderedDict] = [
block
for block in blocks_data
if block["block_type"] == BLOCK_TYPE_TO_NAME["code"]
]
edges_data: List[OrderedDict] = []
greatest_block_id: int = 0
if len(blocks_data) > 0:
greatest_block_id = blocks_data[-1]["id"]
last_socket_id_out: int = -1
for i, block in enumerate(code_blocks):
socket_id_out: int = greatest_block_id + 2 * i + 2
socket_id_in: int = greatest_block_id + 2 * i + 1
# Only add sockets where there will be edges
if i > 0:
block["sockets"].append(get_input_socket_data(socket_id_in, block))
if i < len(code_blocks) - 1:
block["sockets"].append(get_output_socket_data(socket_id_out, block))
if i >= 1:
edges_data.append(
get_edge_data(
i,
code_blocks[i - 1]["id"],
last_socket_id_out,
code_blocks[i]["id"],
socket_id_in,
)
)
last_socket_id_out = socket_id_out
return edges_data
The provided code snippet includes necessary dependencies for implementing the `ipynb_to_ipyg` function. Write a Python function `def ipynb_to_ipyg(data: OrderedDict, use_theme_font: bool = True) -> OrderedDict` to solve the following problem:
Convert ipynb data (ipynb file, as ordered dict) into ipyg data (ipyg, as ordered dict) - use_theme_font: should the height of the blocks be computed based on the current font selected.
Here is the function:
def ipynb_to_ipyg(data: OrderedDict, use_theme_font: bool = True) -> OrderedDict:
"""
Convert ipynb data (ipynb file, as ordered dict) into ipyg data (ipyg, as ordered dict)
- use_theme_font: should the height of the blocks be computed based on the current
font selected.
"""
blocks_data: List[OrderedDict] = get_blocks_data(data, use_theme_font)
edges_data: List[OrderedDict] = get_edges_data(blocks_data)
return {
"blocks": blocks_data,
"edges": edges_data,
} | Convert ipynb data (ipynb file, as ordered dict) into ipyg data (ipyg, as ordered dict) - use_theme_font: should the height of the blocks be computed based on the current font selected. |
161,136 | from typing import OrderedDict, List, Set
import copy
from pyflow.scene.ipynb_conversion_constants import *
def get_block_in_order(data: OrderedDict) -> OrderedDict:
"""Change the order of the blocks from random to the naturel flow of the documents.
Markdown blocks are put in a random order at the end of the document.
Other blocks are not saved."""
blocks_data = data["blocks"]
edges_data = data["edges"]
code_blocks: List[OrderedDict] = [
block
for block in blocks_data
if block["block_type"] == BLOCK_TYPE_TO_NAME["code"]
]
markdown_blocks: List[OrderedDict] = [
block
for block in blocks_data
if block["block_type"] == BLOCK_TYPE_TO_NAME["markdown"]
]
# The adjacency map
adjacency_map: Dict[int, List[int]] = {}
# Initialize the map
for block in code_blocks:
adjacency_map[block["id"]] = []
# Fill the map with the data contained in the edges
for edge in edges_data:
# Add edges linking two coding blocks together
if (
edge["source"]["block"] in adjacency_map
and edge["destination"]["block"] in adjacency_map
):
adjacency_map[edge["source"]["block"]].append(edge["destination"]["block"])
return topological_sort(code_blocks, adjacency_map) + markdown_blocks
def block_to_ipynb_cell(block_data: OrderedDict) -> OrderedDict:
"""Convert a ipyg block into its corresponding ipynb cell."""
if block_data["block_type"] == BLOCK_TYPE_TO_NAME["code"]:
cell_data: OrderedDict = copy.deepcopy(DEFAULT_CODE_CELL)
cell_data["source"] = split_lines_and_add_newline(block_data["source"])
return cell_data
if block_data["block_type"] == BLOCK_TYPE_TO_NAME["markdown"]:
cell_data: OrderedDict = copy.deepcopy(DEFAULT_MARKDOWN_CELL)
cell_data["source"] = split_lines_and_add_newline(block_data["text"])
return cell_data
raise ValueError(
f"The block type {block_data['block_type']} is not supported but has been declared as such"
)
The provided code snippet includes necessary dependencies for implementing the `ipyg_to_ipynb` function. Write a Python function `def ipyg_to_ipynb(data: OrderedDict) -> OrderedDict` to solve the following problem:
Convert ipyg data (as ordered dict) into ipynb data (as ordered dict).
Here is the function:
def ipyg_to_ipynb(data: OrderedDict) -> OrderedDict:
"""Convert ipyg data (as ordered dict) into ipynb data (as ordered dict)."""
ordered_blocks: OrderedDict = get_block_in_order(data)
ipynb_data: OrderedDict = copy.deepcopy(DEFAULT_NOTEBOOK_DATA)
for block_data in ordered_blocks:
if block_data["block_type"] in BLOCK_TYPE_SUPPORTED_FOR_IPYG_TO_IPYNB:
ipynb_data["cells"].append(block_to_ipynb_cell(block_data))
return ipynb_data | Convert ipyg data (as ordered dict) into ipynb data (as ordered dict). |
161,137 | import os
from pathlib import Path
from typing import List
import hcaptcha_challenger as solver
assets_dir = Path(__file__).parent.parent.joinpath("assets")
pending_keys = ["hedgehog", "rabbit", "raccoon"]
def bytedance(image_paths: List[Path], example_paths: List[Path] = None):
classifier = solver.BinaryClassifier()
if results := classifier.execute(prompt, image_paths, example_paths):
for image_path, result in zip(image_paths, results):
desc = f"{image_path.parent.name}/{image_path.name}"
print(f">> {desc=} - {result=} {classifier.model_name=}")
def demo():
for pk in pending_keys:
images_dir = assets_dir.joinpath("please click on the largest animal")
example_paths = [images_dir.joinpath(f"example_{pk}.png")]
images_dir = images_dir.joinpath(pk)
image_paths = [images_dir.joinpath(image_name) for image_name in os.listdir(images_dir)]
# Regular interface
bytedance(image_paths, example_paths) | null |
161,138 | import os
from pathlib import Path
from typing import List
from PIL import Image
import hcaptcha_challenger as solver
from hcaptcha_challenger import ModelHub, register_pipline, DataLake, ZeroShotImageClassifier
def prelude_self_supervised_config():
def load_samples() -> List[Path]:
def demo():
modelhub, clip_model = prelude_self_supervised_config()
image_paths = load_samples()
# Parse following fields from `requester_restricted_answer_set`
# from: list(requester_restricted_answer_set.keys())
candidates = ["Kitchen", "Living Room", "Bedroom"]
dl = DataLake.from_binary_labels(positive_labels=candidates[:1], negative_labels=candidates[1:])
tool = ZeroShotImageClassifier.from_datalake(dl)
# `image_paths` are the already downloaded images of the challenge
# That is, the picture downloaded from the endpoint link `tasklist.datapoint_uri`
for image_path in image_paths:
results = tool(clip_model, image=Image.open(image_path))
trusted_prompt = results[0]["label"]
for label in candidates:
if DataLake.PREMISED_YES.format(label) == trusted_prompt:
# That is, the most consistent description of the picture is the `trusted_label`
# You can return this variable as needed, and then submit the form
# or click on the btn page element to which it is bound.
trusted_label = label
print(f"{image_path.name=} {trusted_label=}") | null |
161,139 | import os
import sys
from pathlib import Path
import cv2
from tqdm import tqdm
import hcaptcha_challenger as solver
from hcaptcha_challenger.onnx.modelhub import ModelHub
from hcaptcha_challenger.onnx.yolo import YOLOv8Seg
def yolov8_segment(images_dir: Path, output_dir: Path):
def demo(startfile=True):
# fmt:off
groups = [
("please click the center of a circle where all the shapes are of the same color", "default"),
("please click the center of the object that is never repeated", "default"),
("please click on the object that appears only once", "default"),
]
# fmt:on
assets_dir = Path(__file__).parent.parent.joinpath("assets", "image_label_area_select")
for group in groups:
images_dir = assets_dir.joinpath(*group)
output_dir = Path(__file__).parent.joinpath("figs-seg-out", group[0])
output_dir.mkdir(parents=True, exist_ok=True)
yolov8_segment(images_dir, output_dir)
if "win32" in sys.platform and startfile:
os.startfile(output_dir)
print(f">> View at {output_dir}") | null |
161,140 | from __future__ import annotations
import asyncio
from pathlib import Path
from loguru import logger
from playwright.async_api import BrowserContext as ASyncContext, async_playwright, Page
from hcaptcha_challenger import ModelHub, install
from hcaptcha_challenger.agents import AgentT, Malenia
from hcaptcha_challenger.utils import SiteKey
async def hit_challenge(context: ASyncContext, times: int = 8):
page = await context.new_page()
agent = prelude(page)
url = SiteKey.as_sitelink(sitekey)
await page.goto(url)
logger.info("startup sitelink", url=url)
await agent.handle_checkbox()
for pth in range(1, times):
# Handle challenge
result = await agent.execute()
if not agent.qr:
return
# Post-processing
match result:
case agent.status.CHALLENGE_BACKCALL | agent.status.CHALLENGE_RETRY:
logger.warning(f"retry", pth=pth, ash=agent.ash)
await page.wait_for_timeout(500)
fl = page.frame_locator(agent.HOOK_CHALLENGE)
await fl.locator("//div[@class='refresh button']").click()
case agent.status.CHALLENGE_SUCCESS:
logger.success(f"task done", pth=pth, ash=agent.ash)
rqdata_path = agent.export_rq()
print(f"\n>> View RQdata path={rqdata_path}")
return
async def bytedance(undetected: bool = False):
# playwright install chromium --with-deps
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False)
context = await browser.new_context(
locale="en-US", record_video_dir=Path("user_data_dir/record")
)
if undetected:
await Malenia.apply_stealth(context)
await hit_challenge(context) | null |
161,141 | import os
import shutil
import sys
from pathlib import Path
import cv2
from tqdm import tqdm
import hcaptcha_challenger as solver
from hcaptcha_challenger.onnx.modelhub import ModelHub
from hcaptcha_challenger.onnx.yolo import YOLOv8Seg
def yolov8_segment(images_dir: Path, output_dir: Path):
def demo(startfile=True):
assets_dir = Path(__file__).parent.parent.joinpath("assets", "image_label_area_select")
images_dir = assets_dir.joinpath("please click on the star with a texture of bricks")
output_dir = Path(__file__).parent.joinpath("figs-star-bricks-seg-out")
shutil.rmtree(output_dir, ignore_errors=True)
output_dir.mkdir(parents=True, exist_ok=True)
yolov8_segment(images_dir, output_dir)
if "win32" in sys.platform and startfile:
os.startfile(output_dir)
print(f">> View at {output_dir}") | null |
161,142 | import os
import sys
from pathlib import Path
from typing import Callable
import cv2
from tqdm import tqdm
import hcaptcha_challenger as solver
from hcaptcha_challenger.components.cv_toolkit.appears_only_once import (
limited_radius,
annotate_objects,
find_unique_object,
find_unique_color,
)
from hcaptcha_challenger.onnx.modelhub import ModelHub
from hcaptcha_challenger.onnx.yolo import YOLOv8Seg
def execute(images_dir: Path, trident: Callable, output_dir: Path):
# Load model (automatic download, 51MB)
model_name = "appears_only_once_2309_yolov8s-seg.onnx"
classes = modelhub.ashes_of_war.get(model_name)
session = modelhub.match_net(model_name)
yoloseg = YOLOv8Seg.from_pluggable_model(session, classes)
# Read data set
pending_image_paths = [images_dir.joinpath(image_name) for image_name in os.listdir(images_dir)]
# Initialize progress bar
total = len(pending_image_paths)
desc_in = f'"{images_dir.parent.name}/{images_dir.name}"'
with tqdm(total=total, desc=f"Labeling | {desc_in}") as progress:
for image_path in pending_image_paths:
# Find all the circles in the picture
results = yoloseg(image_path)
# Find the unique circle and draw the center of the circle
combined_img = draw_unique_object(results, str(image_path), trident)
# Draw a bounding box and mask region for all circles
combined_img = yoloseg.draw_masks(combined_img, mask_alpha=0.1)
# Preserve pictures with traces of drawing
output_path = output_dir.joinpath(image_path.name)
cv2.imwrite(str(output_path), combined_img)
progress.update(1)
def find_unique_object(img: np.ndarray, circles: List[List[int]]) -> Tuple[int, int, int]:
mask_images = _build_mask(img, circles, lookup="object")
similarity = []
for i, mask_img in enumerate(mask_images):
sig_sim = []
for j, mask_img_ in enumerate(mask_images):
if i == j:
sig_sim.append(0)
continue
score, _ = compare_ssim(mask_img, mask_img_, win_size=3, full=True)
sig_sim.append(score)
similarity.append(np.array(sig_sim))
similarity = np.array(similarity)
sum_similarity = np.sum(similarity, axis=0)
unique_index = np.argmin(sum_similarity)
unique_circle = circles[unique_index]
return unique_circle[0], unique_circle[1], unique_circle[2]
def find_unique_color(img: np.ndarray, circles: List[List[int]]) -> Tuple[int, int, int]:
mask_images = _build_mask(img, circles, lookup="color")
original_mask_images = mask_images.copy()
original_mask_images = np.array(original_mask_images)
mask_images = [cv2.convertScaleAbs(mask_img, alpha=1.5, beta=0) for mask_img in mask_images]
scores = []
for original_mask_img, mask_img in zip(original_mask_images, mask_images):
gray = cv2.cvtColor(mask_img, cv2.COLOR_BGR2GRAY)
center_color = gray[gray.shape[0] // 2, gray.shape[1] // 2]
gray[gray < min(200, int(center_color))] = 0
# remove noise
kernel = np.ones((3, 3), np.uint8)
gray = cv2.morphologyEx(gray, cv2.MORPH_OPEN, kernel)
# binary
threshold = 255
gray[gray < threshold] = 0
gray[gray >= threshold] = 255
colors = original_mask_img[gray == 0]
colors = np.array(colors).reshape(-1, 3)
score = np.var(colors, axis=0).sum()
scores.append(score)
unique_index = np.argmin(scores)
unique_circle = circles[unique_index]
return unique_circle[0], unique_circle[1], unique_circle[2]
def demo(startfile=True):
prompt2trident = {
"please click the center of the object that is never repeated": find_unique_object,
"please click on the object that appears only once": find_unique_object,
"please click the center of a circle where all the shapes are of the same color": find_unique_color,
}
assets_dir = Path(__file__).parent.parent.joinpath("assets", "image_label_area_select")
for prompt, trident in prompt2trident.items():
images_dir = assets_dir.joinpath(prompt, "default")
output_dir = Path(__file__).parent.joinpath("figs-unique-out", prompt)
output_dir.mkdir(parents=True, exist_ok=True)
execute(images_dir, trident, output_dir)
if "win32" in sys.platform and startfile:
os.startfile(output_dir)
print(f">> View at {output_dir}") | null |
161,143 | from __future__ import annotations
import logging
import os
import shutil
import sys
from dataclasses import dataclass, field
from datetime import datetime
from pathlib import Path
from typing import Tuple, List
from PIL import Image
from tqdm import tqdm
import hcaptcha_challenger as solver
from hcaptcha_challenger import DataLake, ModelHub, ZeroShotImageClassifier, register_pipline
class AutoLabeling:
"""
Example:
---
1. Roughly observe the distribution of the dataset and design a DataLake for the challenge prompt.
- ChallengePrompt: "Please click each image containing an off-road vehicle"
- positive_labels --> ["off-road vehicle"]
- negative_labels --> ["bicycle", "car"]
2. You can design them in batches and save them as YAML files,
which the classifier can read and automatically DataLake
3. Note that positive_labels is a list, and you can specify multiple labels for this variable
if the label pointed to by the prompt contains ambiguity。
"""
input_dir: Path = field(default_factory=Path)
pending_tasks: List[Path] = field(default_factory=list)
tool: ZeroShotImageClassifier = field(default_factory=ZeroShotImageClassifier)
output_dir: Path = field(default_factory=Path)
limit: int = field(default=1)
"""
By default, all pictures in the specified folder are classified and moved,
Specifies the limit used to limit the number of images for the operation.
"""
def from_datalake(cls, dl: DataLake, **kwargs):
if not isinstance(dl.joined_dirs, Path):
raise TypeError(
"The dataset joined_dirs needs to be passed in for auto-labeling. -"
f" {dl.joined_dirs=}"
)
if not dl.joined_dirs.exists():
raise ValueError(f"Specified dataset path does not exist - {dl.joined_dirs=}")
input_dir = dl.joined_dirs
pending_tasks = []
for image_name in os.listdir(input_dir):
image_path = input_dir.joinpath(image_name)
if image_path.is_file():
pending_tasks.append(image_path)
if (limit := kwargs.get("limit")) is None:
limit = len(pending_tasks)
elif not isinstance(limit, int) or limit < 1:
raise ValueError(f"limit should be a positive integer greater than zero. - {limit=}")
tool = ZeroShotImageClassifier.from_datalake(dl)
return cls(tool=tool, input_dir=input_dir, pending_tasks=pending_tasks, limit=limit)
def mkdir(self) -> Tuple[Path, Path, Path]:
__formats = ("%Y-%m-%d %H:%M:%S.%f", "%Y%m%d%H%M")
now = datetime.strptime(str(datetime.now()), __formats[0]).strftime(__formats[1])
tmp_dir = self.input_dir.joinpath(now)
yes_dir = tmp_dir.joinpath("yes")
bad_dir = tmp_dir.joinpath("bad")
yes_dir.mkdir(parents=True, exist_ok=True)
bad_dir.mkdir(parents=True, exist_ok=True)
self.output_dir = tmp_dir
for label in self.tool.candidate_labels:
tmp_dir.joinpath(label).mkdir(parents=True, exist_ok=True)
return yes_dir, bad_dir, tmp_dir
def execute(self, model):
if not self.pending_tasks:
logging.info("No pending tasks")
return
yes_dir, bad_dir, tmp_dir = self.mkdir()
desc_in = f'"{self.input_dir.parent.name}/{self.input_dir.name}"'
total = len(self.pending_tasks)
logging.info(f"load {self.tool.positive_labels=}")
logging.info(f"load {self.tool.candidate_labels=}")
with tqdm(total=total, desc=f"Labeling | {desc_in}") as progress:
for image_path in self.pending_tasks[: self.limit]:
# The label at position 0 is the highest scoring target
image = Image.open(image_path)
results = self.tool(model, image)
# we're only dealing with binary classification tasks here
trusted_label = results[0]["label"]
if trusted_label in self.tool.positive_labels:
output_path = yes_dir.joinpath(image_path.name)
else:
output_path = bad_dir.joinpath(image_path.name)
shutil.copyfile(image_path, output_path)
# Store multi-classification results
bk_path = tmp_dir.joinpath(trusted_label, image_path.name)
shutil.copyfile(image_path, bk_path)
progress.update(1)
def run(startfile=True):
assets_dir = Path(__file__).parent.parent.joinpath("assets")
modelhub = ModelHub.from_github_repo()
modelhub.parse_objects()
# Make sure you have torch and transformers installed and
# the NVIDIA graphics card is available
model = register_pipline(modelhub, fmt="transformers")
flow_card = [
{
"positive_labels": ["off-road vehicle"],
"negative_labels": ["car", "bicycle"],
"joined_dirs": ["image_label_binary", "off_road_vehicle"],
}
]
for card in flow_card:
# Generating a dataclass from serialized data
dl = DataLake(
positive_labels=card["positive_labels"],
negative_labels=card["negative_labels"],
joined_dirs=assets_dir.joinpath(*card["joined_dirs"]),
)
# Starts an automatic labeling task
al = AutoLabeling.from_datalake(dl)
al.execute(model)
# Automatically open output directory
if "win32" in sys.platform and al.output_dir.is_dir() and startfile:
os.startfile(al.output_dir) | null |
161,144 | from __future__ import annotations
import asyncio
import json
from pathlib import Path
from loguru import logger
from hcaptcha_challenger import install, QuestionResp, Answers, Status, ModelHub
from hcaptcha_challenger.agents import AgentR
def patch_modelhub(modelhub: ModelHub):
"""
1. Patching clip_candidates allows you to handle all image classification tasks in self-supervised mode.
2. You need to inject hints for all categories that appear in a batch of images
3. The ObjectsYaml in the GitHub repository are updated regularly,
but if you find something new, you can imitate the following and patch some hints.
4. Note that this should be a regularly changing table.
If after a while certain labels no longer appear, you should not fill them in clip_candidates
5. Please note that you only need a moderate number of candidates prompts,
too many prompts will increase the computational complexity
:param modelhub:
:return:
"""
modelhub.clip_candidates.update(
{
"the largest animal in real life": [
"parrot",
"bee",
"ladybug",
"frog",
"crab",
"bat",
"butterfly",
"dragonfly",
]
}
)
def install(
upgrade: bool | None = False,
username: str = "QIN2DIM",
lang: str = "en",
flush_yolo: bool | Iterable[str] = False,
pypi: bool = False,
clip: bool = False,
**kwargs,
):
if pypi is True:
from hcaptcha_challenger.utils import PyPI
PyPI("hcaptcha-challenger").install()
modelhub = ModelHub.from_github_repo(username=username, lang=lang)
modelhub.pull_objects(upgrade=upgrade)
modelhub.assets.flush_runtime_assets(upgrade=upgrade)
if clip is True:
from hcaptcha_challenger.components.zero_shot_image_classifier import register_pipline
register_pipline(modelhub, install_only=True)
if flush_yolo is not None:
modelhub.parse_objects()
if isinstance(flush_yolo, bool) and flush_yolo:
flush_yolo = [modelhub.circle_segment_model]
if isinstance(flush_yolo, Iterable):
pending_models = []
for model_name in flush_yolo:
if model_name in modelhub.ashes_of_war:
modelhub.match_net(model_name, install_only=True)
pending_models.append(model_name)
return pending_models
def prelude() -> AgentR:
# 1. You need to deploy sub-thread tasks and actively run `install(upgrade=True)` every 20 minutes
# 2. You need to make sure to run `install(upgrade=True, clip=True)` before each instantiation
install(upgrade=True, clip=True)
modelhub = ModelHub.from_github_repo()
modelhub.parse_objects()
# Make arbitrary pre-modifications to modelhub, which is very useful for CLIP models
patch_modelhub(modelhub)
agent = AgentR.summon_ranni_the_witch(
# Register modelhub externally, and the agent can patch custom configurations
modelhub=modelhub,
# Mount the cache directory to the current working folder
tmp_dir=Path(__file__).parent.joinpath("tmp_dir"),
# Enable CLIP zero-shot image classification method
clip=True,
)
return agent | null |
161,145 | from __future__ import annotations
import asyncio
import json
from pathlib import Path
from loguru import logger
from hcaptcha_challenger import install, QuestionResp, Answers, Status, ModelHub
from hcaptcha_challenger.agents import AgentR
The provided code snippet includes necessary dependencies for implementing the `get_question_data` function. Write a Python function `def get_question_data() -> QuestionResp` to solve the following problem:
import httpx url = "https://api.hcaptcha.com/getcaptcha/{sitekey}" res = httpx.post(url, json=payload) data = res.json() :return: QuestionResp(**data)
Here is the function:
def get_question_data() -> QuestionResp:
"""
import httpx
url = "https://api.hcaptcha.com/getcaptcha/{sitekey}"
res = httpx.post(url, json=payload)
data = res.json()
:return: QuestionResp(**data)
"""
dp = Path(__file__).parent.parent.joinpath(
"assets/record_json/image_label_binary.beverage.json"
)
data = json.loads(dp.read_text(encoding="utf8"))
return QuestionResp(**data) | import httpx url = "https://api.hcaptcha.com/getcaptcha/{sitekey}" res = httpx.post(url, json=payload) data = res.json() :return: QuestionResp(**data) |
161,146 | from __future__ import annotations
import asyncio
import json
from pathlib import Path
from loguru import logger
from hcaptcha_challenger import install, QuestionResp, Answers, Status, ModelHub
from hcaptcha_challenger.agents import AgentR
def cache_rqdata(cache_dir: Path, response: Answers):
record_json = cache_dir.joinpath("payload_json")
record_json.mkdir(parents=True, exist_ok=True)
# You can export it as json format by the `model_dump_json()` method
json_path = record_json.joinpath(f"pipline-{response.job_mode}.json")
json_path.write_text(response.model_dump_json(indent=2))
logger.success("cache rqdata", output=f"{json_path}") | null |
161,147 | import csv
import os.path
import os.path
import time
from datetime import datetime
from pathlib import Path
from loguru import logger
from sanic import Sanic, Request
from sanic.response import html
from selenium.common.exceptions import WebDriverException
from selenium.webdriver import Chrome, ChromeOptions
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
class MotionData:
def __init__(self, temp_dir: Path):
self.ctx_session = None
self.temp_dir = temp_dir
self.action_name = "MotionData"
self.startpoint = time.time()
self.sequential_queue = {}
def __enter__(self):
options = ChromeOptions()
service = Service(ChromeDriverManager().install())
self.ctx_session = Chrome(service=service, options=options)
return self
def __exit__(self, exc_type, exc_val, exc_tb):
logger.debug(
f">> QUIT [{self.action_name}] Turn off tracker - "
f"runtime={round(time.time() - self.startpoint, 2)}s"
)
try:
if self.ctx_session:
self._overload(self.ctx_session)
self._offload()
self.ctx_session.quit()
except AttributeError:
pass
def _overload(self, ctx):
try:
mouse_track_obj = ctx.find_element(By.CLASS_NAME, "track-coordinate-list")
mouse_track = mouse_track_obj.text
except (WebDriverException, AttributeError):
logger.warning("Failed to record mouse track")
except Exception as err:
logger.debug(err)
else:
if not mouse_track:
return
for p in mouse_track.split(","):
x = [int(xi.split(".")[0]) for xi in p.split(":")]
self.sequential_queue[x[0]] = [x[1], x[2]]
def _offload(self):
endpoint = (
str(datetime.utcnow()).replace("-", "").replace(":", "").replace(" ", "").split(".")[0]
)
# Record track
fn = os.path.join(self.temp_dir, "motion_data", f"{endpoint}.csv")
os.makedirs(os.path.dirname(fn), exist_ok=True)
with open(fn, "w", encoding="utf8", newline="") as file:
writer = csv.writer(file)
for xp, yp in self.sequential_queue.values():
writer.writerow([xp, yp])
# Record offset
fn_offset = os.path.join(os.path.dirname(fn), f"{endpoint}.offset.csv")
with open(fn_offset, "w", encoding="utf8", newline="") as file:
writer = csv.writer(file)
timeline = list(self.sequential_queue)[200:-200]
for i in range(len(timeline) - 1):
x1, y1 = self.sequential_queue[timeline[i]]
x2, y2 = self.sequential_queue[timeline[i + 1]]
writer.writerow([x2 - x1, y2 - y1])
logger.debug(
f">> OFFLOAD [{self.action_name}] Record mouse track - endpoint={endpoint} path={fn}"
)
def mimic(self, url: str = "http://127.0.0.1:8000"):
if not self.ctx_session:
return
try:
self.ctx_session.get(url)
logger.debug("Press CTRL + C to terminate the action")
for _ in range(120):
time.sleep(0.24)
self._overload(self.ctx_session)
except (KeyboardInterrupt, EOFError):
logger.debug("Received keyboard interrupt signal")
def train_motion(test_site: str, temp_dir: Path):
with MotionData(temp_dir) as motion:
motion.mimic(test_site) | null |
161,148 | import os
from pathlib import Path
from typing import List
import hcaptcha_challenger as solver
from hcaptcha_challenger import handle, ModelHub, DataLake, register_pipline
solver.install(upgrade=True, clip=True)
prompt = "Please click each image containing a sedan car"
def prelude_self_supervised_config():
modelhub = ModelHub.from_github_repo()
modelhub.parse_objects()
for prompt_, serialized_binary in datalake_post.items():
modelhub.datalake[prompt_] = DataLake.from_serialized(serialized_binary)
clip_model = register_pipline(modelhub)
return modelhub, clip_model
def get_test_images() -> List[Path]:
images = []
for image_name in os.listdir(images_dir):
image_path = images_dir.joinpath(image_name)
if image_path.is_file():
images.append(image_path)
return images
def demo():
modelhub, clip_model = prelude_self_supervised_config()
image_paths = get_test_images()
classifier = solver.BinaryClassifier(modelhub=modelhub, clip_model=clip_model)
if results := classifier.execute(prompt, image_paths, self_supervised=True):
for image_path, result in zip(image_paths, results):
print(f"{image_path.name=} - {result=} {classifier.model_name=}") | null |
161,149 | import os
from pathlib import Path
import hcaptcha_challenger as solver
solver.install(upgrade=True)
prompt = "please click on the elephant"
images_dir = assets_dir.joinpath("image_label_area_select", "raccoon")
images = [images_dir.joinpath(fn).read_bytes() for fn in os.listdir(images_dir)]
def bytedance():
tool = solver.AreaSelector()
results = tool.execute(prompt, images, shape_type="point")
if not results:
return
for i, filename in enumerate(os.listdir(images_dir)):
alts = results[i]
if len(alts) > 1:
alts = sorted(alts, key=lambda x: x[-1])
if len(alts) > 0:
best = alts[-1]
class_name, (center_x, center_y), score = best
print(f"{images_dir.name}.{filename} - {class_name=} {(center_x, center_y)=}")
else:
print(f"{images_dir.name}.{filename} - ObjectsNotFound") | null |
161,150 | import os
from pathlib import Path
from typing import List
import hcaptcha_challenger as solver
solver.install(upgrade=True)
prompt = "diamond bracelet"
def get_test_images() -> List[Path]:
image_paths = []
for image_name in os.listdir(images_dir):
image_path = images_dir.joinpath(image_name)
if image_path.is_file():
image_paths.append(image_path)
return image_paths
def bytedance():
image_paths = get_test_images()
classifier = solver.BinaryClassifier()
if results := classifier.execute(prompt, image_paths):
for image_path, result in zip(image_paths, results):
print(f"{image_path.name=} - {result=} {classifier.model_name=}") | null |
161,151 | from __future__ import annotations
import inspect
import random
import subprocess
import sys
import uuid
from shlex import quote
from typing import Dict, Any, Literal
from loguru import logger
def init_log(**sink_channel):
event_logger_format = "<g>{time:YYYY-MM-DD HH:mm:ss}</g> | <lvl>{level}</lvl> - {message}"
persistent_format = (
"<g>{time:YYYY-MM-DD HH:mm:ss}</g> | "
"<lvl>{level}</lvl> | "
"<c><u>{name}</u></c>:{function}:{line} | "
"{message} - "
"{extra}"
)
serialize_format = event_logger_format + " - {extra}"
logger.remove()
logger.add(
sink=sys.stdout, colorize=True, level="DEBUG", format=serialize_format, diagnose=False
)
if sink_channel.get("error"):
logger.add(
sink=sink_channel.get("error"),
level="ERROR",
rotation="1 week",
encoding="utf8",
diagnose=False,
format=persistent_format,
)
if sink_channel.get("runtime"):
logger.add(
sink=sink_channel.get("runtime"),
level="DEBUG",
rotation="20 MB",
retention="20 days",
encoding="utf8",
diagnose=False,
format=persistent_format,
)
if sink_channel.get("serialize"):
logger.add(
sink=sink_channel.get("serialize"),
level="DEBUG",
format=persistent_format,
encoding="utf8",
diagnose=False,
serialize=True,
)
return logger | null |
161,152 | from __future__ import annotations
import inspect
import random
import subprocess
import sys
import uuid
from shlex import quote
from typing import Dict, Any, Literal
from loguru import logger
def from_dict_to_model(cls, data: Dict[str, Any]):
return cls(
**{
key: (data[key] if val.default == val.empty else data.get(key, val.default))
for key, val in inspect.signature(cls).parameters.items()
}
) | null |
161,153 | from __future__ import annotations
import logging
import os
import sys
from undetected_chromedriver import Chrome
from undetected_chromedriver import ChromeOptions
from webdriver_manager.chrome import ChromeDriverManager
def create_chrome_options(silence: bool | None = None, lang: str | None = None) -> ChromeOptions:
"""
Create ChromeOptions for undetected_chromedriver.Chrome
:param silence: Control headless browser
:param lang: Restrict the language of hCAPTCHA label.
:rtype: undetected_chromedriver.ChromeOptions
"""
# - Restrict browser startup parameters
options = ChromeOptions()
options.add_argument("--log-level=3")
options.add_argument("--disable-dev-shm-usage")
# - Restrict the language of hCaptcha label
# - Environment variables are valid only in the current process
# and do not affect other processes in the operating system
os.environ["LANGUAGE"] = "en_US" if lang is None else lang
options.add_argument(f"--lang={os.getenv('LANGUAGE')}")
if silence is True:
options.add_argument("--disable-gpu")
options.add_argument("--disable-software-rasterizer")
return options
The provided code snippet includes necessary dependencies for implementing the `get_challenge_ctx` function. Write a Python function `def get_challenge_ctx(silence: bool | None = None, lang: str | None = None, **kwargs)` to solve the following problem:
Challenger drive for handling human-machine challenges. :param silence: Control headless browser :param lang: Restrict the language of hCAPTCHA label. See https://github.com/QIN2DIM/hcaptcha-challenger/issues/13 :rtype: undetected_chromedriver.Chrome
Here is the function:
def get_challenge_ctx(silence: bool | None = None, lang: str | None = None, **kwargs):
"""
Challenger drive for handling human-machine challenges.
:param silence: Control headless browser
:param lang: Restrict the language of hCAPTCHA label.
See https://github.com/QIN2DIM/hcaptcha-challenger/issues/13
:rtype: undetected_chromedriver.Chrome
"""
# Control headless browser
# If on Linux, and no X server is available (`DISPLAY` not set), assume
# headless operation
silence = (
True
if silence is None or ("linux" in sys.platform and "DISPLAY" not in os.environ)
else silence
)
# - Use chromedriver cache to improve application startup speed
# - Requirement: undetected-chromedriver >= 3.1.5.post2
logging.getLogger("WDM").setLevel(logging.NOTSET)
driver_executable_path = ChromeDriverManager().install()
return Chrome(
options=create_chrome_options(silence, lang),
headless=silence,
driver_executable_path=driver_executable_path,
**kwargs,
) | Challenger drive for handling human-machine challenges. :param silence: Control headless browser :param lang: Restrict the language of hCAPTCHA label. See https://github.com/QIN2DIM/hcaptcha-challenger/issues/13 :rtype: undetected_chromedriver.Chrome |
161,154 | from __future__ import annotations
import os
import cv2
import importlib_metadata
import numpy as np
def _is_package_available(pkg_name: str) -> bool:
try:
package_version = importlib_metadata.metadata(pkg_name) is not None
return bool(package_version)
except importlib_metadata.PackageNotFoundError:
return False | null |
161,155 | from __future__ import annotations
import os
import cv2
import importlib_metadata
import numpy as np
_torch_available = False
def is_torch_available():
return _torch_available | null |
161,156 | from __future__ import annotations
import os
import cv2
import importlib_metadata
import numpy as np
_transformers_available = _is_package_available("transformers")
def is_transformers_available():
return _transformers_available | null |
161,157 | from __future__ import annotations
import os
import cv2
import importlib_metadata
import numpy as np
def nms(boxes, scores, iou_threshold):
# Sort by score
sorted_indices = np.argsort(scores)[::-1]
keep_boxes = []
while sorted_indices.size > 0:
# Pick the last box
box_id = sorted_indices[0]
keep_boxes.append(box_id)
# Compute IoU of the picked box with the rest
ious = compute_iou(boxes[box_id, :], boxes[sorted_indices[1:], :])
# Remove boxes with IoU over the threshold
keep_indices = np.where(ious < iou_threshold)[0]
# print(keep_indices.shape, sorted_indices.shape)
sorted_indices = sorted_indices[keep_indices + 1]
return keep_boxes
def multiclass_nms(boxes, scores, class_ids, iou_threshold):
unique_class_ids = np.unique(class_ids)
keep_boxes = []
for class_id in unique_class_ids:
class_indices = np.where(class_ids == class_id)[0]
class_boxes = boxes[class_indices, :]
class_scores = scores[class_indices]
class_keep_boxes = nms(class_boxes, class_scores, iou_threshold)
keep_boxes.extend(class_indices[class_keep_boxes])
return keep_boxes | null |
161,158 | from __future__ import annotations
import os
import cv2
import importlib_metadata
import numpy as np
def xywh2xyxy(x):
# Convert bounding box (x, y, w, h) to bounding box (x1, y1, x2, y2)
y = np.copy(x)
y[..., 0] = x[..., 0] - x[..., 2] / 2
y[..., 1] = x[..., 1] - x[..., 3] / 2
y[..., 2] = x[..., 0] + x[..., 2] / 2
y[..., 3] = x[..., 1] + x[..., 3] / 2
return y | null |
161,159 | from __future__ import annotations
import os
import cv2
import importlib_metadata
import numpy as np
def sigmoid(x):
return 1 / (1 + np.exp(-x)) | null |
161,160 | from __future__ import annotations
import os
import cv2
import importlib_metadata
import numpy as np
def draw_masks(image, boxes, class_ids, colors, mask_alpha=0.3, mask_maps=None):
mask_img = image.copy()
# Draw bounding boxes and labels of detections
for i, (box, class_id) in enumerate(zip(boxes, class_ids)):
color = colors[class_id]
x1, y1, x2, y2 = box.astype(int)
# Draw fill mask image
if mask_maps is None:
cv2.rectangle(mask_img, (x1, y1), (x2, y2), color, -1)
else:
crop_mask = mask_maps[i][y1:y2, x1:x2, np.newaxis]
crop_mask_img = mask_img[y1:y2, x1:x2]
crop_mask_img = crop_mask_img * (1 - crop_mask) + crop_mask * color
mask_img[y1:y2, x1:x2] = crop_mask_img
return cv2.addWeighted(mask_img, mask_alpha, image, 1 - mask_alpha, 0)
def draw_detections(
image, boxes, scores, class_ids, colors, classes, mask_alpha=0.3, mask_maps=None
):
img_height, img_width = image.shape[:2]
size = min([img_height, img_width]) * 0.0006
text_thickness = int(min([img_height, img_width]) * 0.001)
mask_img = draw_masks(image, boxes, class_ids, colors, mask_alpha, mask_maps)
# Draw bounding boxes and labels of detections
for box, score, class_id in zip(boxes, scores, class_ids):
color = colors[class_id]
x1, y1, x2, y2 = box.astype(int)
# Draw rectangle
cv2.rectangle(mask_img, (x1, y1), (x2, y2), color, 2)
label = classes[class_id]
caption = f"{label} {int(score * 100)}%"
(tw, th), _ = cv2.getTextSize(
text=caption,
fontFace=cv2.FONT_HERSHEY_SIMPLEX,
fontScale=size,
thickness=text_thickness,
)
th = int(th * 1.2)
cv2.rectangle(mask_img, (x1, y1), (x1 + tw, y1 - th), color, -1)
cv2.putText(
mask_img,
caption,
(x1, y1),
cv2.FONT_HERSHEY_SIMPLEX,
size,
(255, 255, 255),
text_thickness,
cv2.LINE_AA,
)
return mask_img | null |
161,161 | from __future__ import annotations
import os
import cv2
import importlib_metadata
import numpy as np
def draw_comparison(img1, img2, name1, name2, fontsize=2.6, text_thickness=3):
(tw, th), _ = cv2.getTextSize(
text=name1, fontFace=cv2.FONT_HERSHEY_DUPLEX, fontScale=fontsize, thickness=text_thickness
)
x1 = img1.shape[1] // 3
y1 = th
offset = th // 5
cv2.rectangle(
img1,
(x1 - offset * 2, y1 + offset),
(x1 + tw + offset * 2, y1 - th - offset),
(0, 115, 255),
-1,
)
cv2.putText(
img1, name1, (x1, y1), cv2.FONT_HERSHEY_DUPLEX, fontsize, (255, 255, 255), text_thickness
)
(tw, th), _ = cv2.getTextSize(
text=name2, fontFace=cv2.FONT_HERSHEY_DUPLEX, fontScale=fontsize, thickness=text_thickness
)
x1 = img2.shape[1] // 3
y1 = th
offset = th // 5
cv2.rectangle(
img2,
(x1 - offset * 2, y1 + offset),
(x1 + tw + offset * 2, y1 - th - offset),
(94, 23, 235),
-1,
)
cv2.putText(
img2, name2, (x1, y1), cv2.FONT_HERSHEY_DUPLEX, fontsize, (255, 255, 255), text_thickness
)
combined_img = cv2.hconcat([img1, img2])
if combined_img.shape[1] > 3840:
combined_img = cv2.resize(combined_img, (3840, 2160))
return combined_img | null |
161,162 | from __future__ import annotations
import gzip
import html
import os
from dataclasses import dataclass
from functools import lru_cache
from typing import List, Union, Iterable
import cv2
import ftfy
import numpy as np
import regex as re
from PIL import Image
from onnxruntime import InferenceSession
def default_bpe():
return os.path.join(
os.path.dirname(os.path.abspath(__file__)), "data", "bpe_simple_vocab_16e6.txt.gz"
) | null |
161,163 | from __future__ import annotations
import gzip
import html
import os
from dataclasses import dataclass
from functools import lru_cache
from typing import List, Union, Iterable
import cv2
import ftfy
import numpy as np
import regex as re
from PIL import Image
from onnxruntime import InferenceSession
The provided code snippet includes necessary dependencies for implementing the `bytes_to_unicode` function. Write a Python function `def bytes_to_unicode()` to solve the following problem:
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 is a signficant percentage of your normal, say, 32K bpe vocab. To avoid that, we want lookup tables between utf-8 bytes and unicode strings. And avoids mapping to whitespace/control characters the bpe code barfs on.
Here is the function:
def bytes_to_unicode():
"""
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 is a signficant percentage of your normal, say, 32K bpe vocab.
To avoid that, we want lookup tables between utf-8 bytes and unicode strings.
And avoids mapping to whitespace/control characters the bpe code barfs on.
"""
bs = (
list(range(ord("!"), ord("~") + 1))
+ list(range(ord("¡"), ord("¬") + 1))
+ list(range(ord("®"), ord("ÿ") + 1))
)
cs = bs[:]
n = 0
for b in range(2**8):
if b not in bs:
bs.append(b)
cs.append(2**8 + n)
n += 1
cs = [chr(n) for n in cs]
return dict(zip(bs, cs)) | 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 is a signficant percentage of your normal, say, 32K bpe vocab. To avoid that, we want lookup tables between utf-8 bytes and unicode strings. And avoids mapping to whitespace/control characters the bpe code barfs on. |
161,164 | from __future__ import annotations
import gzip
import html
import os
from dataclasses import dataclass
from functools import lru_cache
from typing import List, Union, Iterable
import cv2
import ftfy
import numpy as np
import regex as re
from PIL import Image
from onnxruntime import InferenceSession
The provided code snippet includes necessary dependencies for implementing the `get_pairs` function. Write a Python function `def get_pairs(word)` to solve the following problem:
Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings).
Here is the function:
def get_pairs(word):
"""Return set of symbol pairs in a word.
Word is represented as tuple of symbols (symbols being variable-length strings).
"""
pairs = set()
prev_char = word[0]
for char in word[1:]:
pairs.add((prev_char, char))
prev_char = char
return pairs | Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings). |
161,165 | from __future__ import annotations
import gzip
import html
import os
from dataclasses import dataclass
from functools import lru_cache
from typing import List, Union, Iterable
import cv2
import ftfy
import numpy as np
import regex as re
from PIL import Image
from onnxruntime import InferenceSession
def basic_clean(text):
text = ftfy.fix_text(text)
text = html.unescape(html.unescape(text))
return text.strip() | null |
161,166 | from __future__ import annotations
import gzip
import html
import os
from dataclasses import dataclass
from functools import lru_cache
from typing import List, Union, Iterable
import cv2
import ftfy
import numpy as np
import regex as re
from PIL import Image
from onnxruntime import InferenceSession
def whitespace_clean(text):
text = re.sub(r"\s+", " ", text)
text = text.strip()
return text | null |
161,167 | from __future__ import annotations
import gc
import json
import os
import shutil
import time
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from json import JSONDecodeError
from pathlib import Path
from typing import Dict, List, Tuple
from urllib.parse import urlparse
import cv2
import httpx
import onnxruntime
import yaml
from cv2.dnn import Net
from loguru import logger
from onnxruntime import InferenceSession
from tenacity import *
from tqdm import tqdm
from hcaptcha_challenger.utils import from_dict_to_model
def request_resource(url: str, save_path: Path):
cdn_prefix = os.environ.get("MODELHUB_CDN_PREFIX", "")
if cdn_prefix and cdn_prefix.startswith("https://"):
parser = urlparse(cdn_prefix)
scheme, netloc = parser.scheme, parser.netloc
url = f"{scheme}://{netloc}/{url}"
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0"
}
with open(save_path, "wb") as download_file:
with httpx.Client(headers=headers, follow_redirects=True, http2=True) as client:
with client.stream("GET", url) as response:
total = int(response.headers["Content-Length"])
with tqdm(
total=total,
unit_scale=True,
unit_divisor=1024,
unit="B",
desc=f"Installing {save_path.parent.name}/{save_path.name}",
) as progress:
num_bytes_downloaded = response.num_bytes_downloaded
for chunk in response.iter_bytes():
download_file.write(chunk)
progress.update(response.num_bytes_downloaded - num_bytes_downloaded)
num_bytes_downloaded = response.num_bytes_downloaded | null |
161,168 | from __future__ import annotations
import math
import time
from dataclasses import dataclass, field
from pathlib import Path
from typing import List
from typing import Literal
import cv2
import numpy as np
from onnxruntime import InferenceSession
from .utils import nms, xywh2xyxy, draw_detections, sigmoid, multiclass_nms
def is_matched_ash_of_war(ash: str, class_name: str):
if "head of " in ash:
if "head" not in class_name:
return False
keyword = class_name.replace("-head", "").strip()
if keyword not in ash:
return False
return True
# catch-all rules
if class_name not in ash:
return False
return True | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.