Skip to content

Commit

Permalink
Merge pull request IDEA-Research#108 from Andy1621/lkc/develop
Browse files Browse the repository at this point in the history
add chatbot, wait to check ChatGPT
  • Loading branch information
rentainhe authored Apr 13, 2023
2 parents 905fb4f + b6a0fa4 commit 22aee1d
Show file tree
Hide file tree
Showing 7 changed files with 1,483 additions and 17 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ The **core idea** behind this project is to **combine the strengths of different

**BLIP + Grounded-SAM: Automatic Label System!**

Using BLIP to generate caption, extract tags and using Grounded-SAM for box and mask generating. Here's the demo output:
Using BLIP to generate caption, extracting tags with ChatGPT, and using Grounded-SAM for box and mask generating. Here's the demo output:

![](./assets/automatic_label_output_demo3.jpg)

**ChatBot**
![](./assets/chatbot_demo.png)


**Imagine Space**

Expand Down Expand Up @@ -306,6 +309,24 @@ python grounded_sam_whisper_inpainting_demo.py \

![](./assets/acoustics/gsam_whisper_inpainting_pipeline.png)

## :speech_balloon: Run ChatBot Demo
Following [Visual ChatGPT](https://github.com/microsoft/visual-chatgpt), we add a ChatBot for our project. Currently, it supports:
1. "Descripe the image."
2. "Detect the dog (and the cat) in the image."
3. "Segment anything in the image."
4. "Segment the dog (and the cat) in the image."
5. "Help me label the image."
6. "Replace the dog with a cat in the image."

To use the ChatBot:
- Install whisper if you want to use audio as input.
- Set the default model setting in the tool `Grounded_dino_sam_inpainting`.
- Run Demo
```bash
export CUDA_VISIBLE_DEVICES=0
python chatbot.py
```


## :cupid: Acknowledgements
- [Segment Anything](https://github.com/facebookresearch/segment-anything)
Expand Down
Binary file added assets/chatbot_demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions automatic_label_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ def save_mask_data(output_dir, caption, mask_list, box_list, label_list):
)

# initialize SAM
sam = build_sam(checkpoint=sam_checkpoint)
sam.to(device=device)
predictor = SamPredictor(sam)
predictor = SamPredictor(build_sam(checkpoint=sam_checkpoint).to(device))
image = cv2.imread(image_path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
predictor.set_image(image)
Expand All @@ -293,7 +291,7 @@ def save_mask_data(output_dir, caption, mask_list, box_list, label_list):
masks, _, _ = predictor.predict_torch(
point_coords = None,
point_labels = None,
boxes = transformed_boxes,
boxes = transformed_boxes.to(device),
multimask_output = False,
)

Expand Down
1,453 changes: 1,453 additions & 0 deletions chatbot.py

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions grounded_sam_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ def save_mask_data(output_dir, mask_list, box_list, label_list):
)

# initialize SAM
sam = build_sam(checkpoint=sam_checkpoint)
sam.to(device=device)
predictor = SamPredictor(sam)
predictor = SamPredictor(build_sam(checkpoint=sam_checkpoint).to(device))
image = cv2.imread(image_path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
predictor.set_image(image)
Expand All @@ -197,7 +195,7 @@ def save_mask_data(output_dir, mask_list, box_list, label_list):
masks, _, _ = predictor.predict_torch(
point_coords = None,
point_labels = None,
boxes = transformed_boxes,
boxes = transformed_boxes.to(device),
multimask_output = False,
)

Expand Down
6 changes: 2 additions & 4 deletions grounded_sam_inpainting_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ def show_box(box, ax, label):
)

# initialize SAM
sam = build_sam(checkpoint=sam_checkpoint)
sam.to(device=device)
predictor = SamPredictor(sam)
predictor = SamPredictor(build_sam(checkpoint=sam_checkpoint).to(device))
image = cv2.imread(image_path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
predictor.set_image(image)
Expand All @@ -178,7 +176,7 @@ def show_box(box, ax, label):
masks, _, _ = predictor.predict_torch(
point_coords = None,
point_labels = None,
boxes = transformed_boxes,
boxes = transformed_boxes.to(device),
multimask_output = False,
)

Expand Down
6 changes: 2 additions & 4 deletions grounded_sam_whisper_inpainting_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ def filter_prompts_with_chatgpt(caption, max_tokens=100, model="gpt-3.5-turbo"):
)

# initialize SAM
sam = build_sam(checkpoint=sam_checkpoint)
sam.to(device=device)
predictor = SamPredictor(sam)
predictor = SamPredictor(build_sam(checkpoint=sam_checkpoint).to(device))
image = cv2.imread(image_path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
predictor.set_image(image)
Expand All @@ -247,7 +245,7 @@ def filter_prompts_with_chatgpt(caption, max_tokens=100, model="gpt-3.5-turbo"):
masks, _, _ = predictor.predict_torch(
point_coords = None,
point_labels = None,
boxes = transformed_boxes,
boxes = transformed_boxes.to(device),
multimask_output = False,
)

Expand Down

0 comments on commit 22aee1d

Please sign in to comment.