Revision 2b019233d6851facadec8e9215cc805eef47932c authored by Changjian Chen on 20 May 2024, 01:52:04 UTC, committed by Changjian Chen on 20 May 2024, 01:52:04 UTC
1 parent 08a8fb3
__init__.cpython-37.pyc
B
���_s � @ s� d dl mZmZmZmZmZ d dlmZmZm Z d dl
mZmZm
Z
mZ d dlT ddlZddlZddlZddlmZ ddlmZ d d
� Zdd� ZG d
d� de�Zdd� ZG dd� d�ZdS )� )�
COCODetection�COCOAnnotationTransform�COCO_CLASSES� COCO_ROOT�
get_label_map)�COCO17Detection�COCO17_ROOT�COCO17AnnotationTransform)�VOCDetection�VOCAnnotationTransform�VOC_ROOT�VOC_CLASSES)�*� N)�Sampler)�pad_sequencec C s� g }g }g }g }xb| D ]Z}|� |d � |� t�|d �� |� t�|d �� t|�dkr|� t�|d �� qW t|�dkr�t�|d�|fS t�|d�||t�|d�fS dS )a� Custom collate fn for dealing with batches of images that have a different
number of associated object annotations (bounding boxes).
Arguments:
batch: (tuple) A tuple of tensor images and lists of annotations
Return:
A tuple containing:
1) (tensor) batch of images stacked on their 0 dim
2) (list of tensors) annotations for a given image are stacked on
0 dim
r r � � � N)�append�torch�FloatTensor�len�stack)�batch�targetsZimgs�semis�image_level_target�sample� r �,/data/changjian/WSL/CSD-SSD/data/__init__.py�detection_collate s
r! c C s� g }g }g }g }xJ| D ]B}|� |d � |� |d � |� |d � |� t�|d �� qW t|dd�t�|�t|dd�t�|d�fS )Nr r r r T)Zbatch_first)r r r r r )r Z
text_featuresZimage_featuresr Zmasksr r r r �text_collate- s
r" c @ s. e Zd Zddd�Zdd� Zdd� Zdd � Zd
S )�VOCBatchSamplerr c C s� t |t�std�|���t |t�s*|dkr8td�|���t |t�sPtd�|���|| _|| _|| _|| _|| _ t
|| | j �| _| j| j | _|| _
d S )NzMsampler should be an instance of torch.utils.data.Sampler, but got sampler={}r zFbatch_size should be a positive integeral value, but got batch_size={}z9drop_last should be a boolean value, but got drop_last={})�
isinstancer �
ValueError�format�bool�sampler�
batch_size� drop_last�super_threshold�supervise_percent�int�
supervise_num�unsupervise_num�only_supervise)�selfr( r) r* r+ r, r0 �batch_super_timesr r r �__init__<