Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom_prediction.json file size is too large #184

Open
greeksharifa opened this issue Sep 19, 2022 · 4 comments
Open

custom_prediction.json file size is too large #184

greeksharifa opened this issue Sep 19, 2022 · 4 comments

Comments

@greeksharifa
Copy link

greeksharifa commented Sep 19, 2022

❓ Questions and Help

During running in custom dataset...
I got the error:

INIT SAVE DIR checkpoints/causal-motifs-sgdet
get_checkpoint_file checkpoints/causal-motifs-sgdet/last_checkpoint
last_saved checkpoints/causal-motifs-sgdet/model_0028000.pth
2022-09-13 19:49:41,654 maskrcnn_benchmark.utils.checkpoint INFO: Loading checkpoint from checkpoints/causal-motifs-sgdet/model_0028000.pth
100%|████████████████████████████████████████████████████████████████████████████████| 12195/12195 [03:49<00:00, 53.16it/s]
=====> output_dir/01/custom_data_info.json SAVED !
2022-09-13 19:53:50,023 maskrcnn_benchmark.inference INFO: Start evaluation on VG_stanford_filtered_with_attribute_test dataset(12195 images).
100%|██████████████████████████████████████████████████████████████████████████████| 12195/12195 [2:32:32<00:00,  1.33it/s]
2022-09-13 22:26:23,093 maskrcnn_benchmark.inference INFO: Total run time: 2:32:33.070335 (0.750559273055461 s / img per device, on 1 devices)
2022-09-13 22:26:23,093 maskrcnn_benchmark.inference INFO: Model inference time: 2:32:03.855223 (0.7481636098976652 s / img per device, on 1 devices)
Traceback (most recent call last):
  File "/home/ywjang/miniconda3/envs/usgg/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/ywjang/miniconda3/envs/usgg/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/ywjang/miniconda3/envs/usgg/lib/python3.7/site-packages/torch/distributed/launch.py", line 263, in <module>
    main()
  File "/home/ywjang/miniconda3/envs/usgg/lib/python3.7/site-packages/torch/distributed/launch.py", line 259, in main
    cmd=cmd)
subprocess.CalledProcessError: Command '['/home/ywjang/miniconda3/envs/usgg/bin/python', '-u', 'tools/relation_test_net.py', '--local_rank=0', '--config-file', 'configs/e2e_relation_X_101_32_8_FPN_1x.yaml', 'MODEL.ROI_RELATION_HEAD.USE_GT_BOX', 'False', 'MODEL.ROI_RELATION_HEAD.USE_GT_OBJECT_LABEL', 'False', 'MODEL.ROI_RELATION_HEAD.PREDICTOR', 'CausalAnalysisPredictor', 'MODEL.ROI_RELATION_HEAD.CAUSAL.EFFECT_TYPE', 'TDE', 'MODEL.ROI_RELATION_HEAD.CAUSAL.FUSION_TYPE', 'sum', 'MODEL.ROI_RELATION_HEAD.CAUSAL.CONTEXT_LAYER', 'motifs', 'TEST.IMS_PER_BATCH', '1', 'DTYPE', 'float16', 'GLOVE_DIR', '/data/glove', 'MODEL.PRETRAINED_DETECTOR_CKPT', 'checkpoints/causal-motifs-sgdet', 'OUTPUT_DIR', 'checkpoints/causal-motifs-sgdet', 'TEST.CUSTUM_EVAL', 'True', 'TEST.CUSTUM_PATH', '/data/AnotherMissOh/images_per_episode/01/', 'DETECTED_SGG_DIR', 'output_dir/01/']' died with <Signals.SIGKILL: 9>.

It died with <Signals.SIGKILL: 9>.

So, I run the tools/relation_test_net.py in only 10 images, it successfully executed, but the output file is too big:

ls output_dir/images_10/ -hl
total 60M
-rw-r--r-- 1 root root 2.5K  9월 12 16:50 custom_data_info.json
-rw-r--r-- 1 root root  60M  9월 12 16:51 custom_prediction.json

6 Megabytes per 1 image...

What's the problem?
Should I edit some config files? where or what?

Thanks.

@farahFif
Copy link

Hi, @greeksharifa did you find a solution for this ?

@greeksharifa
Copy link
Author

Hi, @greeksharifa did you find a solution for this ?

No, I didn't.

@farahFif
Copy link

farahFif commented Feb 1, 2023

My solution was to change json with PICKLE , it reduced the size from 29MB to 12MB for 4 images. I think it still big but this is due to the large number of objects stored. Try to play with maskrcnn_benchmark/engine/inference.py and reduce bbx or delete structures you don't need.

@mamadkhaleghi
Copy link

mamadkhaleghi commented May 16, 2024

consider setting the "`MODEL.ROI_HEADS.DETECTIONS_PER_IMG" into an smaller value in your command

(default is 80 in "configs/e2e_relation_X_101_32_8_FPN_1x.yaml" file)

it will considerably shrink the size of the output "custom_prediction.json" file

but be aware that the size of "custom_prediction.json" file is dependent on the number of images existing in your "DETECTED_SGG_DIR" directory, so you might need to exclude some of your images from this directory and put them in another one and try to generate scene graphs from them with another command!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants