simclr icon indicating copy to clipboard operation
simclr copied to clipboard

simclr on medical dataset gives error

Open fatmacelebi opened this issue 3 years ago • 7 comments

I just changed the line 65 in simclr/tf2/data.py ( dataset = builder.as_dataset() ) as dataset= tf.data.Dataset.from_tensor_slices(train_images) but I was not able to run the codes. Is there any document that you can share with me how to apply simclr on custom dataset which different than tensorflow dataset or can you say where I am doing wrong? In my codes; train_images = list(paths.list_images(images_path)) images_path=folder path which contains unlabaled pretraining images With this way I am getting error in mp_fn function with error "tf__map_fn() missing 1 required positional argument: 'label'"

fatmacelebi avatar Jan 24 '22 19:01 fatmacelebi

Hi, you can try to add labels from the dataset, that might fix the issue. You can refer to this from - https://www.tensorflow.org/api_docs/python/tf/data/Dataset

# Both the features and the labels tensors can be converted to a Dataset object separately and combined after. features_dataset = Dataset.from_tensor_slices(features) labels_dataset = Dataset.from_tensor_slices(labels) dataset = Dataset.zip((features_dataset, labels_dataset))

ambekarsameer96 avatar Jan 27 '22 09:01 ambekarsameer96

but I don't have any label, because I want to train unlabeled images as pretraining.

fatmacelebi avatar Jan 27 '22 09:01 fatmacelebi

creating a dummy label may suffice. label won't be used anyway for the pretraining of backbone network.

chentingpc avatar Jan 28 '22 03:01 chentingpc

Finally, I was able to run the code, but after completing the iteartions I couldn't get any hub file which has saved model like in your case, and code just cerated files like ;

  • checkpoint
  • model.ckpt-8720.data-00000-of-00001
  • model.ckpt-8720.index
  • model.ckpt-8720.meta

and I don't know from above files which can be used as model for fine-tuning? Am I doing wrong while running and because of that the code doesn't create any hub file with saved model? Can you help please?

fatmacelebi avatar Feb 09 '22 16:02 fatmacelebi

These are checkpoints and you could specify FLAGS.checkpoint=/path/to/directory to load the checkpoint for fine-tuning.

On Wed, Feb 9, 2022 at 11:16 AM fclb @.***> wrote:

Finally, I was able to run the code, but after completing the iteartions I couldn't get any hub file which has saved model like in your case, and code just cerated files like ;

  • checkpoint
  • model.ckpt-8720.data-00000-of-00001
  • model.ckpt-8720.index
  • model.ckpt-8720.meta

and I don't know from above files which can be used as model for fine-tuning? Am I doing wrong while running and because of that the code doesn't create any hub file with saved model? Can you help please?

— Reply to this email directly, view it on GitHub https://github.com/google-research/simclr/issues/187#issuecomment-1033936904, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKERUIU6MKY4Q5GV5YIHWDU2KHPPANCNFSM5MWISKZQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

chentingpc avatar Feb 09 '22 17:02 chentingpc

I need Resnet model pre-trained weights to use in another approach as initial weights and I need an .h5 file to load weights. Is is possible to get such a file?

fatmacelebi avatar Feb 09 '22 18:02 fatmacelebi

apply simclr on custom dataset

Now I want apply simclr on my custom dataset.Could you please tell me how to prepare datas format?Thank you very much!

wmrenr avatar Jan 04 '23 14:01 wmrenr