Skip to content

Segment_WSI migration from TF1 to TF2#13

Open
ishaq-ansari wants to merge 2 commits intomainfrom
issue-12
Open

Segment_WSI migration from TF1 to TF2#13
ishaq-ansari wants to merge 2 commits intomainfrom
issue-12

Conversation

@ishaq-ansari
Copy link

Summary

This PR addresses issue #12 by adding a TensorFlow 2 compatibility layer to all files associated with WSI segmentation, enabling inference to run in a TF2 environment while maintaining compatibility with existing TF1.15 legacy code.

Implementation Details

  • Added TF2-compatible replacements for deprecated TF1 APIs used in WSI segmentation.
  • Preserved variable naming and checkpoint loading behavior between TF1 and TF2.

nas_network.py

  • Introduced a lightweight configuration class to:
    • Store and access hparams in a TF2-compatible way
    • Support dynamic updates to configuration values when required
  • Replaces deprecated TF1 hparams APIs while preserving existing behavior.

conv2d_ws.py

Implemented TF2 equivalents for deprecated internal TF1 layer utilities:

How to Run / Test

  1. Clone the repository

  2. Map TF1 checkpoint to TF2 format

    • Update the TF1 checkpoint path in map_checkpoint_to_deeplabv3plus.py (line 318), for example:
      /home/iansari/model_test/model.ckpt-5000
      
    • Run:
      python map_checkpoint_to_deeplabv3plus.py
    • This generates TF2-compatible checkpoints in the same directory with prefix:
      model_mapped_tf2.ckpt
      
  3. Run segmentation

    • Update paths in run_glom_detection_gpu.sh (lines 21–31)
    • Set checkpoint path using the mapped TF2 checkpoint prefix:
      /home/iansari/model/model_mapped_tf2.ckpt
      
    • Submit the job:
      sbatch run_glom_detection_gpu.sh
  4. Output

    • Segmentation results are saved as .json files in the root-level output/ directory.

Notes

  • This PR focuses on inference compatibility and does not introduce training changes.
  • Output behavior is consistent with TF1 inference when using the same checkpoint.

@ishaq-ansari ishaq-ansari self-assigned this Dec 30, 2025
@ishaq-ansari ishaq-ansari added the migration Migrating the codebase from TF1 to TF2 label Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

migration Migrating the codebase from TF1 to TF2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant