UnboundLocalError: local variable 'l1_loss' referenced before assignment #1739
Replies: 41 comments
-
If needed, I can upload my dataset. |
Beta Was this translation helpful? Give feedback.
-
I tested this on a different environment and I get the same error:
|
Beta Was this translation helpful? Give feedback.
-
I think I made a mistake, I just realized I used polygons from original images and the images in dataset were mogrified... checking |
Beta Was this translation helpful? Give feedback.
-
Working now, with big images much slower. What height or width would be recommanded for training?
EDIT: worked until killed:
|
Beta Was this translation helpful? Give feedback.
-
Images are resized internally :) Try to reduce/set the workers with |
Beta Was this translation helpful? Give feedback.
-
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 :)
|
Beta Was this translation helpful? Give feedback.
-
You should train longer :D But for only 5 epochs the metrics doesn't looks wrong 👍 |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
Curious to see how well this can work ^^ Currently we use |
Beta Was this translation helpful? Give feedback.
-
Never used it, yes, I think it should. |
Beta Was this translation helpful? Give feedback.
-
Seems I can't load it as per |
Beta Was this translation helpful? Give feedback.
-
You can :) You have to change the vocab with The vocab should contain all the chars you have in your dataset (or more) |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 :) |
Beta Was this translation helpful? Give feedback.
-
@johnlockejrr No only for the recognition model training |
Beta Was this translation helpful? Give feedback.
-
I think this wasn't planned right ? ^^ |
Beta Was this translation helpful? Give feedback.
-
For a detection model can't I specify more class names? As I have |
Beta Was this translation helpful? Give feedback.
-
You can also load this model with:
|
Beta Was this translation helpful? Give feedback.
-
Bad day :)
|
Beta Was this translation helpful? Give feedback.
-
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.
|
Beta Was this translation helpful? Give feedback.
-
I reconverted my data to:
I'll retrain :) |
Beta Was this translation helpful? Give feedback.
-
I resumed it and it finished:
|
Beta Was this translation helpful? Give feedback.
-
That's a known issue PR to fix this is on the way :) |
Beta Was this translation helpful? Give feedback.
-
It performs well (*ish). With your script above but any idea why identifies only one line? |
Beta Was this translation helpful? Give feedback.
-
What's the shape of the model output? |
Beta Was this translation helpful? Give feedback.
-
Btw in my provided script lower bin_thresh and box_thresh to 0.1 |
Beta Was this translation helpful? Give feedback.
-
I trained the model on x960 images, when detecting I sould use the same resolution? |
Beta Was this translation helpful? Give feedback.
-
If you have resized it before on your own it would make sense yep |
Beta Was this translation helpful? Give feedback.
-
I resized the image to x960. I think it needs more training. |
Beta Was this translation helpful? Give feedback.
-
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
Beta Was this translation helpful? Give feedback.
All reactions