Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
smilesun committed May 8, 2024
2 parents 0fca21d + 75db7ad commit 6ffb5dd
Showing 5 changed files with 25 additions and 17 deletions.
6 changes: 3 additions & 3 deletions docs/doc_benchmark.md
Original file line number Diff line number Diff line change
@@ -36,11 +36,11 @@ example.

## Running a benchmark
For the execution of a benchmark we provide two scripts in our repository:
- local version for running the benchmark on a standalone machine:
- running the benchmark on a standalone machine (computation node):
[run_benchmark_standalone.sh](https://github.com/marrlab/DomainLab/blob/master/run_benchmark_standalone.sh)
- cluster version for running the benchmark on a slurm cluster: [run_benchmark_slurm.sh](https://github.com/marrlab/DomainLab/blob/master/run_benchmark_slurm.sh)
- launching the benchmark on the login node of a slurm cluster (benchmark will be dispatched to computation node via DomainLab scripts): [run_benchmark_slurm.sh](https://github.com/marrlab/DomainLab/blob/master/run_benchmark_slurm.sh)

### Benchmark on a standalone machine (with or without GPU)
### Benchmark on a standalone machine/computation node (with or without GPU)
To run the benchmark with a specific configuration on a standalone machine, inside the DomainLab
folder, one can execute (we assume you have a machine with 4 cores or more)
```shell
28 changes: 17 additions & 11 deletions docs/doc_tasks.md
Original file line number Diff line number Diff line change
@@ -32,10 +32,16 @@ To give an example, suppose we have a classification task to classify between ca

In each folder, the images are organized in sub-folders by their class. For example, "/path/to/3rd_domain/folder_c/dog" folder contains all the images of class "dog" from the 3rd domain.

It might be the case that across the different data sources the same class is named differently. For example, in the 1st data source, the class dog is stored in sub-folder named
"hund", in the 2nd data source, the dog is stored in sub-folder named "husky" and in the 3rd data source, the dog is stored in sub-folder named "dog".
It might be the case that the same classes are named differently across the different data sources. For example, in the 1st data source, the class dog is stored in a sub-folder named "hund", in the 2nd data source, the dog is stored in a sub-folder named "husky", and in the 3rd data source, the dog is stored in a sub-folder called "dog".

It might also be the case that some classes exist in one data source but does not exist in another data source. For example, folder "/path/to/2nd_domain/folder_b" does not have a sub-folder for class "human".
In that case, we can use `dict_domain_folder_name2class` to map the corresponding subfolders to the correct domain. The `dict_domain_folder_name2class` parameter is a dictionary where:

- Key: The name of a subfolder in a specific domain.
- Value: The corresponding user-defined class name.

This is also shown in the example below, where the dictionary maps the different subfolder names to 'car' and 'chair', which are the user defined classes. A more complex example of such a mapping can be found [here](../examples/tasks/task_blood3.py).

It might also be the case that some classes exist in one data source but do not exist in another data source. For example, folder "/path/to/2nd_domain/folder_b" does not have a sub-folder for the class "human". In that case, we don't add the entry into the `dict_domain_folder_name2class` mapping.

Folder structure of the 1st domain:
```text
@@ -125,28 +131,28 @@ from domainlab.tasks import mk_task_folder
print(mk_task_folder.__doc__)
```

extensions: a python dictionary with key as the domain name
`extensions`: a python dictionary with key as the domain name
and value as the file extensions of the image.

list_str_y: a python list with user defined class names where
`list_str_y`: a python list with user defined class names where
the order of the list matters.

dict_domain_folder_name2class: a python dictionary, with key
`dict_domain_folder_name2class`: a python dictionary, with key
as the user specified domain name, value as a dictionary to map the
sub-folder name of each domain's class folder into the user defined
common class name.

dict_domain_img_trans: a python dictionary with keys as the user
`dict_domain_img_trans`: a python dictionary with keys as the user
specified domain name, value as a user defined torchvision transform.
This feature allows carrying out different transformation (composition) to different
domains at training time.

img_trans_te: at test or inference time, we do not have knowledge
`img_trans_te`: at test or inference time, we do not have knowledge
of domain information so only a unique transform (composition) is allowed.

isize: domainlab.tasks.ImSize(image channel, image height, image width)
`isize`: domainlab.tasks.ImSize(image channel, image height, image width)

dict_domain2imgroot: a python dictionary with keys as user specified domain names and values
`dict_domain2imgroot`: a python dictionary with keys as user specified domain names and values
as the absolute path to each domain's data.

taskna: user defined task name
`taskna`: user defined task name
4 changes: 3 additions & 1 deletion domainlab/algos/trainers/a_trainer.py
Original file line number Diff line number Diff line change
@@ -127,7 +127,9 @@ def init_business(self, model, task, observer, device, aconf, flag_accept=True):
self._decoratee.init_business(
model, task, observer, device, aconf, flag_accept
)
self.model = model
self.model = self._decoratee
else:
self.model = model
self.task = task
self.task.init_business(trainer=self, args=aconf)
self.model.list_d_tr = self.task.list_domain_tr
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "domainlab"
version = "0.6.1"
version = "0.6.3"
readme = "README.md"
repository = "https://github.com/marrlab/DomainLab"
homepage = "https://marrlab.github.io/DomainLab/"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ def copy_dir(dir_path="zdata"):
package_data={
"zdata": [f for f in copy_dir()],
},
version="0.6.1",
version="0.6.3",
description="Library of modular domain generalization for deep learning",
url="https://github.com/marrlab/DomainLab",
author="Xudong Sun, et.al.",

0 comments on commit 6ffb5dd

Please sign in to comment.