yuantailing / ctw-baseline

Baseline methods for [CTW dataset](https://ctwdataset.github.io/)
MIT License
329 stars 88 forks source link

How to output the text in the picture to a text file with your project like the picture on homepage #24

Open Sesefad0u opened 5 years ago

Sesefad0u commented 5 years ago

Thanks for your share,it's good . But there are too many file for a new, and i just want that use it like this :input a picture with some text in it and output the text into a text file via the trained model in your project. Which py file should i use and what should i do ? Thanks !

yuantailing commented 5 years ago

I think you should see tutorial (Part 3: detection baseline).

After you run cd ../detection && python3 merge_results.py (and have run all code above it), you will get detection results in detection/products/detections.jsonl.

kdzmwl commented 5 years ago

If I want to use the existing models, are all the images shared(image-test, image-trainval) necessary? If not, should I begin from ### Download trained models? New comer here, thx.

yuantailing commented 5 years ago

I think you could download only testset but not download trainval. Annotation files must be downloaded. Some files are generated in training steps. If you don't download trainval images, some scripts may fail. If it fails in some images not found, you can fill them with any image of shape 2048x2048x3.

kdzmwl commented 5 years ago

I think you could download only testset but not download trainval. Annotation files must be downloaded. Some files are generated in training steps. If you don't download trainval images, some scripts may fail. If it fails in some images not found, you can fill them with any image of shape 2048x2048x3.

Then how about using our own images? Should still download the image-test or just turn ours into 2048x2048x3(and put them into the correct place)?

yuantailing commented 5 years ago

@kdzmwl I think it can be done by changing detection/prepare_test_data.py.

Sesefad0u commented 5 years ago

When I run prepare_test_data.py,There are no text come out in detection/products/test/ as you say that this step will output detection/products/test/*.{jpg,txt} . And when I run eval.py , It's normal . But when merge_results.py run , it tells me that there are no file called like "chinese.0.txt" and so on . And I found that the file in products/results is called"chinese.00.txt,chinese.010.txt,...chinese.10.txt, chinese.100.txt....." . What's wrong with it and what should I do? Thanks!

yuantailing commented 5 years ago
  1. output means these files will be created, not output to stdout.
  2. For the filname issue, did you edited my code anywhere? Please roll back. Or you can edit merge_results.py to read your filename.
Sesefad0u commented 5 years ago

We didn't change your code, just put a picture of a zip file in image/test (a total of seven zip) and changed info.json. The code eval.py runs without error, but runs merge_results.py When he told us that there was no chinese.0.txt, we looked at products/result and found that only Chinese.00.txt was associated with this. And in the end we want to throw our own pictures and run out of the results, then shouldn't this be the case?

Sesefad0u commented 5 years ago

I have 4 GPU on my server. What should I change in eval.py can make it run with 4GPU ? (It run at only one GPU now),Thanks!

yuantailing commented 5 years ago

We decide which GPU to use in https://github.com/yuantailing/ctw-baseline/blob/f7b3467fa5814fac39f2ec68d9df54273537b9f7/detection/eval.py#L48 . Accroding to detection/settings.py, TEST_NUM_GPU = 2, it will use 2 GPUs. Why your code use only 1 GPU? Did git diff indicates that there is no change?

yuantailing commented 5 years ago

And output filename is determined in https://github.com/yuantailing/ctw-baseline/blob/master/detection/eval.py#L30 , the number is formatted to string by '.{}'.format(split_id), why your .txt has a leading "0"?

Sesefad0u commented 5 years ago

But I print it and it just output" chinese.0.data", and it's correct . I download a new from your github and it's output is chinese.00.txt , too.

Sesefad0u commented 5 years ago

And we found there are no cate_id in chinese.xx.txt,what should i do ?Thanks

yuantailing commented 5 years ago

According to https://github.com/yuantailing/darknet/commit/fe0a91a439894f0f787c27bc7910b9b0179d3a2e#diff-265d49678e2dbc64f1aeb120e056f2bfR176 , cate_id should be the first number in each line.

Did you clone the right version of darknet? It is defined in https://github.com/yuantailing/ctw-baseline/blob/master/.gitmodules (clone from yuantailing/darknet and switch to branch ctw).

Sesefad0u commented 5 years ago

The Eorrr is in https://github.com/yuantailing/ctw-baseline/blob/f7b3467fa5814fac39f2ec68d9df54273537b9f7/detection/merge_results.py#L44 (file_path, cate_id, x, y, w, h, prob = line.split()) and the text is 3045513_2_1_1 0.012630 95.435127 23.111725 150.123352 120.032806 in chinese.xx.txt

yuantailing commented 5 years ago

It seems you are using a wrong version of darknet.

Sesefad0u commented 5 years ago

I use the darknet in your github ...

yuantailing commented 5 years ago

But, why no cate_id ... Could you run to this line?

https://github.com/yuantailing/darknet/blob/ctw/examples/detector.c#L176

(commit id is 801409731a46b072b8ee11f6f2acfa29cb16f165: https://github.com/yuantailing/darknet/blob/801409731a46b072b8ee11f6f2acfa29cb16f165/examples/detector.c#L176 )

Sesefad0u commented 5 years ago

It can't