-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile_model.py
More file actions
41 lines (31 loc) · 1.03 KB
/
Copy pathcompile_model.py
File metadata and controls
41 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import qai_hub
def compile_model(model, device, input_shape):
"""Submits a compile job for the model and returns the job instance."""
return qai_hub.submit_compile_job(
model=model,
device=device,
input_specs={"image": input_shape},
options="--target_runtime tflite"
)
# TODO: Set the target device based on your track
device = qai_hub.Device("")
# Define input shape
input_shape = (1, 3, 224, 224)
# Construct your model (replace with actual model initialization)
model = None # Replace with the actual model instance
"""
Example:
# Construct your own model
class PreprocessedMobileNetV2(torch.nn.Module):
...
model = PreprocessedMobileNetV2()
or
model = qai_hub.get_model("model_id")
"""
# Compile the model
compile_job = compile_model(model, device, input_shape)
# Sharing the model
compile_job.modify_sharing(add_emails=['lowpowervision@gmail.com'])
compile_job.set_name(f"{model.model_id}_LPCVC25")
# Output compiled job ID
print(f"Model compile job submitted with ID {compile_job.job_id}")