我的目标是填充几个简单的四边形,但是一些相交的多边形之间的一些孔/补丁未填充。
代码
import cv2
import numpy as np
bboxes = [
np.array([126., 615., 141., 615., 141., 640., 126., 640., 140., 615., 157., 615., 157., 640., 140., 640., 158., 615., 174., 616., 174., 640., 158., 640.]),
np.array([193., 616., 209., 616., 209., 640., 193., 640., 209., 616., 225., 616., 225., 640., 209., 640.]),
np.array([242., 613., 258., 613., 259., 640., 242., 640., 259., 615., 276., 615., 276., 640., 260., 640., 275., 622., 291., 622., 291., 646., 275., 646., 292., 615., 308., 615., 309., …
Run Code Online (Sandbox Code Playgroud) 我有一个地图类型数据集,用于实例分割任务。该数据集非常不平衡,有些图像只有 10 个对象,而其他图像则多达 1200 个。
如何限制每批次的对象数量?
一个最小的可重现示例是:
import math
import torch
import random
import numpy as np
import pandas as pd
from torch.utils.data import Dataset
from torch.utils.data.sampler import BatchSampler
np.random.seed(0)
random.seed(0)
torch.manual_seed(0)
W = 700
H = 1000
def collate_fn(batch) -> tuple:
return tuple(zip(*batch))
class SyntheticDataset(Dataset):
def __init__(self, image_ids):
self.image_ids = torch.tensor(image_ids, dtype=torch.int64)
self.num_classes = 9
def __len__(self):
return len(self.image_ids)
def __getitem__(self, idx: int):
"""
returns single sample
"""
# print("idx: ", idx)
# deliberately left dangling
# id = …
Run Code Online (Sandbox Code Playgroud) dataset pytorch torchvision pytorch-lightning pytorch-dataloader
我想拥有:
\nconf/\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 config.yaml\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 data\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 data.yaml\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 render\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 renderer.yaml\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 storage\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 local.yaml\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 text\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 font.yaml\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 regions.yaml\n
Run Code Online (Sandbox Code Playgroud)\n其中,在 中config.yaml
,text/font.yaml
分配给font
和text/regions.yaml
to regions
,类似于:
\ndefaults:\n - font: text.font\n - regions: text.regions\n - render: renderer\n - data: data\n - storage: local\n
Run Code Online (Sandbox Code Playgroud)\n或者
\n\ndefaults:\n - font:\n - text/font\n - regions:\n - text/regions\n - render: renderer\n - data: data\n - storage: local\n
Run Code Online (Sandbox Code Playgroud)\n上面这些不行!
\n是否能够在某种程度上达到预期的结果yaml
?