Skip to content
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

Enable training with DocLayout-YOLO #35

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

agombert
Copy link

@agombert agombert commented Nov 5, 2024

This PR addresses several issues encountered when running the training command:

python train.py --data data/config --model m-doclayout --epoch 10 --image-size 1024 --batch-size 4 --project finetuning --pretrain models/doclayout_yolo_docstructbench_imgsz1024.pt --optimizer Adam --lr0 0.001 --warmup-epochs 1.0 --patience 2 --device 0

Changes Made

1. Added Missing Dependency

Added huggingface_hub to project dependencies in pyproject.toml:

dependencies = [
    # ... existing dependencies ...
    "huggingface_hub>=0.26.2",
]

2. Fixed AMP Check Issue

Following the solution from issue #32, commented out the AMP check line in utils/checks.py to avoid the UnpicklingError: invalid load key, '<' error.

3. Fixed Dilated Convolution Implementation

Modified the dilated_conv method in g2l_crm.py to properly handle batch normalization and activation functions:

def dilated_conv(self, x, dilation):
    weight = self.dcv.conv.weight
    padding = dilation * (self.k//2)
    x = F.conv2d(x, weight, stride=1, padding=padding, dilation=dilation)
    if hasattr(self.dcv, 'bn'):
        x = self.dcv.bn(x)
    if hasattr(self.dcv, 'act'):
        x = self.dcv.act(x)
    return x

This change fixes the AttributeError: 'Conv' object has no attribute 'bn' by properly checking for the existence of batch normalization and activation layers before applying them.

Testing

  • Successfully ran training for 10 epochs
  • No more AttributeError or UnpicklingError issues

Note: There are still some FutureWarning messages about torch.load with weights_only=False, but these don't affect functionality and can be addressed in a future update.

@JulioZhao97
Copy link
Collaborator

JulioZhao97 commented Nov 6, 2024

Thanks for your contribution! We can discuss further in #32

@JulioZhao97
Copy link
Collaborator

@agombert Hello, please check issue in #72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants