google-research / simclr

SimCLRv2 - Big Self-Supervised Models are Strong Semi-Supervised Learners
https://arxiv.org/abs/2006.10029
Apache License 2.0
4.05k stars 624 forks source link

simclr on medical dataset gives error #187

Open fatmacelebi opened 2 years ago

fatmacelebi commented 2 years ago

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'"

ambekarsameer96 commented 2 years ago

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))

fatmacelebi commented 2 years ago

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

chentingpc commented 2 years ago

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

fatmacelebi commented 2 years ago

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 ;

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?

chentingpc commented 2 years ago

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: @.***>

fatmacelebi commented 2 years ago

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?

wmrenr commented 1 year ago

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!