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

update classifier to load model from hf hub #7

Merged
merged 1 commit into from Oct 29, 2023
Merged

Conversation

pavaris-pm
Copy link
Owner

update the source code to load the model directly from hugginface. In order to prevent the case that the weight cannot be download directly from the .pth file

@pavaris-pm pavaris-pm added the enhancement New feature or request label Oct 29, 2023
@pavaris-pm pavaris-pm self-assigned this Oct 29, 2023
Copy link
Owner Author

@pavaris-pm pavaris-pm left a comment

Choose a reason for hiding this comment

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

add webapp optimization into #1 , since we have made a redundant model initialiation

Comment on lines 50 to +57
def classify(image: Image.Image)->Tuple[torch.Tensor,
torch.Tensor,
str
]:
# init this by ourselves
weight_file = None#'/workspaces/dog-breed-classification-webapp/src/production/models/model_weights/best_model_convnext.pth'
_ , idx2label = get_total_class()

# init the model
classifier, extractor = init_model(weight_file)
classifier, extractor = init_model(engine='convnext_v2')

Copy link
Owner Author

Choose a reason for hiding this comment

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

we will see that it will re-init the model everytime we upload new image, which is time-consuming since the ConvNext itself is very large. Consider optimize the speed by downloading everything first before making an inference at the end would much help

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

Successfully merging this pull request may close these issues.

None yet

1 participant