Ikomia-hub / train_mmlab_detection

https://ikomia.com
Apache License 2.0
10 stars 1 forks source link

I am trying to run a custom trained algorithm on colab using your guide #2

Open saadyousuf45 opened 6 months ago

saadyousuf45 commented 6 months ago

The error that I am getting: demo.jpg: 100%|██████████| 254k/254k [00:00<00:00, 6.03MiB/s] Exception ignored in: <function _TemporaryFileCloser.del at 0x798c05ed2710> Traceback (most recent call last): File "/usr/lib/python3.10/tempfile.py", line 589, in del self.close() File "/usr/lib/python3.10/tempfile.py", line 585, in close unlink(self.name) FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpw_1fojgb/tmpuaftg5q6.py'

Code that I am using: from ikomia.dataprocess.workflow import Workflow

Init your workflow

wf = Workflow()

Add object detection algorithm

detector = wf.add_task(name="infer_mmlab_detection", auto_connect=True)

Set parameters

detector.set_parameters({ "model_name": "deformable_detr", "model_config": "deformable-detr_refine_twostage_r50_16xb2-50e_coco", "use_custom_model" : "True", "model_weight_file":"/content/drive/MyDrive/Colab Notebooks/Final thesis implementation/trainings_HPC/DETR_deform/epoch_50.pth", "config_file":"/content/drive/MyDrive/Colab Notebooks/Final thesis implementation/deformable_detr_twostage_refine_r50_16x2_50e_coco.py", "conf_thres": "0.4", })

Run the workflow on image

wf.run_on(url="https://github.com/open-mmlab/mmdetection/blob/main/demo/demo.jpg?raw=true")

Get the results

image_output = detector.get_output(0) detection_output = detector.get_output(1)

saadyousuf45 commented 6 months ago

RuntimeError: <class 'FileNotFoundError'>: file "/content/drive/MyDrive/Colab Notebooks/base/datasets/coco_detection.py" does not exist: File "/root/Ikomia/Plugins/Python/infer_mmlab_detection/infer_mmlab_detection_process.py", line 114, in run self.model = DetInferencer(cfg_file, ckpt_file, device='cuda:0' if param.cuda and cuda_available else 'cpu')

File "/usr/local/lib/python3.10/dist-packages/mmdet/apis/det_inferencer.py", line 95, in init super().init(

File "/usr/local/lib/python3.10/dist-packages/mmengine/infer/infer.py", line 152, in init cfg = Config.fromfile(model)

File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 177, in fromfile cfg_dict, cfg_text, env_variables = Config._file2dict(

File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 481, in _file2dict _cfg_dict, _cfg_text, _env_variables = Config._file2dict(

File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 449, in _file2dict check_file_exist(filename)

File "/usr/local/lib/python3.10/dist-packages/mmengine/utils/path.py", line 23, in check_file_exist raise FileNotFoundError(msg_tmpl.format(filename)) (Code 18)

saadyousuf45 commented 6 months ago

I removed the base in the cofig file however now I get this error. RuntimeError: <class 'AssertionError'>: class DeformableDETR in mmdet/models/detectors/deformable_detr.py: The two keyword args share_pred_layer, num_pred_layer, and as_two_stage are set indetector.init(), users should not set them inbbox_head` config.: File "/root/Ikomia/Plugins/Python/infer_mmlab_detection/infer_mmlab_detection_process.py", line 114, in run self.model = DetInferencer(cfg_file, ckpt_file, device='cuda:0' if param.cuda and cuda_available else 'cpu')

File "/usr/local/lib/python3.10/dist-packages/mmdet/apis/det_inferencer.py", line 95, in init super().init(

File "/usr/local/lib/python3.10/dist-packages/mmengine/infer/infer.py", line 176, in init self.model = self._init_model(cfg, weights, device) # type: ignore

File "/usr/local/lib/python3.10/dist-packages/mmengine/infer/infer.py", line 477, in _init_model model = MODELS.build(cfg.model)

File "/usr/local/lib/python3.10/dist-packages/mmengine/registry/registry.py", line 545, in build return self.build_func(cfg, *args, **kwargs, registry=self)

File "/usr/local/lib/python3.10/dist-packages/mmengine/registry/build_functions.py", line 241, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args)

File "/usr/local/lib/python3.10/dist-packages/mmengine/registry/build_functions.py", line 135, in build_from_cfg raise type(e)( (Code 18)

saadyousuf45 commented 6 months ago

Anyone