-
Notifications
You must be signed in to change notification settings - Fork 426
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
UnboundLocalError: local variable 'l1_loss' referenced before assignment #1738
Comments
If needed, I can upload my dataset. |
I tested this on a different environment and I get the same error:
|
I think I made a mistake, I just realized I used polygons from original images and the images in dataset were mogrified... checking |
Working now, with big images much slower. What height or width would be recommanded for training?
EDIT: worked until killed:
|
Images are resized internally :) Try to reduce/set the workers with |
I just resized the images to x960 and recalculated the the polygons and everything goes smooth, anyway my dataset is at line level, I give it a try :)
|
You should train longer :D But for only 5 epochs the metrics doesn't looks wrong 👍 |
Yes! I just wanted to be sure it runs, was a first test, I'm happy with it anyway. Just figuring how to add my new trained (*ish) model to the streamlit demo app :-| EDIT: besides my datasets are line-level, I have another problem: my datasets are mostly RTL, should I do anything for it to work (like python bidi etc.)? Is, let's say Arabic or Hebrew requiring other features? |
Curious to see how well this can work ^^ Currently we use |
Never used it, yes, I think it should. |
You can :) You have to change the vocab with The vocab should contain all the chars you have in your dataset (or more) |
Oh, sorry, I'm new to it. I mostly trained But it needs a vocab for a detection model? I didn't train a recognition model yet. |
If no of the predefined vocabs should fit you can simply change: doctr/references/recognition/train_pytorch.py Line 189 in df762ed
to vocab="abc" for example but to load the model later you need the same string which defines your models vocab :) |
@johnlockejrr No only for the recognition model training |
Couldn't I load only the detection model to see how it performs on a new test image? |
I just take a look at |
Feel free to open a PR to add the missing chars 👍 |
Sure :) Load your custom trained model (in combination with the
or only with the
|
Perfect! Thank you for all your help! I'll open a PR later today for a new language and ammend the Hebrew language. |
reference PR to show what's required to update or add a vocab: https://github.com/mindee/doctr/pull/1700/files |
Very strage with my model. Executing your script above:
Could this happen because I trained it on a line-level dataset? |
Can your share on entry from your |
Sure:
|
Better, I can upload the |
Ah i see you trained an KIE model 😅 To train only a detection model
|
OMG! :) |
I think this wasn't planned right ? ^^ |
For a detection model can't I specify more class names? As I have |
You can also load this model with:
|
Bad day :)
|
I think I should re-train it :) Error on line If is a KIE model shouldn't I I changed the line to But I get nothing, script runs but no detections.
|
I reconverted my data to:
I'll retrain :) |
I resumed it and it finished:
|
That's a known issue PR to fix this is on the way :) |
Btw in my provided script lower bin_thresh and box_thresh to 0.1 |
I trained the model on x960 images, when detecting I sould use the same resolution? |
If you have resized it before on your own it would make sense yep |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Bug description
While training a Doctr model with my own dataset, I encountered an UnboundLocalError in the compute_loss function of the differentiable_binarization module.
Code snippet to reproduce the bug
python references/detection/train_pytorch.py datasets/sam/train_out datasets/sam/val_out db_resnet50 --epochs 5 --device 0
Error traceback
Environment
DocTR version: 0.9.1a0
TensorFlow version: N/A
PyTorch version: 2.4.1+cu121 (torchvision 0.19.1+cu121)
OpenCV version: 4.10.0
OS: Ubuntu 22.04.5 LTS
Python version: 3.10.12
Is CUDA available (TensorFlow): N/A
Is CUDA available (PyTorch): Yes
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3060
Nvidia driver version: 561.09
cuDNN version: Could not collect
Deep Learning backend
The text was updated successfully, but these errors were encountered: