I used a pre-made model with Keras for training a data-set about URLs. results are saved in a .h5 format and I am wondering if I could convert that saved .h5 file to JSON so that I could see the results and apply the JSON file in my system that separates bad URLs from good URLs. I also want to avoid re-training again if possible.
            Asked
            
        
        
            Active
            
        
            Viewed 1.0k times
        
    9
            
            
        - 
                    You can refer to the answers at here: https://stackoverflow.com/questions/28170623/how-to-read-hdf5-files-in-python – Han Wang Mar 21 '19 at 23:38
- 
                    I needed it to convert to json so that I could call that json file using javascript and get the data from it – Alexander Wazowski Mar 21 '19 at 23:51
- 
                    You can refer the answers here for saving as json: https://stackoverflow.com/questions/12309269/how-do-i-write-json-data-to-a-file – Manoj Mohan Mar 22 '19 at 17:42
2 Answers
3
            
            
        As mentioned in https://www.tensorflow.org/js/guide/conversion
For example, let’s say you have saved a Keras model named model.h5 to your tmp/ directory. To convert your model using the TensorFlow.js converter, you can run the following command:
tensorflowjs_converter --input_format=keras /tmp/model.h5 /tmp/tfjs_model
 
    
    
        desertnaut
        
- 57,590
- 26
- 140
- 166
 
    
    
        Arun P
        
- 110
- 1
- 8
0
            
            
        At first
!sudo pip3 install tensorflowjs
Then
!sudo tensorflowjs_converter
Just replace model.h5 with your trained weight
!tensorflowjs_converter --input_format=keras '/content/drive/MyDrive/model.h5' "/content/drive/MyDrive/json"
you are good to go your file will me converted!
 
    
    
        Mahyar Mottaghi Zadeh
        
- 1,178
- 6
- 18
- 31
 
    
    
        RAJU M
        
- 11
- 1
 
    