Skip to content

Pytorch support - #276

Open
cpozogonzalez wants to merge 179 commits into
mainfrom
pytorch_support
Open

cpozogonzalez wants to merge 179 commits into
mainfrom
pytorch_support

Conversation

@cpozogonzalez

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 38 changed files in this pull request and generated 8 comments.

Suppressed comments (4)

ctlearn/tools/train_model.py:306

  • setup_framework is declared without a self parameter, but is called as self.setup_framework() in setup(). This will raise TypeError: setup_framework() takes 0 positional arguments but 1 was given at runtime.
    ctlearn/tools/train_model.py:107
  • ctapipe.core.traits.Path expects the keyword argument exists, but the code uses exits. This likely raises a TypeError during import/trait initialization and prevents the tool from running.

This issue also appears on line 303 of the same file.
pyproject.toml:95

  • The console-script key ctlearn-predict-LST1= includes an extra = in the name (ctlearn-predict-LST1=). This will create an incorrectly named entry point (or fail validation), so the expected ctlearn-predict-LST1 command won't be installed.
    ctlearn/tools/predict_LST1.py:1052
  • The __name__ guard uses "main" instead of "__main__", so main() will never run when executing this file directly.
if __name__ == "main":
    main()

Comment thread pyproject.toml
Comment thread Dockerfile Outdated
Comment on lines 94 to +98
--LST1PredictionTool.channels=cleaned_relative_peak_time \\
--LST1PredictionTool.image_mapper_type=BilinearMapper \\
--type_model="/path/to/your/type/ctlearn_model.cpk" \\
--energy_model="/path/to/your/energy/ctlearn_model.cpk" \\
--cameradirection_model="/path/to/your/direction/ctlearn_model.cpk" \\
--type_model="/path/to/your/type/ctlearn_model(.keras/.pth)"" \\
--energy_model="/path/to/your/energy/ctlearn_model(.keras/.pth)"" \\
--cameradirection_model="/path/to/your/direction/ctlearn_model(.keras/.pth)"" \\
Comment thread ctlearn/tools/predict_model.py Outdated
Comment on lines +2459 to +2463
@@ -2366,4 +2460,4 @@ def stereo_tool():
mono_tool()

if __name__ == "stereo_tool":
stereo_tool()
stereo_tool() No newline at end of file
Comment thread ctlearn/tools/keras/train_model.py Outdated
Comment thread ctlearn/tools/pytorch/train_model.py Outdated
Comment thread ctlearn/tools/predict_model.py
Comment thread ctlearn/tools/utils.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment on lines +941 to +942
if self.framework_type == FrameworkType.PYTORCH:
from scipy.special import softmax

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scipy is a core dependency and should be move to the top of the file

Comment on lines -2462 to +2474
if __name__ == "mono_tool":
mono_tool()

if __name__ == "stereo_tool":
stereo_tool() No newline at end of file
if __name__ == "__main__":
import sys
if "--stereo" in sys.argv:
sys.argv.remove("--stereo")
stereo_tool()
else:
mono_tool() No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not introduce breaking changes if not necessary.

Comment thread ctlearn/core/pytorch/model.py Outdated
Comment on lines +63 to +65
if original_task == "type":
outputs[original_task] = F.softmax(out, dim=-1)
else:
outputs[original_task] = out
# Return raw logits for all tasks, including 'type',
# because CrossEntropyLoss expects logits during training.
outputs[original_task] = out

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cpozogonzalez! Is this fixing the gammaness distribution plot?

Comment on lines +423 to +425
# Set default HDF5Merger options (disable image copying by default for standard DL2 output)
self.config.setdefault("HDF5Merger", {}).setdefault("dl1_images", False)
self.config.setdefault("HDF5Merger", {}).setdefault("true_images", False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not overwrite silently the defaults. At least a log should be written here. And I would prefer to write it in the the docstring of the tool, i.e. providing minimal instructions to the users.

This branch was successfully deployed

1 active deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants