Open SardarArslan opened 1 year ago
ImportError Traceback (most recent call last)
/content/EasyOCR/trainer/train.py in
ImportError: cannot import name 'validation' from 'test' (/usr/lib/python3.7/test/init.py)
This is the full error
ImportError Traceback (most recent call last) in 3 import yaml 4 #from test import validation ----> 5 from train import train 6 from utils import AttrDict 7 import pandas as pd
/content/EasyOCR/trainer/train.py in 15 from dataset import hierarchical_dataset, AlignCollate, Batch_Balanced_Dataset 16 from model import Model ---> 17 from test import validation 18 device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') 19
ImportError: cannot import name 'validation' from 'test' (/usr/lib/python3.7/test/init.py)
This is the full error can you find answer for this error?
Does anyone have solution for this error ?
Yes. Copy the train and test function in your code and comment this line. It'll work.
On Sat, Oct 22, 2022, 10:23 huynhkhoa44 @.***> wrote:
Does anyone have solution for this error ?
— Reply to this email directly, view it on GitHub https://github.com/JaidedAI/EasyOCR/issues/858#issuecomment-1287635348, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATYE26CG4SWUC5VUAUUX2E3WEN26VANCNFSM6AAAAAAQQFERX4 . You are receiving this because you authored the thread.Message ID: @.***>
Can you describe more clearly, I don't really understand :(((
In the trainer directory, you'll find test.py and train.py. Just copy paste the entire code above the train(opt, amp=False) line. Comment out the import validation from test line with #, run the above two functions and then call train as mentioned, in the order i wrote. It'll work. I use colab I ran the test and train in separate cells and then called the train function.
On Mon, Oct 24, 2022, 11:54 huynhkhoa44 @.***> wrote:
Can you describe more clearly, I don't really understand :(((
— Reply to this email directly, view it on GitHub https://github.com/JaidedAI/EasyOCR/issues/858#issuecomment-1288504381, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATYE26HY5YKF7CP3ACRYIBDWEYXBHANCNFSM6AAAAAAQQFERX4 . You are receiving this because you authored the thread.Message ID: @.***>
Can you show me a pic or snap how you are suggesting to do so
Can you show me a pic or snap how you are suggesting to do so
Kindly check it out.
Here's the colab link, it has another error, which I don't remeber how I resolved but check it out, it also has the inference code : https://drive.google.com/file/d/1Culfo69gTH0m10C5tvn2rPTow_FH1Jd6/view?usp=sharing
ImportError Traceback (most recent call last) in 3 import yaml 4 #from test import validation ----> 5 from train import train 6 from utils import AttrDict 7 import pandas as pd
/content/EasyOCR/trainer/train.py in 15 from dataset import hierarchical_dataset, AlignCollate, Batch_Balanced_Dataset 16 from model import Model ---> 17 from test import validation 18 device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') 19
ImportError: cannot import name 'validation' from 'test'
(/usr/lib/python3.7/test/**init**.py)
This is the full error
The reason is that test is being called from another module (/usr/lib/python3.7/test/init.py)
You can just rename the test.py
in the trainer folder to mytest.py
(or something else), and in the train.py
replace the:
from test import validation
to
from mytest import validation
Copy "validation" functoin from test.py ( /content/EasyOCR/trainer/test.py
) to train.py ( /content/EasyOCR/trainer/train.py
) and then comment out from test import validation
from train.py. Please do not forget to import necessarily modulus from test.py. Finally restart your session if you are working on Google Colab.
import os import torch.backends.cudnn as cudnn import yaml from train import train from utils import AttrDict import pandas as pd
4th line gives this error, kindly help me to remove this error.