Pytorch support - #276
Pytorch support#276cpozogonzalez wants to merge 179 commits into
Conversation
…ytorch legacy code
There was a problem hiding this comment.
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_frameworkis declared without aselfparameter, but is called asself.setup_framework()insetup(). This will raiseTypeError: setup_framework() takes 0 positional arguments but 1 was givenat runtime.
ctlearn/tools/train_model.py:107ctapipe.core.traits.Pathexpects the keyword argumentexists, but the code usesexits. This likely raises aTypeErrorduring 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 expectedctlearn-predict-LST1command won't be installed.
ctlearn/tools/predict_LST1.py:1052 - The
__name__guard uses"main"instead of"__main__", somain()will never run when executing this file directly.
if __name__ == "main":
main()
| --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)"" \\ |
| @@ -2366,4 +2460,4 @@ def stereo_tool(): | |||
| mono_tool() | |||
|
|
|||
| if __name__ == "stereo_tool": | |||
| stereo_tool() | |||
| stereo_tool() No newline at end of file | |||
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>
| if self.framework_type == FrameworkType.PYTORCH: | ||
| from scipy.special import softmax |
There was a problem hiding this comment.
scipy is a core dependency and should be move to the top of the file
| 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 |
There was a problem hiding this comment.
Please do not introduce breaking changes if not necessary.
| 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 |
There was a problem hiding this comment.
Thanks @cpozogonzalez! Is this fixing the gammaness distribution plot?
| # 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) |
There was a problem hiding this comment.
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.
No description provided.