feat: add version 2 - complex field support#8
Open
electricalgorithm wants to merge 25 commits intomainfrom
Open
feat: add version 2 - complex field support#8electricalgorithm wants to merge 25 commits intomainfrom
electricalgorithm wants to merge 25 commits intomainfrom
Conversation
Removed the phrase 'research-grade' from the project description and adjusted the wording for clarity.
| Defaults to 224. | ||
| """ | ||
| self.files = glob.glob(os.path.join(data_dir, "*.npz")) | ||
| self.data_dir = Path(data_dir) |
Owner
Author
There was a problem hiding this comment.
As far as I understand, it's not used anywhere else. No need to preserve the data.
src/holopaswin/dataset.py
Outdated
Comment on lines
44
to
47
| # Pixels per image (512x512) | ||
| # We hardcode this because the dataset structure (1 pixel per row) implies it. | ||
| # If it changes, this breaks, but we verified it's 262144 rows per image. | ||
| self.rows_per_sample = 512 * 512 |
Owner
Author
There was a problem hiding this comment.
I'd be better to make it configurable.
src/holopaswin/dataset.py
Outdated
| continue | ||
|
|
||
| # Use pyarrow to get metadata | ||
| import pyarrow.parquet as pq |
Owner
Author
There was a problem hiding this comment.
Only allow imports on module-level.
src/holopaswin/dataset.py
Outdated
| # Convert to numpy and reshape | ||
| # Note: .to_numpy() on a ChunkedArray (from slice) is efficient | ||
| h_flat = h_slice['intensity'].to_numpy() # (262144,) | ||
| h_np = h_flat.reshape(512, 512).astype(np.float32) |
Owner
Author
There was a problem hiding this comment.
No magic numbers.
src/holopaswin/swin_transformer.py
Outdated
Comment on lines
38
to
45
| # Pretrained = True (User Request). | ||
| # PROBLEM: Pretrained weights are 3 channels (RGB). We have 2 channels (Real/Imag). | ||
| # TIMM automatically adapts conv weights if in_chans != 3? | ||
| # Yes, timm usually re-initializes or copies weights. | ||
| # But to be safe/optimal for "Physics Aware" where Real/Imag matters: | ||
| # We relying on timm's default adaptation (sum/mean) is better than random init. | ||
| # Timm's `timm.models.load_checkpoint` helper usually handles this but `create_model` does too. | ||
| # `in_chans=2` will trigger timm to adapt the patch embedding layer. |
Owner
Author
There was a problem hiding this comment.
This part is a huge miss. It's like we're not sure. It had to do experimentation before assumption,
| nn.GELU(), | ||
| nn.Conv2d(encoder_channels[-4] // 2, out_chans, kernel_size=3, padding=1), | ||
| nn.Sigmoid(), # Assuming object is amplitude 0-1 | ||
| # REMOVED Sigmoid: Real/Imag parts are not bounded [0,1]. |
Owner
Author
There was a problem hiding this comment.
No need to emphasise it.
src/train.py
Outdated
| BATCH_SIZE = 6 | ||
| LR = 1e-4 | ||
| NUM_EPOCHS = 5 | ||
| NUM_EPOCHS = 1 # Reduced for demo/validation purposes |
Owner
Author
There was a problem hiding this comment.
No need to write it down.
1f1d445 to
0984c62
Compare
0984c62 to
77918b8
Compare
We see from the experiment 3 that the model cannot predict the objects. Since the task is mainly removing the noise from reconstructed but dirty complex domain, let's start by copying the dirty one to output but remove the noise.
Within this patch, we realize that exp3 is way worse then expected. That's why we wanted to add two new loss components that compares the distance between phases and magnitudes.
Signed-off-by: Gyokhan Kochmarla <gokhan.kocmarli@gmail.com>
Signed-off-by: Gyokhan Kochmarla <gokhan.kocmarli@gmail.com>
Signed-off-by: Gyokhan Kochmarla <gokhan.kocmarli@gmail.com>
aa65403 to
c24276e
Compare
…phase reconstruction Experiment 9 Results: - Dataset: 25k native 224x224 samples - Noise Configs: 8 variations (Speckle/Shot/Read/Dark) - Amp SSIM: 0.9715 - Phase SSIM: 0.9713 - Phase PSNR: 44.00 dB Changes: - Updated test/check_stats to point to Exp 9 - Added Exp 9 README and results
Signed-off-by: Gyokhan Kochmarla <gokhan.kocmarli@gmail.com>
Signed-off-by: Gyokhan Kochmarla <gokhan.kocmarli@gmail.com>
Signed-off-by: Gyokhan Kochmarla <gokhan.kocmarli@gmail.com>
Signed-off-by: Gyokhan Kochmarla <gokhan.kocmarli@gmail.com>
Signed-off-by: Gyokhan Kochmarla <gokhan.kocmarli@gmail.com>
Signed-off-by: Gyokhan Kochmarla <gokhan.kocmarli@gmail.com>
Signed-off-by: Gyokhan Kochmarla <gokhan.kocmarli@gmail.com>
Within this scripts and results, we can enhance our model to perform better. The ablation study mainly focuses on architecture decisions, loss function design and checks z-mismatch for generalization. The ablation study will be used in the article. Signed-off-by: Gyokhan Kochmarla <gokhan.kocmarli@gmail.com>
Signed-off-by: Gyokhan Kochmarla <gokhan.kocmarli@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.