You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In cases where the dataset was not used to train the model, people would need to: 1) remap the class names to match with the dataset; 2) transform the class IDs to match with the dataset. Here is what a boilerplate code would look like:
class_mapping= {"dog": "animal", "cat": "animal", "eagle": "bird"}
for_, image, targetindataset:
result=model.infer(image)[0]
detection=sv.Detections.from_inference(result)
# check if all mapped values are within the dataset classesifnotall([valueindataset.classesforvalueinclass_mapping.values()]):
raiseValueError("All mapped values must be in dataset classes")
# remap class namesdetection['class_name'] =list(map(lambdaname: class_mapping[name] ifnameinclass_mapingelsename, detection['class_name']))
# remove predicted classes not in the datasetdetection=detection[np.isin(detection['class_name'], dataset.classes)]
# remap Class IDs based on Class namesdetection.class_id=np.array([dataset.classes.index(name) fornameindetection['class_name']])
Where the transform method implements the same logic described in the boilerplate. Note that class_mapping is an optional argument in cases where class names are the same between a model and a dataset.
Additional
No response
Are you willing to submit a PR?
Yes I'd like to help by submitting a PR!
The text was updated successfully, but these errors were encountered:
Search before asking
Description
Context
If a model is trained on a dataset, benchmarking with
supervision
's evaluation API is straightforward.However, if the dataset was not used to train a model (unrelated dataset), one should follow the "how-to" guide on Benchmarking a model.
What if we can improve this with a simpler API?
Use case
In cases where the dataset was not used to train the model, people would need to: 1) remap the class names to match with the dataset; 2) transform the class IDs to match with the dataset. Here is what a boilerplate code would look like:
Proposed API for the above transformation:
Where the
transform
method implements the same logic described in the boilerplate. Note thatclass_mapping
is an optional argument in cases where class names are the same between a model and a dataset.Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: