From 9dac4c605b40d87d82bfff5961467556f4d381a9 Mon Sep 17 00:00:00 2001 From: Shilong Liu <34858619+SlongLiu@users.noreply.github.com> Date: Sun, 9 Apr 2023 22:08:36 +0800 Subject: [PATCH] fix windows bugs (#30) --- README.md | 30 ++++++++++++++++++------------ groundingdino/util/slconfig.py | 3 +++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index de1e809..a7a4ec5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Grounding DINO +# :sauropod: Grounding DINO --- @@ -28,7 +28,7 @@ Extensions | [Grounding DINO with Segment Anything](https://github.com/IDEA-Rese Official PyTorch implementation of [Grounding DINO](https://arxiv.org/abs/2303.05499), a stronger open-set object detector. Code is available now! -## Highlight +## :bulb: Highlight - **Open-Set Detection.** Detect **everything** with language! - **High Performancce.** COCO zero-shot **52.5 AP** (training without COCO data!). COCO fine-tune **63.0 AP**. @@ -37,10 +37,10 @@ Official PyTorch implementation of [Grounding DINO](https://arxiv.org/abs/2303.0 -## News +## :fire: News - **`2023/04/08`**: We release [demos](demo/image_editing_with_groundingdino_gligen.ipynb) to combine [Grounding DINO](https://arxiv.org/abs/2303.05499) with [GLIGEN](https://github.com/gligen/GLIGEN) for more controllable image editings. - **`2023/04/08`**: We release [demos](demo/image_editing_with_groundingdino_stablediffusion.ipynb) to combine [Grounding DINO](https://arxiv.org/abs/2303.05499) with [Stable Diffusion](https://github.com/Stability-AI/StableDiffusion) for image editings. -- **`2023/04/06`**: We build a new demo by marrying GroundingDINO with [Segment-Anything](https://github.com/facebookresearch/segment-anything) named [Grounded-Segment-Anything](https://github.com/IDEA-Research/Grounded-Segment-Anything) aims to support segmentation in GroundingDINO. +- **`2023/04/06`**: We build a new demo by marrying GroundingDINO with [Segment-Anything](https://github.com/facebookresearch/segment-anything) named **[Grounded-Segment-Anything](https://github.com/IDEA-Research/Grounded-Segment-Anything)** aims to support segmentation in GroundingDINO. - **`2023/03/28`**: A YouTube [video](https://youtu.be/cMa77r3YrDk) about Grounding DINO and basic object detection prompt engineering. [[SkalskiP](https://github.com/SkalskiP)] - **`2023/03/28`**: Add a [demo](https://huggingface.co/spaces/ShilongLiu/Grounding_DINO_demo) on Hugging Face Space! - **`2023/03/27`**: Support CPU-only mode. Now the model can run on machines without GPUs. @@ -59,14 +59,14 @@ Marrying Grounding DINO -## TODO +## :label: TODO - [x] Release inference code and demo. - [x] Release checkpoints. - [x] Grounding DINO with Stable Diffusion and GLIGEN demos. - [ ] Release training codes. -## Install +## :hammer_and_wrench: Install If you have a CUDA environment, please make sure the environment variable `CUDA_HOME` is set. It will be compiled under CPU-only mode if no CUDA available. @@ -74,7 +74,7 @@ If you have a CUDA environment, please make sure the environment variable `CUDA_ pip install -e . ``` -## Demo +## :arrow_forward: Demo ```bash CUDA_VISIBLE_DEVICES=6 python demo/inference_on_a_image.py \ @@ -91,7 +91,13 @@ See the `demo/inference_on_a_image.py` for more details. We also provide a demo code to integrate Grounding DINO with Gradio Web UI. See the file `demo/gradio_app.py` for more details. -## Checkpoints +**Notebooks** + +- We release [demos](demo/image_editing_with_groundingdino_gligen.ipynb) to combine [Grounding DINO](https://arxiv.org/abs/2303.05499) with [GLIGEN](https://github.com/gligen/GLIGEN) for more controllable image editings. +- We release [demos](demo/image_editing_with_groundingdino_stablediffusion.ipynb) to combine [Grounding DINO](https://arxiv.org/abs/2303.05499) with [Stable Diffusion](https://github.com/Stability-AI/StableDiffusion) for image editings. + + +## :luggage: Checkpoints @@ -128,7 +134,7 @@ We also provide a demo code to integrate Grounding DINO with Gradio Web UI. See
-## Results +## :medal_military: Results
@@ -161,14 +167,14 @@ See our example
-## Model +## :sauropod: Model: Grounding DINO Includes: a text backbone, an image backbone, a feature enhancer, a language-guided query selection, and a cross-modality decoder. ![arch](.asset/arch.png) -## Acknowledgement +## :hearts: Acknowledgement Our model is related to [DINO](https://github.com/IDEA-Research/DINO) and [GLIP](https://github.com/microsoft/GLIP). Thanks for their great work! @@ -177,7 +183,7 @@ We also thank great previous work including DETR, Deformable DETR, SMCA, Conditi Thanks [Stable Diffusion](https://github.com/Stability-AI/StableDiffusion) and [GLIGEN](https://github.com/gligen/GLIGEN) for their awesome models. -## Citation +## :black_nib: Citation If you find our work helpful for your research, please consider citing the following BibTeX entry. diff --git a/groundingdino/util/slconfig.py b/groundingdino/util/slconfig.py index 0d84a4c..672e72e 100644 --- a/groundingdino/util/slconfig.py +++ b/groundingdino/util/slconfig.py @@ -2,6 +2,7 @@ # Modified from mmcv # ========================================================== import ast +import os import os.path as osp import shutil import sys @@ -80,6 +81,8 @@ class SLConfig(object): with tempfile.TemporaryDirectory() as temp_config_dir: temp_config_file = tempfile.NamedTemporaryFile(dir=temp_config_dir, suffix=".py") temp_config_name = osp.basename(temp_config_file.name) + if os.name == 'nt': + temp_config_file.close() shutil.copyfile(filename, osp.join(temp_config_dir, temp_config_name)) temp_module_name = osp.splitext(temp_config_name)[0] sys.path.insert(0, temp_config_dir)