|
1 | 1 | from bioclip import TreeOfLifeClassifier, Rank, CustomLabelsClassifier
|
2 | 2 | from .predict import BIOCLIP_MODEL_STR
|
3 | 3 | import open_clip as oc
|
| 4 | +import os |
4 | 5 | import json
|
5 | 6 | import sys
|
6 | 7 | import prettytable as pt
|
@@ -83,9 +84,9 @@ def create_parser():
|
83 | 84 | predict_parser.add_argument('--rank', choices=['kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species'],
|
84 | 85 | help='rank of the classification, default: species (when)')
|
85 | 86 | predict_parser.add_argument('--k', type=int, help='number of top predictions to show, default: 5')
|
86 |
| - cls_group = predict_parser.add_mutually_exclusive_group(required=False) |
87 |
| - cls_group.add_argument('--cls', help='comma separated list of classes to predict, when specified the --rank argument is not allowed') |
88 |
| - cls_group.add_argument('--cls-file', help='path to file with list of classes to predict, one per line, when specified the --rank and --k arguments are not allowed') |
| 87 | + cls_help = "classes to predict either a comma separated list or a path to a text file of classes (one per line), when specified the --rank argument is not allowed." |
| 88 | + predict_parser.add_argument('--cls', help=cls_help) |
| 89 | + |
89 | 90 | predict_parser.add_argument('--device', **device_arg)
|
90 | 91 | predict_parser.add_argument('--model', **model_arg)
|
91 | 92 | predict_parser.add_argument('--pretrained', **pretrained_arg)
|
@@ -147,8 +148,8 @@ def main():
|
147 | 148 | pretrained_str=args.pretrained)
|
148 | 149 | elif args.command == 'predict':
|
149 | 150 | cls_str = args.cls
|
150 |
| - if args.cls_file: |
151 |
| - cls_str = create_classes_str(args.cls_file) |
| 151 | + if os.path.exists(args.cls): |
| 152 | + cls_str = create_classes_str(args.cls) |
152 | 153 | predict(args.image_file,
|
153 | 154 | format=args.format,
|
154 | 155 | output=args.output,
|
|
0 commit comments