The croissant metadata on HF are generated automatically for datasets in supported formats like Parquet or ImageFolder (folder of images and a metadata file ). If you convert your dataset to Parquet, or if you structure your dataset as a ImageFolder, the croissant metadata will be available.
There is no way to automatically get a croissant metadata file for a dataset based on a python script.