Skip to content

Commit

Permalink
v0.4.0r2
Browse files Browse the repository at this point in the history
Remove Incomplete Model Folder

Signed-off-by: QAIHM Team <[email protected]>
  • Loading branch information
qaihm-bot committed Mar 21, 2024
1 parent 943150b commit fc058e7
Show file tree
Hide file tree
Showing 24 changed files with 353 additions and 356 deletions.
5 changes: 4 additions & 1 deletion qai_hub_models/models/_shared/ffnet/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import os
from importlib import reload
from typing import Type, TypeVar

import torch

Expand Down Expand Up @@ -58,12 +59,14 @@
),
}

FFNetType = TypeVar("FFNetType", bound="FFNet")


class FFNet(CityscapesSegmentor):
"""Exportable FFNet fuss-free Cityscapes segmentation model."""

@classmethod
def from_pretrained(cls, variant_name: str) -> FFNet:
def from_pretrained(cls: Type[FFNetType], variant_name: str) -> FFNetType:
model = _load_ffnet_source_model(variant_name)
model.eval()

Expand Down
7 changes: 5 additions & 2 deletions qai_hub_models/models/_shared/ffnet/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
# ---------------------------------------------------------------------
from __future__ import annotations

from typing import Type

import numpy as np
import torch

from qai_hub_models.models._shared.cityscapes_segmentation.demo import (
TEST_CITYSCAPES_LIKE_IMAGE_ASSET,
)
from qai_hub_models.models._shared.ffnet.model import FFNet, _load_ffnet_source_model
from qai_hub_models.models._shared.ffnet.model import _load_ffnet_source_model
from qai_hub_models.utils.asset_loaders import load_image
from qai_hub_models.utils.base_model import BaseModel
from qai_hub_models.utils.image_processing import preprocess_PIL_image


def run_test_off_target_numerical(
ffnet_cls: FFNet, variant_name: str, relax_numerics: bool = False
ffnet_cls: Type[BaseModel], variant_name: str, relax_numerics: bool = False
):
"""Verify that raw (numeric) outputs of both (qaism and non-qaism) networks are the same."""
processed_sample_image = preprocess_PIL_image(
Expand Down
7 changes: 5 additions & 2 deletions qai_hub_models/models/_shared/ffnet_quantized/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# isort: on

import os
from typing import Type, TypeVar

import torch
from aimet_torch.batch_norm_fold import fold_all_batch_norms
Expand All @@ -29,6 +30,8 @@
os.path.join(os.path.dirname(__file__), "aimet_config.json")
)

FFNetQuantizableType = TypeVar("FFNetQuantizableType", bound="FFNetQuantizable")


class FFNetQuantizable(AIMETQuantizableMixin, FFNet):
"""
Expand Down Expand Up @@ -58,10 +61,10 @@ def default_aimet_encodings(cls) -> str:

@classmethod
def from_pretrained(
cls,
cls: Type[FFNetQuantizableType],
variant_name: str,
aimet_encodings: str | None = "DEFAULT",
) -> "FFNetQuantizable":
) -> FFNetQuantizableType:
ffnet = FFNet.from_pretrained(variant_name).model

input_shape = FFNetQuantizable.get_input_spec()["image"][0]
Expand Down
2 changes: 1 addition & 1 deletion qai_hub_models/models/_shared/whisper/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def get_input_spec(num_blocks: int, attention_dim: int) -> InputSpec:

return specs

def _get_input_spec_for_model_instance(self) -> InputSpec:
def _get_input_spec_for_instance(self) -> InputSpec:
return self.__class__.get_input_spec(len(self.blocks), self.attention_dim)

@classmethod
Expand Down
1 change: 1 addition & 0 deletions qai_hub_models/models/controlnet_quantized/info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ deploy_license: https://github.com/lllyasviel/ControlNet/blob/main/LICENSE
source_repo: https://github.com/lllyasviel/ControlNet
technical_details:
Input: Text prompt and input image as a reference
Conditioning Input: Canny-Edge
QNN-SDK: '2.19'
Text Encoder Number of parameters: 340M
UNet Number of parameters: 865M
Expand Down
6 changes: 3 additions & 3 deletions qai_hub_models/models/ffnet_122ns_lowres/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class FFNet122NSLowRes(FFNetLowRes):
@classmethod
def from_pretrained(cls) -> FFNet122NSLowRes:
return FFNetLowRes.from_pretrained.__func__(
cls, "segmentation_ffnet122NS_CCC_mobile_pre_down"
def from_pretrained(cls) -> FFNet122NSLowRes: # type: ignore
return super(FFNet122NSLowRes, cls).from_pretrained(
"segmentation_ffnet122NS_CCC_mobile_pre_down"
)
4 changes: 2 additions & 2 deletions qai_hub_models/models/ffnet_40s/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

class FFNet40S(FFNet):
@classmethod
def from_pretrained(cls) -> FFNet40S:
return FFNet.from_pretrained.__func__(cls, "segmentation_ffnet40S_dBBB_mobile")
def from_pretrained(cls) -> FFNet40S: # type: ignore
return super(FFNet40S, cls).from_pretrained("segmentation_ffnet40S_dBBB_mobile")
5 changes: 2 additions & 3 deletions qai_hub_models/models/ffnet_40s_quantized/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@

class FFNet40SQuantizable(FFNetQuantizable, FFNet40S):
@classmethod
def from_pretrained(
def from_pretrained( # type: ignore
cls,
aimet_encodings: str | None = "DEFAULT",
) -> FFNet40SQuantizable:
return FFNetQuantizable.from_pretrained.__func__(
cls,
return super(FFNet40SQuantizable, cls).from_pretrained(
"segmentation_ffnet40S_dBBB_mobile",
aimet_encodings=aimet_encodings,
)
Expand Down
4 changes: 2 additions & 2 deletions qai_hub_models/models/ffnet_54s/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

class FFNet54S(FFNet):
@classmethod
def from_pretrained(cls) -> FFNet54S:
return FFNet.from_pretrained.__func__(cls, "segmentation_ffnet54S_dBBB_mobile")
def from_pretrained(cls) -> FFNet54S: # type: ignore
return super(FFNet54S, cls).from_pretrained("segmentation_ffnet54S_dBBB_mobile")
6 changes: 3 additions & 3 deletions qai_hub_models/models/ffnet_54s_quantized/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

class FFNet54SQuantizable(FFNetQuantizable, FFNet54S):
@classmethod
def from_pretrained(
def from_pretrained( # type: ignore
cls,
aimet_encodings: str | None = "DEFAULT",
) -> FFNet54SQuantizable:
return FFNetQuantizable.from_pretrained.__func__(
cls, "segmentation_ffnet54S_dBBB_mobile", aimet_encodings=aimet_encodings
return super(FFNet54SQuantizable, cls).from_pretrained(
"segmentation_ffnet54S_dBBB_mobile", aimet_encodings=aimet_encodings
)

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions qai_hub_models/models/ffnet_78s/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

class FFNet78S(FFNet):
@classmethod
def from_pretrained(cls) -> FFNet78S:
return FFNet.from_pretrained.__func__(cls, "segmentation_ffnet78S_dBBB_mobile")
def from_pretrained(cls) -> FFNet78S: # type: ignore
return super(FFNet78S, cls).from_pretrained("segmentation_ffnet78S_dBBB_mobile")
6 changes: 3 additions & 3 deletions qai_hub_models/models/ffnet_78s_lowres/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class FFNet78SLowRes(FFNetLowRes):
@classmethod
def from_pretrained(cls) -> FFNet78SLowRes:
return FFNetLowRes.from_pretrained.__func__(
cls, "segmentation_ffnet78S_BCC_mobile_pre_down"
def from_pretrained(cls) -> FFNet78SLowRes: # type: ignore
return super(FFNet78SLowRes, cls).from_pretrained(
"segmentation_ffnet78S_BCC_mobile_pre_down"
)
6 changes: 3 additions & 3 deletions qai_hub_models/models/ffnet_78s_quantized/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

class FFNet78SQuantizable(FFNetQuantizable, FFNet78S):
@classmethod
def from_pretrained(
def from_pretrained( # type: ignore
cls,
aimet_encodings: str | None = "DEFAULT",
) -> FFNet78SQuantizable:
return FFNetQuantizable.from_pretrained.__func__(
cls, "segmentation_ffnet78S_dBBB_mobile", aimet_encodings=aimet_encodings
return super(FFNet78SQuantizable, cls).from_pretrained(
"segmentation_ffnet78S_dBBB_mobile", aimet_encodings=aimet_encodings
)

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions qai_hub_models/models/sam/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def forward(self, image: torch.Tensor) -> torch.Tensor:
"""
return self.sam.image_encoder(image)

def _get_input_spec_for_model_instance(
def _get_input_spec_for_instance(
self,
batch_size: int = 1,
num_channels: int = 3,
Expand Down Expand Up @@ -227,7 +227,7 @@ def forward(
image_embeddings, point_coords, point_labels, mask_input, has_mask_input
)

def _get_input_spec_for_model_instance(
def _get_input_spec_for_instance(
self,
num_of_points: int = 1,
) -> InputSpec:
Expand Down
4 changes: 2 additions & 2 deletions qai_hub_models/models/stylegan2/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def get_input_spec(
inputs["classes"] = ((batch_size, num_classes), "float32")
return inputs

def _get_input_spec_for_model_instance(self, batch_size: int = 1) -> InputSpec:
def _get_input_spec_for_instance(self, batch_size: int = 1) -> InputSpec:
return self.__class__.get_input_spec(
self.output_size, self.num_classes, batch_size
)
Expand All @@ -104,7 +104,7 @@ def sample_inputs(
self, input_spec: InputSpec | None = None, seed=None
) -> Dict[str, List[np.ndarray]]:
if not input_spec:
input_spec = self._get_input_spec_for_model_instance()
input_spec = self._get_input_spec_for_instance()

inputs = {
"image_noise": [
Expand Down
2 changes: 1 addition & 1 deletion qai_hub_models/models/trocr/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def get_input_spec(

return decoder_input_specs

def _get_input_spec_for_model_instance(self) -> InputSpec:
def _get_input_spec_for_instance(self) -> InputSpec:
return self.__class__.get_input_spec(
self.decoder_attention_heads,
self.embeddings_per_head,
Expand Down
4 changes: 0 additions & 4 deletions qai_hub_models/models/whisper_small_multi/code-gen.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions qai_hub_models/models/whisper_small_multi/demo.py

This file was deleted.

6 changes: 3 additions & 3 deletions qai_hub_models/test/test_async_compile_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import os

import qai_hub as hub
import yaml

from qai_hub_models.utils.asset_loaders import load_yaml


def test_compile_jobs_success():
Expand All @@ -16,8 +17,7 @@ def test_compile_jobs_success():
"""
if os.stat(os.environ["COMPILE_JOBS_FILE"]).st_size == 0:
return
with open(os.environ["COMPILE_JOBS_FILE"], "r") as f:
job_ids = yaml.safe_load(f.read())
job_ids = load_yaml(os.environ["COMPILE_JOBS_FILE"])
failed_jobs = {}
for name, job_id in job_ids.items():
result = hub.get_job(job_id).wait()
Expand Down
Loading

0 comments on commit fc058e7

Please sign in to comment.