shivahanifi / SCDD-image-segmentation-keras

Implementation of Segnet, FCN, UNet , PSPNet and other models in Keras.
https://divamgupta.com/image-segmentation/2019/06/06/deep-learning-semantic-segmentation-keras.html
MIT License
0 stars 0 forks source link

visualize the models using Netron #15

Closed shivahanifi closed 2 weeks ago

shivahanifi commented 2 weeks ago

Model saved in a correct format should be easily visualized by clicking on it in wandb using Netron

https://community.wandb.ai/t/how-to-visualize-model-graph-in-weights-and-biases/2547

Netron supports the following file formats:

  1. ONNX (Open Neural Network Exchange) - .onnx
  2. TensorFlow - .pb (Protocol Buffers), .tf (TensorFlow SavedModel)
  3. Keras - .h5, .keras
  4. PyTorch - .pt, .pth
  5. CoreML - .mlmodel
  6. Caffe - .prototxt (model architecture) and .caffemodel (weights)
  7. MXNet - .json (model structure) and .params (weights)
  8. TFLite - .tflite (TensorFlow Lite models)
  9. DNN (OpenVINO) - .bin (weights) and .xml (model architecture)
  10. PaddlePaddle - .pdmodel and .pdiparams
  11. ULMFiT - .pth (from the ULMFiT library)
  12. KNN (Keras Neural Networks) - .keras

Netron also supports custom formats through extensions

shivahanifi commented 2 weeks ago

The checkpoints saved in the from of .0.index and .0.data-00000-of-00001 store the model's weights but not the full architecture or configuration. This is a common output format when using TensorFlow's checkpointing system. These files are saved in this way because:

shivahanifi commented 2 weeks ago

Solved

Using the following code I saved the model.h5 format and was able to visualize the architecture in the wandb. wandb report

artifact = wandb.Artifact(name = wandb.run.name, type = "model")
ckp_files = os.listdir(checkpoint_path)
for ckp in ckp_files:
    full_path = os.path.join(checkpoint_path, ckp)
    artifact.add_file(local_path=full_path, name=ckp)
    # Save the model as .h5 file
    h5_model_path = os.path.join(checkpoint_path, f"{ckp}_model.h5")
    model.save(h5_model_path)
artifact.save()
wandb.save(os.path.join(checkpoint_path, "*"))

Visualization

Issue: It saves several models with inefficient naming convention.

shivahanifi commented 2 weeks ago

Closing the issue. Follow in issue #17