giovannipasq / da-faster-rcnn Goto Github PK
View Code? Open in Web Editor NEWDetectron2 implementation of DA-Faster R-CNN, Domain Adaptive Faster R-CNN for Object Detection in the Wild
License: MIT License
Detectron2 implementation of DA-Faster R-CNN, Domain Adaptive Faster R-CNN for Object Detection in the Wild
License: MIT License
Hello author! Thanks for the code! If I want to implement the "source-only" item in the experimental table of the original paper, how should I modify the uda_train.py file of this code?
i am getting error like this ,please explain why ?
Traceback (most recent call last):
File "/mnt/d/adaptive_2/uda.py", line 130, in
do_train(cfg_source,cfg_target,model)
File "/mnt/d/adaptive_2/uda.py", line 74, in do_train
loss_dict = model(data_source, False, 0.5)
File "/home/mouli41/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
TypeError: GeneralizedRCNN.forward() takes 2 positional arguments but 4 were given
Hello
I used the model for my own dataset but every time I run the code , I've got different APs Percent.
I want to ask you about this problem.
Hello
I use your model and code for my own dataset, but when I trained that I've got this error :
RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with TORCH_USE_CUDA_DSA
to enable device-side assertions.
Hi
How can we display the results of the algorithm visually?
That is, after running the algorithm on my dataset, I want to see the results that include the binding boxes
hello again
I want to run it on my own data set and after putting the data set in my drive and addressing it correctly, it gives the following error code:"
FileNotFoundError: Caught FileNotFoundError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop
data = fetcher.fetch(index)
File "/usr/local/lib/python3.10/dist-packages/torch/utils/data/_utils/fetch.py", line 32, in fetch
data.append(next(self.dataset_iter))
File "/usr/local/lib/python3.10/dist-packages/detectron2/data/common.py", line 296, in iter
yield self.dataset[idx]
File "/usr/local/lib/python3.10/dist-packages/detectron2/data/common.py", line 125, in getitem
data = self._map_func(self._dataset[cur_idx])
File "/usr/local/lib/python3.10/dist-packages/detectron2/utils/serialize.py", line 26, in call
return self._obj(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/detectron2/data/dataset_mapper.py", line 154, in call
image = utils.read_image(dataset_dict["file_name"], format=self.image_format)
File "/usr/local/lib/python3.10/dist-packages/detectron2/data/detection_utils.py", line 180, in read_image
with PathManager.open(file_name, "rb") as f:
File "/usr/local/lib/python3.10/dist-packages/iopath/common/file_io.py", line 1012, in open
bret = handler._open(path, mode, buffering=buffering, **kwargs) # type: ignore
File "/usr/local/lib/python3.10/dist-packages/iopath/common/file_io.py", line 604, in _open
return open( # type: ignore
FileNotFoundError: [Errno 2] No such file or directory: 'content/drive/MyDrive/PRJ/students_prj_ship_train_val_test_dataset/students_ship_train_images/DCS_115_evening_rainy_180.jpg'"
by running this line:"do_train(cfg_source,cfg_target,model)" I downloaded rcnn.py and roi.head files from your Github and deleted that files in the mentioned address and uploaded a downloaded file. I did the same for the rest of the steps.
I also registered the dataset correctly:"#This block is an example of how you should use this API
register_coco_instances("dataset1_train_synthetic", {}, "/content/drive/MyDrive/PRJ/students_prj_ship_train_val_test_dataset/Train_in_coco_format.json", "/content/drive/MyDrive/PRJ/students_prj_ship_train_val_test_dataset/students_ship_train_images")
register_coco_instances("dataset1_train_real", {}, "/content/drive/MyDrive/PRJ/students_prj_ship_train_val_test_dataset/_annotations.coco.json", "/content/drive/MyDrive/PRJ/students_prj_ship_train_val_test_dataset/train_target_coco")
register_coco_instances("dataset1_test_real", {}, "/content/drive/MyDrive/PRJ/students_prj_ship_train_val_test_dataset/test_coco_format.json", "/content/drive/MyDrive/PRJ/students_prj_ship_train_val_test_dataset/students_ship_test_dataset")"
Why does it give this error?
Hello. thanks for your work!
Can we use this model when we don't have a labels in the target domain?
Can I utilize the DA-Faster R-CNN model when there are no labels in the target domain? I came across a previous query on this topic. In response to that question, it was suggested to add the line cfg_target.DATALOADER.FILTER_EMPTY_ANNOTATIONS = False to the script, following the cfg_target.INPUT.MIN_SIZE_TRAIN = (600,) instruction.
Given this, I'm considering preparing two datasets:
Source domain: All images are labeled using the COCO JSON format. Target domain: 30% of the images have labels (in COCO JSON format), while 70% are unlabeled (no annotation file).
Source domain: All images are labeled using the COCO JSON format. Target domain: 100% of the images are unlabeled (no annotation file).
Is it possible to use both dataset configurations (1 and 2) with your API? Moreover, for the unlabeled data, should I still include this information in the COCO JSON (maybe it has no information of bounding box and class)?
Hello again
I wanted to ask you about how to optimize your model compared to the original model and what changes compared to the original source code that have improved the process.
Thank you
Any plan to add support for multi-gpu training? Thanks!
Thanks for your work!
When I train the model on my own dataset, I got the error 'TypeError: forward() takes 2 positional arguments but 4 were given' in 'torch/nn/modules/module.py'.
I just change the dataset root and did not change any other arguments.
I use only one GPU.
Would you help me?
Hello,
I have questions about the implementation of your work. I used custom dataset. I successfully train the model but when I tried to do test using the generated model, i have no error but the test accuracy is always 0. For testing i am using COCOEvaluator part. And also i tried to test with this code:
cfg_source = get_cfg()
cfg_source.merge_from_file(model_zoo.get_config_file("COCO-Detection/faster_rcnn_R_50_C4_1x.yaml"))
cfg_source.MODEL.WEIGHTS = os.path.join(cfg_source.OUTPUT_DIR, "C4_model_final.pth")
cfg_source.DATASETS.TEST = ("target_test",)
cfg_source.MODEL.ROI_HEADS.NUM_CLASSES = 1
cfg_source.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5
predictor = DefaultPredictor(cfg_source)
The result is same :(
Could you have the solution for the problem? And also what is your test accuracy for your own case?
Thank you in advance.
I tried to understand DA-Faster R-CNN, authors with your well-made code.
I did download your code, and replace detectron2 it yours.
I successfully train the model but when I tried to do test using the generated model, the following error occurs:
cfg_source = get_cfg()
cfg_source.merge_from_file(model_zoo.get_config_file("COCO-Detection/faster_rcnn_R_50_C4_1x.yaml"))
cfg_source.MODEL.WEIGHTS = os.path.join(cfg_source.OUTPUT_DIR, "model_final.pth")
cfg_source.DATASETS.TEST = ("target_test",)
cfg_source.MODEL.ROI_HEADS.NUM_CLASSES = 2
cfg_source.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5
predictor = DefaultPredictor(cfg_source)
AttributeError Traceback (most recent call last)
Cell In[17], line 13
10 cfg_source.MODEL.ROI_HEADS.NUM_CLASSES = 2
11 cfg_source.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5
---> 13 predictor = DefaultPredictor(cfg_source)
File ~/Desktop/Seunghyeon/DA-Faster R-CNN/detectron2/detectron2/engine/defaults.py:282, in DefaultPredictor.init(self, cfg)
280 def init(self, cfg):
281 self.cfg = cfg.clone() # cfg can be modified by model
--> 282 self.model = build_model(self.cfg)
283 self.model.eval()
284 if len(cfg.DATASETS.TEST):
File ~/Desktop/Seunghyeon/DA-Faster R-CNN/detectron2/detectron2/modeling/meta_arch/build.py:22, in build_model(cfg)
17 """
18 Build the whole model architecture, defined by cfg.MODEL.META_ARCHITECTURE
.
19 Note that it does not load any weights from cfg
.
20 """
21 meta_arch = cfg.MODEL.META_ARCHITECTURE
---> 22 model = META_ARCH_REGISTRY.get(meta_arch)(cfg)
23 model.to(torch.device(cfg.MODEL.DEVICE))
24 _log_api_usage("modeling.meta_arch." + meta_arch)
File ~/Desktop/Seunghyeon/DA-Faster R-CNN/detectron2/detectron2/config/config.py:190, in configurable..wrapped(self, *args, **kwargs)
188 if _called_with_cfg(*args, **kwargs):
189 explicit_args = _get_args_from_config(from_config_func, *args, **kwargs)
--> 190 init_func(self, **explicit_args)
191 else:
192 init_func(self, *args, **kwargs)
File ~/Desktop/Seunghyeon/DA-Faster R-CNN/detectron2/detectron2/modeling/meta_arch/rcnn.py:68, in GeneralizedRCNN.init(self, backbone, proposal_generator, roi_heads, pixel_mean, pixel_std, input_format, vis_period, model_weights)
66 self.backbone_name = "C4"
67 self.dim_in_feature_discriminator = 1024
---> 68 self.discriminator = Discriminator(self.dim_in_feature_discriminator)
70 self.input_format = input_format
71 self.vis_period = vis_period
File ~/Desktop/Seunghyeon/hanyang/lib/python3.10/site-packages/torch/nn/modules/module.py:1614, in Module.getattr(self, name)
1612 if name in modules:
1613 return modules[name]
-> 1614 raise AttributeError("'{}' object has no attribute '{}'".format(
1615 type(self).name, name))
AttributeError: 'GeneralizedRCNN' object has no attribute 'dim_in_feature_discriminator'
Can you give the guideline for solving this?
Ciao Giovanni,
first of all thanks for your work. It's very interesting to have this project ported to Pytorch 2.x!!
Mine is mainly a curiosity. I was having a look at the losses trend in the notebook and to me it seems that da instance loss and da image loss are decreasing very slowly if compared to the others.
Is this somehow expected?
How can we guarantee that the network is actually learning also the adaptation part?
Grazie
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.