You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failed to find data adapter that can handle input #30
Hi @pythonlessons,
I'm trying to use the image to word Tutorial.
I changed the train.py a bit in order to read my images and labels better. The only change was in def read_annotation_file:
Old Code:
def read_annotation_file(annotation_path):
dataset, vocab, max_len = [], set(), 0
with open(annotation_path, "r") as f:
for line in tqdm(f.readlines()):
line = line.split()
image_path = data_path + line[0][1:]
label = line[0].split("_")[1]
dataset.append([image_path, label])
vocab.update(list(label))
max_len = max(max_len, len(label))
return dataset, sorted(vocab), max_len
New Code:
def read_annotation_file(annotation_path):
dataset, vocab, max_len = [], set(), 0
with open(annotation_path, "r") as f:
for line in tqdm(f.readlines()):
line = line.split(' ')
image_path = data_path + line[0]
label = line[1]
dataset.append([image_path, label])
vocab.update(list(label))
max_len = max(max_len, len(label))
return dataset, sorted(vocab), max_len
I also changed something in line 91 due to an error:
Old Code: metrics=[CWERMetric()],
New Code: metrics=[CWERMetric('accuracy')],
This is my error:
Traceback (most recent call last):
File "/path/to/mltu/Tutorials/01_image_to_word/train.py", line 111, in
model.fit(
File "/path/to/.local/lib/python3.10/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/path/to/.local/lib/python3.10/site-packages/keras/engine/data_adapter.py", line 1083, in select_data_adapter
raise ValueError(
ValueError: Failed to find data adapter that can handle input: <class 'mltu.dataProvider.DataProvider'>, <class 'NoneType'>
How do I need to change train_data_provider or train_dataset or is it a version problem ?
Traceback (most recent call last):
File "/path/to/mltu/Tutorials/01_image_to_word/train.py", line 102, in <module>
model.fit(
File "/path/to/python3.10/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/path/to/python3.10/site-packages/keras/engine/data_adapter.py", line 1083, in select_data_adapter
raise ValueError(
ValueError: Failed to find data adapter that can handle input: <class 'mltu.dataProvider.DataProvider'>, <class 'NoneType'>
My dataset in read_annotation_file looks like this:
1000 is the size of my dataset and I'm loading it as described on to the dataset. I already sent the dataset above.
Could you maybe show me a few lines of your example annotation file maybe I'm loading the wrong way ....
Activity
pythonlessons commentedon Aug 8, 2023
Hi, if you followed my tutorial from pylessons.com then you may face a problem with code.
Use newest mltu library version. And use the right ImageReader, example code:
philzetter commentedon Aug 8, 2023
Thank you for the fast response !
I'm using exactly the same code.
My train_dataset looks like this:
[['CINCMC/images/one.jpg', 'one']]pythonlessons commentedon Aug 15, 2023
try to iterate train_data_provider in for loop and check if you receive correct data there
philzetter commentedon Aug 16, 2023
Could you sent me an example of your annotation files. I just need a few lines of the txt files. I think that's the problem.
philzetter commentedon Aug 23, 2023
I still get this error:
My dataset in read_annotation_file looks like this:
[['CINCMC/train_images/word_1001.png', 'KSZU0005183'], ['CINCMC/train_images/word_1002.png', '25G2'], ['CINCMC/train_images/word_1003.png', 'SLRU0001112'], ['CINCMC/train_images/word_1004.png', '25U2'], ['CINCMC/train_images/word_1005.png', 'SLRU0001540'], ['CINCMC/train_images/word_1006.png', 'SLRU0001072'], ['CINCMC/train_images/word_1007.png', '25U2'], ['CINCMC/train_images/word_1008.png', '25U2'], ['CINCMC/train_images/word_1009.png', 'SLRU0000939'], ['CINCMC/train_images/word_1010.png', '25U2'], ['CINCMC/train_images/word_1011.png', '25U2'], ['CINCMC/train_images/word_1012.png', 'SLRU0001046'], ['CINCMC/train_images/word_1013.png', '25U2'], ['CINCMC/train_images/word_1014.png', 'SLRU0000923'], ['CINCMC/train_images/word_1015.png', '25U2'], ['CINCMC/train_images/word_1016.png', 'SLRU0001133'], ['CINCMC/train_images/word_1017.png', '25U2'], ['CINCMC/train_images/word_1018.png', 'SLRU0001386'], ['CINCMC/train_images/word_1019.png', 'SLRU0001473'], ['CINCMC/train_images/word_1020.png', '25U2'], ['CINCMC/train_images/word_1021.png', '25U2'], ['CINCMC/train_images/word_1022.png', 'SLRU0001046'], ['CINCMC/train_images/word_1023.png', 'SLRU0001410'], ['CINCMC/train_images/word_1024.png', '25U2'], ['CINCMC/train_images/word_1025.png', '25U2'], ['CINCMC/train_images/word_1026.png', '25U2'], ['CINCMC/train_images/word_1027.png', 'SLRU0001616'], ['CINCMC/train_images/word_1028.png', 'SLRU0001128'], ['CINCMC/train_images/word_1029.png', 'SLRU0001149'], ['CINCMC/train_images/word_1030.png', '25U2'], ['CINCMC/train_images/word_1031.png', '25U2'], ['CINCMC/train_images/word_1032.png', 'SLRU0001365'], ['CINCMC/train_images/word_1033.png', '25U2'], ['CINCMC/train_images/word_1034.png', 'SLRU0001318'], ['CINCMC/train_images/word_1035.png', '25U2'], ['CINCMC/train_images/word_1036.png', '25U2'], ['CINCMC/train_images/word_1037.png', 'SLRU0001262'], ['CINCMC/train_images/word_1038.png', '25U2']]Versions:
keras 2.13.1
tensorflow 2.13.0
pythonlessons commentedon Aug 23, 2023
you tried to run this:
Check if it doesn't return None, because it seems like that
philzetter commentedon Aug 23, 2023
The result of:
looks like this:
pythonlessons commentedon Aug 23, 2023
Looks ok, try to print following:
philzetter commentedon Aug 23, 2023
Tried the following code:
Result is:
(1000, 32, 128, 3) (1000, 12)But this was the only line that was printed out
pythonlessons commentedon Aug 23, 2023
your batch_size is 1000?
philzetter commentedon Aug 23, 2023
1000 is the size of my dataset and I'm loading it as described on to the dataset. I already sent the dataset above.
Could you maybe show me a few lines of your example annotation file maybe I'm loading the wrong way ....
vaidehidev2 commentedon Nov 19, 2024
i want to train this model of handwritting sentences on my custom dataset, is it possible?
how will i generate the text file that is require to train