load multi-modal data with pytorchModel summary in pytorchmulti-variable linear regression with pytorchHow do I load up an image and convert it to a proper tensor for PyTorch?MemoryError when attempting to create a docker image with Torch/PyTorchMulti label classification in pytorchUpdating pre-trained Deep Learning model with respect to new data pointsPyTorch - loading images without sub foldersLoad data from CSV using DataLoaderPytorch torchvision MNIST downloadinteger argument expected, got float Pytorch : transform
What is the difference between "Plural" and "Mehrzahl"?
How to slow yourself down (for playing nice with others)
Can I do brevets (long distance rides) on my hybrid bike? If yes, how to start?
Why does a C.D.F need to be right-continuous?
Is a diamond sword feasible?
"Fīliolō me auctum scito, salva Terentia"; what is "me" role in this phrase?
Does the sorcerer's Subtle Spell Metamagic option allow you to ignore both Verbal and Somatic components?
How do I tell my supervisor that he is choosing poor replacements for me while I am on maternity leave?
51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily?
Why do Thanos's punches not kill Captain America or at least cause some mortal injuries?
Noob at soldering, can anyone explain why my circuit won't work?
Would an 8% reduction in drag outweigh the weight addition from this custom CFD-tested winglet?
Guns in space with bullets that return?
How to pronounce "r" after a "g"?
What is the significance of 4200 BCE in context of farming replacing foraging in Europe?
Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019
Delta TSA-Precheck status removed
Why was this sacrifice sufficient?
Pre-1993 comic in which Wolverine's claws were turned to rubber?
How can a Lich look like a human without magic?
Can the sorting of a list be verified without comparing neighbors?
How are one-time password generators like Google Authenticator different from having two passwords?
Should these notes be played as a chord or one after another?
Two researchers want to work on the same extension to my paper. Who to help?
load multi-modal data with pytorch
Model summary in pytorchmulti-variable linear regression with pytorchHow do I load up an image and convert it to a proper tensor for PyTorch?MemoryError when attempting to create a docker image with Torch/PyTorchMulti label classification in pytorchUpdating pre-trained Deep Learning model with respect to new data pointsPyTorch - loading images without sub foldersLoad data from CSV using DataLoaderPytorch torchvision MNIST downloadinteger argument expected, got float Pytorch : transform
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to load multi-modal data (e.g. text and image) in pytorch for image classification. I do not know how to load them simultaneously, like the following code.
def __init__(self, img_path, txt_path, transform=None, loader=default_loader):
def __len__(self):
return len(self.img_name)
def __getitem__(self, item):
Can anyone help me?
pytorch
add a comment |
I'm trying to load multi-modal data (e.g. text and image) in pytorch for image classification. I do not know how to load them simultaneously, like the following code.
def __init__(self, img_path, txt_path, transform=None, loader=default_loader):
def __len__(self):
return len(self.img_name)
def __getitem__(self, item):
Can anyone help me?
pytorch
add a comment |
I'm trying to load multi-modal data (e.g. text and image) in pytorch for image classification. I do not know how to load them simultaneously, like the following code.
def __init__(self, img_path, txt_path, transform=None, loader=default_loader):
def __len__(self):
return len(self.img_name)
def __getitem__(self, item):
Can anyone help me?
pytorch
I'm trying to load multi-modal data (e.g. text and image) in pytorch for image classification. I do not know how to load them simultaneously, like the following code.
def __init__(self, img_path, txt_path, transform=None, loader=default_loader):
def __len__(self):
return len(self.img_name)
def __getitem__(self, item):
Can anyone help me?
pytorch
pytorch
asked Mar 22 at 15:11
xiaodan zhangxiaodan zhang
61
61
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
In __getitem__
, you can use a dictionary or a tuple to represent one sample of your data. Later during training when you create a dataloader using the dataset, pytorch will automatically create batches of dictonary or tuples.
If you want to create samples in a much more different way, check out collate_fn in pytorch.
add a comment |
The method getitem(self, item) would help you do this.
For example:
def __getitem__(self, item): # item can be thought as an index
text = textList[item] # textList would be a list containing the text you want to input into the model for element 'item'
img = imgList[image] # imgList would be a list containing the images you want to input into the model for element 'item'
input = [text, img]
y = labels[item] # labels would be a list containing the label for the input of the text and img. This is your target.
return input, y
Thanks for your reply. I will try it.
– xiaodan zhang
Mar 24 at 8:48
if it is fixed please mark my answer as correct
– asong24
Mar 24 at 14:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302653%2fload-multi-modal-data-with-pytorch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In __getitem__
, you can use a dictionary or a tuple to represent one sample of your data. Later during training when you create a dataloader using the dataset, pytorch will automatically create batches of dictonary or tuples.
If you want to create samples in a much more different way, check out collate_fn in pytorch.
add a comment |
In __getitem__
, you can use a dictionary or a tuple to represent one sample of your data. Later during training when you create a dataloader using the dataset, pytorch will automatically create batches of dictonary or tuples.
If you want to create samples in a much more different way, check out collate_fn in pytorch.
add a comment |
In __getitem__
, you can use a dictionary or a tuple to represent one sample of your data. Later during training when you create a dataloader using the dataset, pytorch will automatically create batches of dictonary or tuples.
If you want to create samples in a much more different way, check out collate_fn in pytorch.
In __getitem__
, you can use a dictionary or a tuple to represent one sample of your data. Later during training when you create a dataloader using the dataset, pytorch will automatically create batches of dictonary or tuples.
If you want to create samples in a much more different way, check out collate_fn in pytorch.
answered Mar 23 at 10:42
shivam2298shivam2298
184
184
add a comment |
add a comment |
The method getitem(self, item) would help you do this.
For example:
def __getitem__(self, item): # item can be thought as an index
text = textList[item] # textList would be a list containing the text you want to input into the model for element 'item'
img = imgList[image] # imgList would be a list containing the images you want to input into the model for element 'item'
input = [text, img]
y = labels[item] # labels would be a list containing the label for the input of the text and img. This is your target.
return input, y
Thanks for your reply. I will try it.
– xiaodan zhang
Mar 24 at 8:48
if it is fixed please mark my answer as correct
– asong24
Mar 24 at 14:31
add a comment |
The method getitem(self, item) would help you do this.
For example:
def __getitem__(self, item): # item can be thought as an index
text = textList[item] # textList would be a list containing the text you want to input into the model for element 'item'
img = imgList[image] # imgList would be a list containing the images you want to input into the model for element 'item'
input = [text, img]
y = labels[item] # labels would be a list containing the label for the input of the text and img. This is your target.
return input, y
Thanks for your reply. I will try it.
– xiaodan zhang
Mar 24 at 8:48
if it is fixed please mark my answer as correct
– asong24
Mar 24 at 14:31
add a comment |
The method getitem(self, item) would help you do this.
For example:
def __getitem__(self, item): # item can be thought as an index
text = textList[item] # textList would be a list containing the text you want to input into the model for element 'item'
img = imgList[image] # imgList would be a list containing the images you want to input into the model for element 'item'
input = [text, img]
y = labels[item] # labels would be a list containing the label for the input of the text and img. This is your target.
return input, y
The method getitem(self, item) would help you do this.
For example:
def __getitem__(self, item): # item can be thought as an index
text = textList[item] # textList would be a list containing the text you want to input into the model for element 'item'
img = imgList[image] # imgList would be a list containing the images you want to input into the model for element 'item'
input = [text, img]
y = labels[item] # labels would be a list containing the label for the input of the text and img. This is your target.
return input, y
answered Mar 24 at 4:10
asong24asong24
234
234
Thanks for your reply. I will try it.
– xiaodan zhang
Mar 24 at 8:48
if it is fixed please mark my answer as correct
– asong24
Mar 24 at 14:31
add a comment |
Thanks for your reply. I will try it.
– xiaodan zhang
Mar 24 at 8:48
if it is fixed please mark my answer as correct
– asong24
Mar 24 at 14:31
Thanks for your reply. I will try it.
– xiaodan zhang
Mar 24 at 8:48
Thanks for your reply. I will try it.
– xiaodan zhang
Mar 24 at 8:48
if it is fixed please mark my answer as correct
– asong24
Mar 24 at 14:31
if it is fixed please mark my answer as correct
– asong24
Mar 24 at 14:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302653%2fload-multi-modal-data-with-pytorch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown