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

以图搜图如何使用自己的模型 #234

Open
David1-git opened this issue Aug 28, 2023 · 13 comments
Open

以图搜图如何使用自己的模型 #234

David1-git opened this issue Aug 28, 2023 · 13 comments

Comments

@David1-git
Copy link


p_embed = (
pipe.input('src')
.flat_map('src', 'img_path', load_image)
.map('img_path', 'img', ops.image_decode())
.map('img', 'vec', ops.image_embedding.timm(model_name=MODEL, device=DEVICE))
)
现在我有一个行人重识别的模型,在这里我需要怎么样做,才能替换为自己的模型。非常期待您的回复,感谢!

@junjiejiangjjj
Copy link
Contributor

If you want to pass in the weights of a PyTorch model, you can pass it in as parameter: ops.image_embedding.timm(model_name=MODEL, device=DEVICE, checkpoint_path=YOUR_WEIGHTS_PATH)
If it contains PyTorch code, a new operator needs to be created.
https://towhee.readthedocs.io/en/latest/operator/usage.html#run-pipeline-with-named-operators
You can refer to this implementation
https://towhee.io/image-embedding/timm/raw/branch/main/timm_image.py

@David1-git
Copy link
Author

If you want to pass in the weights of a PyTorch model, you can pass it in as parameter: ops.image_embedding.timm(model_name=MODEL, device=DEVICE, checkpoint_path=YOUR_WEIGHTS_PATH) If it contains PyTorch code, a new operator needs to be created. https://towhee.readthedocs.io/en/latest/operator/usage.html#run-pipeline-with-named-operators You can refer to this implementation https://towhee.io/image-embedding/timm/raw/branch/main/timm_image.py

我可以使用timm库注册自己的模型吗

@David1-git
Copy link
Author

If you want to pass in the weights of a PyTorch model, you can pass it in as parameter: ops.image_embedding.timm(model_name=MODEL, device=DEVICE, checkpoint_path=YOUR_WEIGHTS_PATH) If it contains PyTorch code, a new operator needs to be created. https://towhee.readthedocs.io/en/latest/operator/usage.html#run-pipeline-with-named-operators You can refer to this implementation https://towhee.io/image-embedding/timm/raw/branch/main/timm_image.py

我想要替换掉以图搜图里的模型,使用自己的行人重识别模型。换句话说,我想让我的行人重识别模型可以像以图搜图项目那样部署在服务器上

@junjiejiangjjj
Copy link
Contributor

https://github.com/huggingface/pytorch-image-models/tree/main/timm/models
Can you find the model you are using there? If so, you can use timm.

@David1-git
Copy link
Author

https://github.com/huggingface/pytorch-image-models/tree/main/timm/models Can you find the model you are using there? If so, you can use timm.

这个里面没有我使用的模型

@junjiejiangjjj
Copy link
Contributor

Then you'll have to implement an op yourself.

@David1-git
Copy link
Author

Then you'll have to implement an op yourself.
具体要怎么实现呢,可以具体说一下吗

@junjiejiangjjj
Copy link
Contributor

Then you'll have to implement an op yourself.
具体要怎么实现呢,可以具体说一下吗

https://towhee.readthedocs.io/en/latest/operator/usage.html#run-pipeline-with-named-operators

@watertianyi
Copy link

@junjiejiangjjj
I found that there is ConvNeXt-V2 in timm, but I use https://github.com/open-mmlab/mmpretrain or https://github.com/facebookresearch/ConvNeXt-V2 for training. You can directly use timm to load this Is it a model trained by two warehouses?

@junjiejiangjjj
Copy link
Contributor

@junjiejiangjjj I found that there is ConvNeXt-V2 in timm, but I use https://github.com/open-mmlab/mmpretrain or https://github.com/facebookresearch/ConvNeXt-V2 for training. You can directly use timm to load this Is it a model trained by two warehouses?

You can use checkpoint_path param to load your weights: ops.image_embedding.timm(model_name='resnet50', checkpoint_path="your weights file path")

@watertianyi
Copy link

@junjiejiangjjj
Copy link
Contributor

image
This op decodes the image in bgr format by default, so the displayed image color is incorrect. Use ops.image_decode.cv2('rgb') to display it normally.

@watertianyi
Copy link

@junjiejiangjjj Thank you for your prompt reply!

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

No branches or pull requests

3 participants