-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add handling of multiclass format in detection dataset loading #4
base: main
Are you sure you want to change the base?
Conversation
ad3181b
to
f9996cd
Compare
e33889b
to
2e2a281
Compare
2e2a281
to
3c334cd
Compare
doctr/datasets/datasets/base.py
Outdated
for k, v in target.items(): | ||
img, target[k] = self.sample_transforms(img, v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, you apply self.sample_transforms
multiple time on img
. Also, img
seems to be strongly linked to the latest target in dict because it's the output of self.sample_transforms
with v
as target
, but I'm not sure what is the impact on img
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's more the other way around from what i see the transforms used in training are resizing transform and it's the target changes that is linked to the image
Yes the changes are done multiple time to the img
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't understand. Do you have an example ?
Is it fine to apply multiple times the same transformation on the same image ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you're right ! didn't see it
i tried resolving it this way
img_transformed = img.copy()
for class_name, bboxes in target.items():
img_transformed, target[class_name] = self.sample_transforms(img, bboxes)
img = img_transformed
what do you think ?
val_metric.update(gts=boxes_gt, preds=boxes_pred[:, :4]) | ||
for target, loc_pred in zip(targets, loc_preds): | ||
if isinstance(target, np.ndarray): | ||
target = {"words": target} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constant words
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
doctr/utils/visualization.py
Outdated
@@ -141,6 +141,24 @@ def create_obj_patch( | |||
raise ValueError("invalid geometry format") | |||
|
|||
|
|||
def get_colors(num_colors: int) -> List: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typing on return statement: List[Tuple[int, int, int]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
doctr/datasets/datasets/base.py
Outdated
@@ -56,8 +56,10 @@ def __getitem__(self, index: int) -> Tuple[Any, Any]: | |||
|
|||
if self.sample_transforms is not None: | |||
if isinstance(target, dict): | |||
img_transformed = img.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.copy()
didn't work neither on Tensorflow nor PyTorch. You may need to check if the current backend (TF or PyTorch) and use the good method to clone the tensor
tests/common/test_models_builder.py
Outdated
boxes = {CLASS_NAME: np.random.rand(words_per_page, 6)} | ||
boxes[CLASS_NAME][:2] *= boxes[CLASS_NAME][2:4] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should remove these statements, otherwise boxes
parameter is not used ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work ! 🚀
eccb2ee
to
8965394
Compare
…with all transforms
…handle better class ids
…lements for kie predictor (#6) * feat: ✨ add load backbone * feat: change kie predictor out * fix new elements for kie, dataset when class is empty and fix and add tests * fix api kie route * fix evaluate kie script * fix black * remove commented code * update README
aa15f43
to
b396f6d
Compare
Hello,
For testing,
dataset, in tests/common/test_datasets.py
preditions , in tensorflow and pytorch in test_models_detection and test_models_zoo
for training part, you should use the command
python references/detection/train_pytorch.py path/to/train/folder/ /path/to/test/folder/ "db_resnet34"
for db modelpython references/detection/train_pytorch.py path/to/train/folder/ /path/to/test/folder/ "linknet_resnet34"
for linknet model