Skip to content

Commit

Permalink
Merge pull request #72 from mobiusml/hr/max_token
Browse files Browse the repository at this point in the history
Hr/max new token
  • Loading branch information
HRashidi authored Mar 13, 2024
2 parents c02ca2a + 9bc967b commit 91ee957
Show file tree
Hide file tree
Showing 174 changed files with 938 additions and 1,239 deletions.
2 changes: 1 addition & 1 deletion aana/configs/deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@
user_config=StableDiffusion2Config(
model="stabilityai/stable-diffusion-2",
dtype=Dtype.FLOAT16,
).dict(),
).model_dump(),
),
}
7 changes: 6 additions & 1 deletion aana/deployments/hf_blip2_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ class HFBlip2Config(BaseModel):
dtype (str): the data type (optional, default: "auto"), one of "auto", "float32", "float16"
batch_size (int): the batch size (optional, default: 1)
num_processing_threads (int): the number of processing threads (optional, default: 1)
max_new_tokens (int): The maximum numbers of tokens to generate. (optional, default: 64)
"""

model: str
dtype: Dtype = Field(default=Dtype.AUTO)
batch_size: int = Field(default=1)
num_processing_threads: int = Field(default=1)
max_new_tokens: int = Field(default=64)


class CaptioningOutput(TypedDict):
Expand Down Expand Up @@ -89,6 +91,7 @@ async def apply_config(self, config: dict[str, Any]):
load_in_8bit = False
self.torch_dtype = self.dtype.to_torch()
self.device = "cuda" if torch.cuda.is_available() else "cpu"
self.max_new_tokens = config_obj.max_new_tokens
self.model = Blip2ForConditionalGeneration.from_pretrained(
self.model_id,
torch_dtype=self.torch_dtype,
Expand Down Expand Up @@ -163,7 +166,9 @@ def _generate(self, images: list[Image]) -> CaptioningBatchOutput:
)

try:
generated_ids = self.model.generate(**inputs)
generated_ids = self.model.generate(
**inputs, max_new_tokens=self.max_new_tokens
)
generated_texts = self.processor.batch_decode(
generated_ids, skip_special_tokens=True
)
Expand Down
1 change: 0 additions & 1 deletion aana/models/pydantic/asr_output.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import numpy as np
from faster_whisper.transcribe import (
Segment as WhisperSegment,
Expand Down
1 change: 0 additions & 1 deletion aana/models/pydantic/captions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from pydantic import ConfigDict

from aana.models.pydantic.base import BaseListModel, BaseStringModel
Expand Down
1 change: 0 additions & 1 deletion aana/models/pydantic/prompt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from pydantic import ConfigDict

from aana.models.pydantic.base import BaseStringModel
Expand Down
1 change: 0 additions & 1 deletion aana/models/pydantic/question.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from pydantic import ConfigDict

from aana.models.pydantic.base import BaseStringModel
Expand Down
1 change: 0 additions & 1 deletion aana/models/pydantic/sampling_params.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from pydantic import BaseModel, ConfigDict, Field, field_validator


Expand Down
1 change: 0 additions & 1 deletion aana/models/pydantic/time_interval.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from pydantic import BaseModel, ConfigDict, Field


Expand Down
1 change: 0 additions & 1 deletion aana/models/pydantic/video_metadata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from pydantic import BaseModel, ConfigDict, Field


Expand Down
1 change: 0 additions & 1 deletion aana/models/pydantic/video_params.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from pydantic import BaseModel, ConfigDict, Field


Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 91ee957

Please sign in to comment.