-
Notifications
You must be signed in to change notification settings - Fork 248
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
If I use moganet to train a model, and then use the model for feature extraction and image retrieval, how should I apply this framework? #2699
Comments
hi @goldwater668 , towhee integrates image models through timm. If your model can be called through timm, use the following code: from towhee import pipe, ops, DataCollection
p = (
pipe.input('path')
.map('path', 'img', ops.image_decode())
.map('img', 'vec', ops.image_embedding.timm(model_name='model_name', checkpoint_path="your local weights"))
.output('img', 'vec')
)
DataCollection(p('towhee.jpeg')).show() If not, you need to implement an operator yourself, https://towhee.readthedocs.io/en/latest/operator/usage.html#custom-operators |
@junjiejiangjjj
|
It seems that you need to run it in the directory of this project. git clone https://github.com/Westlake-AI/MogaNet
cd MogaNet import models
from towhee import pipe, ops, DataCollection
p = (
pipe.input('path')
.map('path', 'img', ops.image_decode())
.map('img', 'vec', ops.image_embedding.timm(model_name='moganet_xtiny', checkpoint_path="your local weights"))
.output('img', 'vec')
)
DataCollection(p('towhee.jpeg')).show() |
Towhee accelerates model inference through Triton Server , but only supports a subset of models. For your own models, you can consider converting them to ONNX to accelerate inference. |
@junjiejiangjjj |
@junjiejiangjjj |
I don't quite understand your question. Could you look at these cases to see if there are any similar scenarios to yours? https://github.com/towhee-io/examples |
@junjiejiangjjj The second thing is whether I use traditional algorithms for feature extraction and then vector retrieval, such as surf feature point extraction in opencv |
# Search pipeline
p_search_pre = (
p_embed.map('vec', ('search_res'), ops.ann_search.milvus_client(
host=HOST, port=PORT, limit=TOPK,
collection_name=COLLECTION_NAME))
.map('search_res', 'pred', lambda x: [str(Path(y[0]).resolve()) for y in x])
# .output('img_path', 'pred')
)
p_search = p_search_pre.output('img_path', 'pred')
You can refer to this example |
@junjiejiangjjj Is it only limited to the calculation method of similarity measure as L2, and other methods such as inner product (IP) |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe.
If I use moganet to train a model, and then use the model for feature extraction and image retrieval, how should I apply this framework?
Describe the solution you'd like.
If I use moganet to train a model, and then use the model for feature extraction and image retrieval, how should I apply this framework?
Describe an alternate solution.
If I use moganet to train a model, and then use the model for feature extraction and image retrieval, how should I apply this framework?
Anything else? (Additional Context)
If I use moganet to train a model, and then use the model for feature extraction and image retrieval, how should I apply this framework?
The text was updated successfully, but these errors were encountered: