Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Torchvision Transformers #56

Open
BRUNDA-MS opened this issue Sep 8, 2023 · 2 comments
Open

Torchvision Transformers #56

BRUNDA-MS opened this issue Sep 8, 2023 · 2 comments

Comments

@BRUNDA-MS
Copy link

Can I download the images after applying the transformation on custom data? If yes, how do i download with the local installation?

@divideconcept
Copy link
Contributor

Sort of. Those transformations happen on the fly, but if you want to keep a file version on disk of the tensors after transformation, you can either modify datasetload.py to add a function saving the tensor within this block:

    if msg_type == 'RequestTrainingSamples' or msg_type == 'RequestValidationSamples':
        if meta_dataset is not None:
            meta_dataset.train(msg_type == 'RequestTrainingSamples')
            samples_id = tc.decode_ints(msg_data)
            for id in samples_id:
                tc.send_msg(app_socket, 'TensorData', tc.encode_torch_tensors(meta_dataset[id]))

That's the block that sends all the training and validation samples to the model training script.
Or you can modify modeltrain.py and retrieve all the transformed tensors here:

    def add_sample(self, data=None):
        if data:
            if self.cache:
                self.cache.write(len(data).to_bytes(4, 'little'))
                self.cache.write(data)
            self.index.append(tc.decode_torch_tensors(data))
        else:
            if self.cache:
                self.cache.close()
                try:
                    os.rename(self.filename+'.tmp', self.filename)
                except:
                    pass

If you don't want to hack those python file, checking "Cache" next to the "Train" button in Model tabs. This will create a big file containing all transformed tensors on the training server (locally or remotelly depending on where your training happens). Those tensors are packed continuously in this file using fastnumpyio.pack/fastnumpyio.unpack:

endianness: 1 byte, value can be '<', '>', '|'
type: 1 byte, value can be 'b', 'i', 'u', 'f', 'c'
type size: 1 byte, value can be 1, 2, 4, 8, 16
number of dimensions: 1 byte, value can be 0-255
shape: 4 bytes per dimension
raw samples data

@BRUNDA-MS
Copy link
Author

Hi @divideconcept,

I tried the "Cache" approach; but with or without the cache option being checked, the training stops at 70% on its own. I could neither see any results on the Dashboard nor any big file in my local system.

Could you please help me resolve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants