question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to generate gt.mat file for new dataset?

See original GitHub issue

Hello! I am trying to create a new dataset using a different set of texts/words and was able to generate the image containing the new texts. However, I want to crop the individual texts using the code mentioned here: https://github.com/ankush-me/SynthText/issues/174 but it appears that it needs a “gt.mat” file. I tried to do this by adding a line of code within the visualize_results.py

viz_textbb(rgb, [charBB], wordBB)
print ("     image name   : ", colorize(Color.RED, k, bold=True))
print ("  ** no. of chars : ", colorize(Color.YELLOW, charBB.shape[-1]))
print ("  ** no. of words : ", colorize(Color.YELLOW, wordBB.shape[-1]))
print ("  ** text         : ", colorize(Color.GREEN, txt))
gt_file = {"imnames": k, "wordBB": wordBB, "charBB": charBB, "txt": txt} ## added this

then eventually saving gt_file as a gt.mat file using scipy.io. However whenever i use this gt.mat to the code mentioned above to crop word patches, i get an error:

Traceback (most recent call last):
  File "crop.py", line 146, in <module>
    do_work(opts,synth_dat)
  File "crop.py", line 104, in do_work
    np.random.shuffle(i_range)
  File "mtrand.pyx", line 4529, in numpy.random.mtrand.RandomState.shuffle
  File "mtrand.pyx", line 4532, in numpy.random.mtrand.RandomState.shuffle
TypeError: 'range' object does not support item assignment

I feel like the error is coming from my generated gt.mat because of its format. Would just like to ask how to properly create a gt.mat file that can be used as an input to the cropping code?

Thank you very much and thank you btw for this wonderful project. I’ve been learning it for weeks and love it so much!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
claireritycommented, Sep 25, 2021

@ankush-me Thank you very much for these! Really appreciate all the help and esp. this opensource project!

1reaction
ankush-mecommented, Sep 23, 2021

Check the dataset readme file for a description of gt.mat.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MATLAB exportToPreviousRelease - MathWorks
You can use the exportToPreviousRelease function to add data to a MAT-file. For example, if you run another simulation that logs data and...
Read more >
Explain ground-truth .mat file of an image for CNN?
I want to create .mat file for MIT67 indoor scene recognition dataset (15600 images) how should I do that? Also, how to generate...
Read more >
explain ground-thruth .mat file of an image for CNN
i'm new to coding CNN i'v got ShanghaiTech crowd counting dataset that has (beside the images) .mat files for what i believe the...
Read more >
How to work with object detection datasets in COCO format
COCO file format. If you are new to the object detection space and are tasked with creating a new object detection dataset, then...
Read more >
doctr.datasets.synthtext - docTR documentation
Source code for doctr.datasets.synthtext ... os.makedirs(reco_folder_path, exist_ok=False) mat_data = sio.loadmat(os.path.join(tmp_root, "gt.mat")) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found