Skip to content

Commit

Permalink
Rename to classtree to avoid a collision on pypi.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlane-aiml authored Jan 5, 2024
1 parent 716daf3 commit 960ef04
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 67 deletions.
28 changes: 0 additions & 28 deletions .gitlab-ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cff-version: "1.2.0"
title: "Classia"
title: "Classtree"
message: "If you use this software, please cite both the article from preferred-citation and the software itself."
authors:
- family-names: Valmadre
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CLASSIA
CLASSTREE
SOFTWARE LICENCE AGREEMENT
ACADEMIC OR NOT-FOR-PROFIT ORGANISATION - NON-COMMERCIAL INTERNAL RESEARCH USE ONLY
BY USING OR DOWNLOADING THE SOFTWARE, YOU ARE AGREEING TO THE TERMS AND CONDITIONS OF THIS LICENCE AGREEMENT (“AGREEMENT”).
Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Classia
# Classtree

![](https://img.shields.io/pypi/pyversions/name)

Classia is a hierarchical classifier for images or text.


Classtree is a hierarchical classifier for images or text.

```shell
pip install classia
pip install classtree
```

The fastest way to use Classia is to call the CLI on a folder of images or text files.
The fastest way to use Classtree is to call the CLI on a folder of images or text files.

```shell
train_data/
Expand All @@ -27,19 +29,19 @@ train_data/
```

```shell
classia train images --model animals --dir train_data/animals
classtree train images --model animals --dir train_data/animals
```

or

```shell
classia train text --model animals --dir train_data/animals
classtree train text --model animals --dir train_data/animals
```

And then use your model with the predict command.

```shell
classia predict --model animals new_data/image304.jpg
classtree predict --model animals new_data/image304.jpg
> birds/raptors/eagle
```

Expand All @@ -48,20 +50,20 @@ classia predict --model animals new_data/image304.jpg
You can download a pre-trained model using the download command.

```shell
classia download model dbpedia
classtree download model dbpedia
```

Or download a pre-prepared dataset.

```shell
classia download images inaturalist21-mini
classia download text dbpedia
classtree download images inaturalist21-mini
classtree download text dbpedia
```

If you want to fine-tune an existing model, you can use the `--from` flag during training with any downloaded model.

```shell
classia train text --model animals --from dbpedia --dir train_data/animals
classtree train text --model animals --from dbpedia --dir train_data/animals
```


Expand All @@ -84,11 +86,11 @@ classia train text --model animals --from dbpedia --dir train_data/animals
You can test your model on a hold-out dataset using the `test` command.

```shell
classia test --model animals --dir=test_data/animals
classtree test --model animals --dir=test_data/animals
```

## Licensing

Classia is available for non-commercial internal research use by academic institutions or not-for-profit organisations only, free of charge. Please, see the [license](./LICENSE.txt) for further details. To the extent permitted by applicable law, your use is at your own risk and our liability is limited. Interested in a commercial license? For commercial queries, please email <aimlshop@adelaide.edu.au> with subject line “Classia Commercial License”.
Classtree is available for non-commercial internal research use by academic institutions or not-for-profit organisations only, free of charge. Please, see the [license](./LICENSE.txt) for further details. To the extent permitted by applicable law, your use is at your own risk and our liability is limited. Interested in a commercial license? For commercial queries, please email <aimlshop@adelaide.edu.au> with subject line “Classtree Commercial License”.

This is an [AIML Shop](https://shop.aiml.team) project.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "classia"
name = "classtree"
description = "A toolkit for hierarchical classification"
dynamic = ["version"]
readme = "README.md"
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions src/classia/cli.py → src/classtree/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import os

from classia.dataset import hierarchy_and_labels_from_folder
from .dataset import hierarchy_and_labels_from_folder
from .download import download_model, download_text_dataset, download_image_dataset
from .export import export_model
from .test import test_model
Expand All @@ -22,12 +22,12 @@ def add_global_args(parser):
parser.add_argument(
"--datasets_dir",
help="The path of the directory to store named datasets",
default=os.path.expanduser("~/.cache/classia/datasets"),
default=os.path.expanduser("~/.cache/classtree/datasets"),
)
parser.add_argument(
"--models_dir",
help="The path of the directory to store named models",
default=os.path.expanduser("~/.cache/classia/models"),
default=os.path.expanduser("~/.cache/classtree/models"),
)


Expand Down Expand Up @@ -150,7 +150,7 @@ def add_export_args(export_parser):
export_parser.add_argument(
"--export_dir",
help="The path of the directory to export models",
default=os.path.expanduser("~/.cache/classia"),
default=os.path.expanduser("~/.cache/classtree"),
)
export_parser.add_argument(
"--text",
Expand Down
4 changes: 2 additions & 2 deletions src/classia/dataset.py → src/classtree/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .hier import make_hierarchy_from_edges


class ClassiaImageDataset(Dataset):
class ClasstreeImageDataset(Dataset):
def __init__(self, files, labels, transform):
self.files = files
self.labels = labels
Expand All @@ -26,7 +26,7 @@ def __getitem__(self, i):
return image, self.labels[i]


class ClassiaTextDataset(Dataset):
class ClasstreeTextDataset(Dataset):
def __init__(self, files, labels, *, transform):
self.files = files
self.labels = labels
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/classia/export.py → src/classtree/export.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import torch

from classia.models import model_classes
from .models import model_classes


def export_model(models_dir, model, device):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 10 additions & 10 deletions src/classia/models.py → src/classtree/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# Image model: Small, Medium, Large
# ref: https://pytorch.org/vision/master/_modules/torchvision/models/resnet.html
class ClassiaImageModelV1Small(Module):
class ClasstreeImageModelV1Small(Module):
def __init__(self, tree: Hierarchy):
super().__init__()

Expand All @@ -28,7 +28,7 @@ def forward(self, x):
return self.resnet(x)


class ClassiaImageModelV1Medium(Module):
class ClasstreeImageModelV1Medium(Module):
def __init__(self, tree: Hierarchy):
super().__init__()

Expand All @@ -40,7 +40,7 @@ def forward(self, x):
return self.resnet(x)


class ClassiaImageModelV1Large(Module):
class ClasstreeImageModelV1Large(Module):
def __init__(self, tree: Hierarchy):
super().__init__()

Expand All @@ -54,7 +54,7 @@ def forward(self, x):

# TEXT MODEL: Base, Large
# ref: https://pytorch.org/text/stable/_modules/torchtext/models/roberta/bundler.html
class ClassiaTextModelV1Medium(Module):
class ClasstreeTextModelV1Medium(Module):
def __init__(self, tree: Hierarchy):
super().__init__()

Expand All @@ -69,7 +69,7 @@ def forward(self, input_ids):
return self.roberta(input_ids)


class ClassiaTextModelV1Large(Module):
class ClasstreeTextModelV1Large(Module):
def __init__(self, tree: Hierarchy):
super().__init__()

Expand All @@ -85,11 +85,11 @@ def forward(self, input_ids):


model_classes = {
"image-v1-s": ClassiaImageModelV1Small,
"image-v1-m": ClassiaImageModelV1Medium,
"image-v1-l": ClassiaImageModelV1Large,
"text-v1-m": ClassiaTextModelV1Medium,
"text-v1-l": ClassiaTextModelV1Large,
"image-v1-s": ClasstreeImageModelV1Small,
"image-v1-m": ClasstreeImageModelV1Medium,
"image-v1-l": ClasstreeImageModelV1Large,
"text-v1-m": ClasstreeTextModelV1Medium,
"text-v1-l": ClasstreeTextModelV1Large,
}


Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/classia/test.py → src/classtree/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import torch

from classia.dataset import hierarchy_and_labels_from_folder
from classia.models import model_classes, get_text_encoder
from classia.train import get_dataloader, evaluate, get_image_dataset, get_text_dataset
from .dataset import hierarchy_and_labels_from_folder
from .models import model_classes, get_text_encoder
from .train import get_dataloader, evaluate, get_image_dataset, get_text_dataset

LOGGER = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions src/classia/train.py → src/classtree/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from tqdm import tqdm

from .hier import truncate_given_lca, FindLCA, SumDescendants
from .dataset import ClassiaImageDataset, ClassiaTextDataset
from .dataset import ClasstreeImageDataset, ClasstreeTextDataset
from .loss import MarginLoss
from .metrics import UniformLeafInfoMetric, DepthMetric, IsCorrect, operating_curve
from .predict import pareto_optimal_predictions
Expand Down Expand Up @@ -56,13 +56,13 @@ def get_image_dataset(files, labels):
Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.244, 0.225]),
]
)
dataset = ClassiaImageDataset(files, labels, transform=transform)
dataset = ClasstreeImageDataset(files, labels, transform=transform)
return dataset


def get_text_dataset(files, labels, encoder):
transform = encoder.transform()
dataset = ClassiaTextDataset(files, labels, transform=transform)
dataset = ClasstreeTextDataset(files, labels, transform=transform)
return dataset


Expand Down

0 comments on commit 960ef04

Please sign in to comment.