DS4SD / MolGrapher

MolGrapher: Graph-based Visual Recognition of Chemical Structures
https://arxiv.org/abs/2308.12234
MIT License
42 stars 1 forks source link

TypeError: cannot pickle 'paddle.base.libpaddle.PaddleInferPredictor' object #3

Closed sharingan000 closed 5 months ago

sharingan000 commented 8 months ago

Hi, dear developers!

Thank you very much for code sharing! Following step-by-step instruction from you readme file tend me to the following issue :

CEDe not imported: No module named 'annotator.labeled_data_utils' Arguments: {'align_rdkit_output': False, 'assign_stereo': False, 'chunk_size': 10000, 'config_dataset_graph_path': '/Users/danil/НТО/AI_HACK/MolGrapher/molgrapher/scripts/annotate/../../../data/config_dataset_graph_2.json', 'config_dataset_keypoint_path': '/Users/danil/НТО/AI_HACK/MolGrapher/molgrapher/scripts/annotate/../../../data/config_dataset_keypoint.json', 'config_training_graph_path': '/Users/danil/НТО/AI_HACK/MolGrapher/molgrapher/scripts/annotate/../../../data/config_training_graph.json', 'config_training_keypoint_path': '/Users/danil/НТО/AI_HACK/MolGrapher/molgrapher/scripts/annotate/../../../data/config_training_keypoint.json', 'force_cpu': False, 'input_images_paths': '/Users/danil/НТО/AI_HACK/MolGrapher/molgrapher/scripts/annotate/input_images_paths_default.jsonl', 'num_processes_mp': 10, 'num_threads_pytorch': 10, 'remove_captions': True, 'save_mol_folder': '/Users/danil/НТО/AI_HACK/MolGrapher/molgrapher/scripts/annotate/../../../data/predictions/molgrapher/default/'} Number of images to annotate: 1 PyTorch device: cpu Data module configuration: {'batch_size': 4, 'benchmarks': ['uspto-10k', 'uspto-10k-abb', 'uspto-10k-l'], 'experiment_name': 'exp-default', 'image_size': [3, 1024, 1024], 'nb_atoms_classes': 182, 'nb_bonds_classes': 6, 'nb_duplicates': 1, 'nb_sample': 1000, 'nb_sample_benchmarks': [10, 10, 10], 'nb_sample_fine-tuning': 10000, 'nb_workers': 4, 'num_processes_mp': 10, 'num_threads_pytorch': 10, 'on_fly': False, 'training_dataset': 'molgrapher-synthetic', 'training_dataset_fine-tuning': 'uspto-10k'} Starting Caption Removal Preprocessing 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:01<00:00, 1.32s/it] Caption Removal Preprocessing completed in 1.84 Lightning automatically upgraded your loaded checkpoint from v1.8.1 to v2.1.3. To apply the upgrade to your files permanently, runpython -m pytorch_lightning.utilities.upgrade_checkpoint data/models/keypoint_detector/kd_model.ckpt /Users/danil/НТО/AI_HACK/MolGrapher/molgrapher/models/../../data/models/graph_classifier/gc_no_stereo_model.ckpt /Users/danil/НТО/AI_HACK/MolGrapher/molgrapher/models/../../data/models/keypoint_detector/kd_model.ckpt Lightning automatically upgraded your loaded checkpoint from v1.8.1 to v2.1.3. To apply the upgrade to your files permanently, runpython -m pytorch_lightning.utilities.upgrade_checkpoint data/models/graph_classifier/gc_no_stereo_model.ckpt Keypoint detector number parameters: 12.8722 M Node classifier number parameters: 26.6585 M GPU available: True (mps), used: False TPU available: False, using: 0 TPU cores IPU available: False, using: 0 IPUs HPU available: False, using: 0 HPUs Starting Keypoint Detection + Node Classification Setting up predict dataloader Real benchmarks sets lengths (on-the-fly validation): [1] Number of predict sets: 1 Traceback (most recent call last): File "/Users/danil/НТО/AI_HACK/MolGrapher/molgrapher/scripts/annotate/predict_molgrapher.py", line 330, in <module> main() File "/Users/danil/НТО/AI_HACK/MolGrapher/molgrapher/scripts/annotate/predict_molgrapher.py", line 326, in main proceed_batch(args, _batch_images_paths) File "/Users/danil/НТО/AI_HACK/MolGrapher/molgrapher/scripts/annotate/predict_molgrapher.py", line 126, in proceed_batch predictions_out = trainer.predict(model, dataloaders=data_module.predict_dataloader()) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 864, in predict return call._call_and_handle_interrupt( File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/trainer/call.py", line 44, in _call_and_handle_interrupt return trainer_fn(*args, **kwargs) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 903, in _predict_impl results = self._run(model, ckpt_path=ckpt_path) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 989, in _run results = self._run_stage() File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1030, in _run_stage return self.predict_loop.run() File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/loops/utilities.py", line 182, in _decorator return loop_run(self, *args, **kwargs) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/loops/prediction_loop.py", line 105, in run self.reset() File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/loops/prediction_loop.py", line 179, in reset iter(data_fetcher) # creates the iterator inside the fetcher File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/loops/fetchers.py", line 99, in __iter__ super().__iter__() File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/loops/fetchers.py", line 48, in __iter__ self.iterator = iter(self.combined_loader) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/utilities/combined_loader.py", line 335, in __iter__ iter(iterator) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/utilities/combined_loader.py", line 144, in __iter__ self._load_current_iterator() File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/pytorch_lightning/utilities/combined_loader.py", line 160, in _load_current_iterator self.iterators = [iter(self.iterables[self._iterator_idx])] File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 433, in __iter__ self._iterator = self._get_iterator() File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 386, in _get_iterator return _MultiProcessingDataLoaderIter(self) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 1039, in __init__ w.start() File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/multiprocessing/process.py", line 121, in start self._popen = self._Popen(self) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/multiprocessing/context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/multiprocessing/context.py", line 284, in _Popen return Popen(process_obj) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 32, in __init__ super().__init__(process_obj) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/multiprocessing/popen_fork.py", line 19, in __init__ self._launch(process_obj) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 47, in _launch reduction.dump(process_obj, fp) File "/Users/danil/anaconda3/envs/molgrapher/lib/python3.9/multiprocessing/reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) TypeError: cannot pickle 'paddle.base.libpaddle.PaddleInferPredictor' object

Please help to solve this problem

lucas-morin commented 8 months ago

Hello,

Did you install PaddleOCR on CPU using the following command ? bash install_paddleocr.sh -d 'cpu' Or on GPU ?

Best, Lucas

sharingan000 commented 8 months ago

Hello,

Did you install PaddleOCR on CPU using the following command ?

bash install_paddleocr.sh -d 'cpu'

Or on GPU ?

Best,

Lucas

Yes, i have install PaddleOCR on cpu OS: Mac OS But i have install torch==1.13.1, not 1.13.1+cu117, because i had mistake

And can you help with docker for that project to run on the server:)

sharingan000 commented 8 months ago

Best

And i installed PaddleOCR to /MolGrapher

lucas-morin commented 8 months ago

Hello,

Here you can find how to install PaddleOCR (cpu) for Mac M1: https://github.com/DS4SD/MolGrapher/blob/282615be8b0343c9d63f35be456d4469ce6f6a10/install_paddleocr.sh#L17

If it does not work, you may need to read instructions directly on the PaddleOCR repository. (I am not a Mac user myself.)

I just added an example Dockerfile. You can run it with scripts bash docker_build.sh and bash docker_run.sh.

Hopefully it can help, Best,

Lucas

sharingan000 commented 8 months ago

Thank you very much, I will test that