Open pvti opened 4 years ago
Hi, @pvtien96 You can open a pull request and I will merge it to our code. Thank you for your contribution to this repo!
I have three questions:
@394781865 I'm not sure whether I truly understood your questions.
I have three questions:
- why training the model without use yolo3 to detect? 2 . I try to using MARS-v160809 dataset to tain a model, it's ok in traing, but get a very low accuracy in test.what's the problem?
- And how to train the model with using MARS-v160809 dataset?
Hi , i encountered the same problem, i am training the MARS datasets, and get very low accuracy as well as the training speed is very very very slow, i trained the datasets for 3 days ,just run 9 epoches . Did you figure out the problem ?
Hi @pvtien96
I'm curious that you refactored the code above but did not mention/change that the current torchvision.datasets.ImageFolder(train_dir, transform=transform_train)
simply does not work with the Market1501 dataset structure.
I created this custom Dataset
loader:
import natsort
import os
from PIL import Image
from torch.utils.data import Dataset
class Market1501DataSet(Dataset):
def __init__(self, main_dir, transform):
self.main_dir = main_dir
self.transform = transform
all_imgs = os.listdir(main_dir)
self.total_imgs = natsort.natsorted(all_imgs)
# __getitem__ must return an index of list "classes"
image_names = [x[0:4] for x in self.total_imgs]
self.classes_dict = dict.fromkeys(image_names)
for i, key in enumerate(self.classes_dict):
self.classes_dict[key] = i
self.classes = list(self.classes_dict)
def __len__(self):
return len(self.total_imgs)
## Returns: Tuple (image, target) where target is the index of the target category.
def __getitem__(self, idx):
img_loc = os.path.join(self.main_dir, self.total_imgs[idx])
image = Image.open(img_loc).convert("RGB")
tensor_image = self.transform(image)
label = self.total_imgs[idx][0:4]
index_of_label = self.classes_dict[label]
return (tensor_image, index_of_label)
and then in train.py
# train_dir = os.path.join(root,"bounding_box_train") # EDITed this change out after rearranging the Market1501 dataset structure
# test_dir = os.path.join(root,"bounding_box_test") # EDITed this change out after rearranging the Market1501 dataset structure
train_dir = os.path.join(root,"train")
test_dir = os.path.join(root,"test")
market_train = Market1501DataSet(train_dir, transform=transform_train)
market_test = Market1501DataSet(test_dir, transform=transform_test)
trainloader = torch.utils.data.DataLoader(
market_train,
batch_size=64,shuffle=True
)
testloader = torch.utils.data.DataLoader(
market_test,
batch_size=64,shuffle=True
)
What did you do?
(I'd like to discuss this with you and the author because I'm not sure if this is strictly correct, since we'll be training on 751 classes, but then testing in 750 completely different classes but with the same index ids.. (so the network should be confused))
EDIT: K rearranged the Market1501 dataset so that two new folders train
and test
contain half the images of each person, so that we train with 1500 classes, and test on the same 1500 classes
Hi @ZQPei , currently I'm working on a tracking-by-detection project very related to deepsort. I've tried a lot to make your repo works for me. Do you mind rearrange your code in file train.py? Here, I rewrite your train.py code, I push all the related block in functions like the following:
And I think we should puts the training log to a log-directory in order to show the training processing by tensorboard? Any suggestion? Thanks for reading!