Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SAM. #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add SAM. #115

wants to merge 1 commit into from

Conversation

Silver0930
Copy link

No description provided.

Clone the repository locally and install with

```shell
git clone https://github.com/Mark-ZhouWX/models.git
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

链接改掉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

链接改掉

done

## Installation

The code requires `python>=3.7` and supports Ascend platform, some important pre-dependencies is:
1. mindspore: Please follow the instructions [here](https://www.mindspore.cn/install) to install mindspore dependencies.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

版本信息用表格呈现:

MindSPore CANN Mindformers
2.3.1 version version

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

版本信息用表格呈现:

MindSPore CANN Mindformers
2.3.1 version version

done


| pretrained_model | dataset | epochs | mIOU | ckpt |
|:----------------:| -------- |:-------------:|------|--------------------------------------------------------------------------------------------------------------|
| sam-vit-b | COCO2017 | 0 (zero-shot) | 74.5 | |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zero shot的ckpt有吗

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zero shot的ckpt有吗

有,还没上传

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zero shot的ckpt有吗

有,还没上传
已更新


for distributed finetune of COCO dataset, please run:
```shell
msrun --worker_num=8 --local_worker_num=8 train.py -c configs/coco_box_finetune.yaml -o amp_level=O2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成msrun的

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成msrun的

已经是msrun了呀


for distributed finetune, please run:
```shell
msrun --worker_num=8 --local_worker_num=8 train.py -c configs/sa1b_text_finetune_blip2.yaml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

msrun

pycocotools
opencv-python
omegaconf==2.0.0
mindformers=1.0.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个最好配套mindspore装

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个最好配套mindspore装

done

python demo/inference_with_amg.py --model-type vit_h
```

See `python demo/inference_with_amg.py --help` to explore more custom settings.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lite推理的代码有但是readme没有体现

python text_inference.py --checkpoint=your/path/to/ckpt --text-prompt your_prompt
```

## Demo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

demo放finetune前面吧

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

demo放finetune前面吧

done

@@ -0,0 +1,12 @@
def create_group_param(params, **kwargs):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it if not use

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it if not use
AdmW 类需要用到此方法


def main(args) -> None:
# Step1: initialize environment
ms.context.set_context(mode=args.mode, device_target=args.device, pynative_synchronize=True, max_device_memory="50GB")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why set pynative_synchronize=True? isn't it mainly for debug?
why limite max_device_memory to 50GB?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why set pynative_synchronize=True? isn't it mainly for debug? why limite max_device_memory to 50GB?

pynative_synchronize=True 是之前测过pynative没有删掉,这个我去掉
max_device_memory=50GB,是之前如果不限制会报OOM,我再测下去掉还会不会oom

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why set pynative_synchronize=True? isn't it mainly for debug? why limite max_device_memory to 50GB?

已更新

Copy link

@SamitHuang SamitHuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor reject


## Installation

The code supports Ascend platform, some important pre-dependencies is:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are
Here are some important dependency


| model name | cards | batch size | graph compile | recompute | sink | jit level | s/step | img/s |
|:----------:| :---: | :--------: | :-----------: | :-------: | :---: | :------: | :----: | :---: |
| sam-vit-b finetune on COCO2017 | 1 | 16 | 3~4 mins | OFF | ON | O2 | 2.59 | 6.18 |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better add a dataset column instead of writing the dataset name in model_name column


## Installation

The code supports Ascend platform, some important pre-dependencies is:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. fix grammar


| mindspore-lite | mindspore | ascend driver | firmware | cann tookit/kernel |
| :------------: | :-------: | :-----------: | :------: | :----------------: |
| 2.3.1 | 2.3.1 | Same as Finetune | Same as Finetune | Same as Finetune |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as Finetune?
use hyperlink or simply specify the version code


| model name | s/img |
|:----------:| :---: |
| sam-vit-b finetune on COCO2017 | 5.35 |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.
or finetuned on xxx


predictor = SamPredictor(sam)

image = cv2.imread('https://github.com/user-attachments/assets/022bd54a-4e28-4c22-82d4-45113bbe49ee')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow setting input image via argparser, same as lite inference --image_path

# image_npnew = cv2.imread('./images/tumor1.png')/255.0 # (1024, 1024, 3)
# diff = image_npnew - image_np

points_np = np.array([[[868, 622]], [[724, 466]], [[501, 543]], [[565, 505]], [[262, 456]]]) # (bp, n, 2), in [w, h]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this point prompt bound with images/tumor1.png?
what if user change image_path to another image?
better allow setting point prompt via argparser too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants