Morrizzzzz
/
Counting-from-Sky-A-Large-scale-Dataset-for-Remote-Sensing-Object-Counting-and-A-Benchmark-Method
Public
forked from gaoguangshuai/Counting-from-Sky-A-Large-scale-Dataset-for-Remote-Sensing-Object-Counting-and-A-Benchmark-Method
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataset.py
46 lines (34 loc) · 1.22 KB
/
dataset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import random
import torch
import numpy as np
from torch.utils.data import Dataset
from PIL import Image
from image import *
import torchvision.transforms.functional as F
class listDataset(Dataset):
def __init__(self, root, shape=None, shuffle=True, transform=None, train=False, seen=0, batch_size=1, num_workers=4):
if train:
root = root *4
random.shuffle(root)
self.nSamples = len(root)
self.lines = root
self.transform = transform
self.train = train
self.shape = shape
self.seen = seen
self.batch_size = batch_size
self.num_workers = num_workers
def __len__(self):
return self.nSamples
def __getitem__(self, index):
assert index <= len(self), 'index range error'
img_path = self.lines[index]
img,target = load_data(img_path,self.train)
#img = 255.0 * F.to_tensor(img)
#img[0,:,:]=img[0,:,:]-92.8207477031
#img[1,:,:]=img[1,:,:]-95.2757037428
#img[2,:,:]=img[2,:,:]-104.877445883
if self.transform is not None:
img = self.transform(img)
return img,target