Views
No views yet
1from optimum.neuron import NeuronModelForSentenceTransformers
2
3# [Compile]
4model_id = "sentence-transformers/clip-ViT-B-32"
5
6# configs for compiling model
7input_shapes = {
8 "num_channels": 3,
9 "height": 224,
10 "width": 224,
11 "text_batch_size": 3,
12 "image_batch_size": 1,
13 "sequence_length": 64,
14}
15
16neuron_model = NeuronModelForSentenceTransformers.from_pretrained(
17 model_id, subfolder="0_CLIPModel", export=True, dynamic_batch_size=False, **input_shapes
18)
19
20# Save locally or upload to the HuggingFace Hub
21save_directory = "clip_emb_neuron/"
22neuron_model.save_pretrained(save_directory)
23
24# Upload to the HuggingFace Hub
25neuron_model.push_to_hub(
26 "clip_emb_neuron/", repository_id="optimum/clip_vit_emb_neuronx" # Replace with your HF Hub repo id
27)