Skip to content

Commit c2d6122

Browse files
committed
Add license text to each module
1 parent d249702 commit c2d6122

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+966
-166
lines changed

portpy/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Copyright 2025, the PortPy Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 with the Commons Clause restriction.
4+
# You may obtain a copy of the Apache 2 License at:
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# ----------------------------------------------------------------------
9+
# Commons Clause Restriction Notice:
10+
# PortPy is licensed under Apache 2.0 with the Commons Clause.
11+
# You may use, modify, and share the code for non-commercial
12+
# academic and research purposes only.
13+
# Commercial use — including offering PortPy as a service,
14+
# or incorporating it into a commercial product — requires
15+
# a separate commercial license.
16+
# ----------------------------------------------------------------------
17+
118
__version__ = "1.1.1"
219

320
from portpy import photon

portpy/ai/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1+
# Copyright 2025, the PortPy Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 with the Commons Clause restriction.
4+
# You may obtain a copy of the Apache 2 License at:
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# ----------------------------------------------------------------------
9+
# Commons Clause Restriction Notice:
10+
# PortPy is licensed under Apache 2.0 with the Commons Clause.
11+
# You may use, modify, and share the code for non-commercial
12+
# academic and research purposes only.
13+
# Commercial use — including offering PortPy as a service,
14+
# or incorporating it into a commercial product — requires
15+
# a separate commercial license.
16+
# ----------------------------------------------------------------------
17+
118

portpy/ai/data/__init__.py

Lines changed: 16 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,19 @@
1-
"""This package includes all the modules related to data loading and preprocessing
2-
3-
To add a custom dataset class called 'dummy', you need to add a file called 'dummy_dataset.py' and define a subclass 'DummyDataset' inherited from BaseDataset.
4-
You need to implement four functions:
5-
-- <__init__>: initialize the class, first call BaseDataset.__init__(self, opt).
6-
-- <__len__>: return the size of dataset.
7-
-- <__getitem__>: get a data point from data loader.
8-
-- <modify_commandline_options>: (optionally) add dataset-specific options and set default options.
9-
10-
Now you can use the dataset class by specifying flag '--dataset_mode dummy'.
11-
See our template dataset class 'template_dataset.py' for more details.
12-
"""
13-
import os
14-
import sys
15-
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../.."))
16-
if project_root not in sys.path:
17-
sys.path.append(project_root)
18-
19-
import importlib
20-
import torch.utils.data
21-
from portpy.ai.data.base_dataset import BaseDataset
22-
23-
24-
def find_dataset_using_name(dataset_name):
25-
"""Import the module "data/[dataset_name]_dataset.py".
26-
27-
In the file, the class called DatasetNameDataset() will
28-
be instantiated. It has to be a subclass of BaseDataset,
29-
and it is case-insensitive.
30-
"""
31-
dataset_filename = "portpy.ai.data." + dataset_name + "_dataset"
32-
datasetlib = importlib.import_module(dataset_filename)
33-
34-
dataset = None
35-
target_dataset_name = dataset_name.replace('_', '') + 'dataset'
36-
for name, cls in datasetlib.__dict__.items():
37-
if name.lower() == target_dataset_name.lower() \
38-
and issubclass(cls, BaseDataset):
39-
dataset = cls
40-
41-
if dataset is None:
42-
raise NotImplementedError("In %s.py, there should be a subclass of BaseDataset with class name that matches %s in lowercase." % (dataset_filename, target_dataset_name))
43-
44-
return dataset
45-
46-
47-
def get_option_setter(dataset_name):
48-
"""Return the static method <modify_commandline_options> of the dataset class."""
49-
dataset_class = find_dataset_using_name(dataset_name)
50-
return dataset_class.modify_commandline_options
51-
52-
53-
def create_dataset(opt):
54-
"""Create a dataset given the option.
55-
56-
This function wraps the class CustomDatasetDataLoader.
57-
This is the main interface between this package and 'train.py'/'test.py'
58-
59-
Example:
60-
from data import create_dataset
61-
dataset = create_dataset(opt)
62-
"""
63-
data_loader = CustomDatasetDataLoader(opt)
64-
dataset = data_loader.load_data()
65-
return dataset
66-
67-
68-
class CustomDatasetDataLoader():
69-
"""Wrapper class of Dataset class that performs multi-threaded data loading"""
1+
# Copyright 2025, the PortPy Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 with the Commons Clause restriction.
4+
# You may obtain a copy of the Apache 2 License at:
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# ----------------------------------------------------------------------
9+
# Commons Clause Restriction Notice:
10+
# PortPy is licensed under Apache 2.0 with the Commons Clause.
11+
# You may use, modify, and share the code for non-commercial
12+
# academic and research purposes only.
13+
# Commercial use — including offering PortPy as a service,
14+
# or incorporating it into a commercial product — requires
15+
# a separate commercial license.
16+
# ----------------------------------------------------------------------
7017

7118
def __init__(self, opt):
7219
"""Initialize this class

portpy/ai/data/base_dataset.py

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
1-
"""This module implements an abstract base class (ABC) 'BaseDataset' for datasets.
2-
3-
It also includes common transformation functions (e.g., get_transform, __scale_width), which can be later used in subclasses.
4-
"""
5-
import random
6-
import numpy as np
7-
import torch.utils.data as data
8-
from PIL import Image
9-
import torchvision.transforms as transforms
10-
import torchvision.transforms.functional as TF
11-
from abc import ABC, abstractmethod
12-
import torch
13-
import warnings
14-
from scipy.ndimage import affine_transform
15-
16-
17-
warnings.filterwarnings("ignore")
18-
19-
20-
class BaseDataset(data.Dataset, ABC):
21-
"""This class is an abstract base class (ABC) for datasets.
22-
23-
To create a subclass, you need to implement the following four functions:
24-
-- <__init__>: initialize the class, first call BaseDataset.__init__(self, opt).
25-
-- <__len__>: return the size of dataset.
26-
-- <__getitem__>: get a data point.
27-
-- <modify_commandline_options>: (optionally) add dataset-specific options and set default options.
28-
"""
1+
# Copyright 2025, the PortPy Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 with the Commons Clause restriction.
4+
# You may obtain a copy of the Apache 2 License at:
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# ----------------------------------------------------------------------
9+
# Commons Clause Restriction Notice:
10+
# PortPy is licensed under Apache 2.0 with the Commons Clause.
11+
# You may use, modify, and share the code for non-commercial
12+
# academic and research purposes only.
13+
# Commercial use — including offering PortPy as a service,
14+
# or incorporating it into a commercial product — requires
15+
# a separate commercial license.
16+
# ----------------------------------------------------------------------
2917

3018
def __init__(self, opt):
3119
"""Initialize the class; save the options in the class

portpy/ai/data/dosepred3d_dataset.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Copyright 2025, the PortPy Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 with the Commons Clause restriction.
4+
# You may obtain a copy of the Apache 2 License at:
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# ----------------------------------------------------------------------
9+
# Commons Clause Restriction Notice:
10+
# PortPy is licensed under Apache 2.0 with the Commons Clause.
11+
# You may use, modify, and share the code for non-commercial
12+
# academic and research purposes only.
13+
# Commercial use — including offering PortPy as a service,
14+
# or incorporating it into a commercial product — requires
15+
# a separate commercial license.
16+
# ----------------------------------------------------------------------
17+
118
#!/usr/bin/env python3
219
# -*- coding: utf-8 -*-
320
"""

portpy/ai/data/image_folder.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
"""A modified image folder class
2-
3-
We modify the official PyTorch image folder (https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py)
4-
so that this class can load images from both current directory and its subdirectories.
5-
"""
1+
# Copyright 2025, the PortPy Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 with the Commons Clause restriction.
4+
# You may obtain a copy of the Apache 2 License at:
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# ----------------------------------------------------------------------
9+
# Commons Clause Restriction Notice:
10+
# PortPy is licensed under Apache 2.0 with the Commons Clause.
11+
# You may use, modify, and share the code for non-commercial
12+
# academic and research purposes only.
13+
# Commercial use — including offering PortPy as a service,
14+
# or incorporating it into a commercial product — requires
15+
# a separate commercial license.
16+
# ----------------------------------------------------------------------
617

718
import torch.utils.data as data
819

portpy/ai/data/single_dataset.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Copyright 2025, the PortPy Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 with the Commons Clause restriction.
4+
# You may obtain a copy of the Apache 2 License at:
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# ----------------------------------------------------------------------
9+
# Commons Clause Restriction Notice:
10+
# PortPy is licensed under Apache 2.0 with the Commons Clause.
11+
# You may use, modify, and share the code for non-commercial
12+
# academic and research purposes only.
13+
# Commercial use — including offering PortPy as a service,
14+
# or incorporating it into a commercial product — requires
15+
# a separate commercial license.
16+
# ----------------------------------------------------------------------
17+
118
from portpy.ai.data.base_dataset import BaseDataset, get_transform
219
from portpy.ai.data.image_folder import make_dataset
320
import torch

portpy/ai/data/template_dataset.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Copyright 2025, the PortPy Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 with the Commons Clause restriction.
4+
# You may obtain a copy of the Apache 2 License at:
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# ----------------------------------------------------------------------
9+
# Commons Clause Restriction Notice:
10+
# PortPy is licensed under Apache 2.0 with the Commons Clause.
11+
# You may use, modify, and share the code for non-commercial
12+
# academic and research purposes only.
13+
# Commercial use — including offering PortPy as a service,
14+
# or incorporating it into a commercial product — requires
15+
# a separate commercial license.
16+
# ----------------------------------------------------------------------
17+
118
"""Dataset class template
219
320
This module provides a template for users to implement custom datasets.

portpy/ai/models/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Copyright 2025, the PortPy Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 with the Commons Clause restriction.
4+
# You may obtain a copy of the Apache 2 License at:
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# ----------------------------------------------------------------------
9+
# Commons Clause Restriction Notice:
10+
# PortPy is licensed under Apache 2.0 with the Commons Clause.
11+
# You may use, modify, and share the code for non-commercial
12+
# academic and research purposes only.
13+
# Commercial use — including offering PortPy as a service,
14+
# or incorporating it into a commercial product — requires
15+
# a separate commercial license.
16+
# ----------------------------------------------------------------------
17+
118
"""This package contains modules related to objective functions, optimizations, and network architectures.
219
320
To add a custom model class called 'dummy', you need to add a file called 'dummy_model.py' and define a subclass DummyModel inherited from BaseModel.

portpy/ai/models/base_model.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Copyright 2025, the PortPy Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 with the Commons Clause restriction.
4+
# You may obtain a copy of the Apache 2 License at:
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# ----------------------------------------------------------------------
9+
# Commons Clause Restriction Notice:
10+
# PortPy is licensed under Apache 2.0 with the Commons Clause.
11+
# You may use, modify, and share the code for non-commercial
12+
# academic and research purposes only.
13+
# Commercial use — including offering PortPy as a service,
14+
# or incorporating it into a commercial product — requires
15+
# a separate commercial license.
16+
# ----------------------------------------------------------------------
17+
118
import os
219
import torch
320
from collections import OrderedDict

0 commit comments

Comments
 (0)