Skip to content

Commit ffcb28d

Browse files
committed
Fix support to images
1 parent 503a56c commit ffcb28d

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/guidellm/core/request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import uuid
2-
from typing import Any, Dict, List, Optional, Tuple
2+
from typing import Any, Dict, List, Optional
33

44
from pydantic import Field
55

@@ -42,7 +42,7 @@ def number_images(self) -> int:
4242
return len(self.images)
4343

4444
@property
45-
def image_resolution(self) -> Tuple[int]:
45+
def image_resolution(self) -> List[int]:
4646
if self.images is None:
4747
return None
4848
else:

src/guidellm/request/emulated.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class EmulatedConfig:
3131
generated_tokens_min (Optional[int]): Minimum number of generated tokens.
3232
generated_tokens_max (Optional[int]): Maximum number of generated tokens.
3333
images (Optional[int]): Number of images.
34-
image_resultion (Optional[List[int]]): Resolution of images.
34+
width (Optional[int]): Width of images.
35+
height (Optional[int]): Height of images.
3536
"""
3637

3738
@staticmethod
@@ -108,7 +109,8 @@ def create_config(config: Optional[Union[str, Path, Dict]]) -> "EmulatedConfig":
108109
generated_tokens_max: Optional[int] = None
109110

110111
images: int = 0
111-
image_resolution = None
112+
width: int = None
113+
height: int = None
112114

113115
def __post_init__(self):
114116
if self.images is not None and self.image_resultion is not None and self.images > 0:
@@ -337,7 +339,7 @@ def __init__(
337339
settings.emulated_data.filter_end,
338340
)
339341
if self._config.images > 0:
340-
self._images = load_images(settings.emulated_data.image_source, self._config.image_resolution)
342+
self._images = load_images(settings.emulated_data.image_source, [self._config.width, self._config.height])
341343
self._rng = np.random.default_rng(random_seed)
342344

343345
# NOTE: Must be after all the parameters since the queue population

src/guidellm/utils/images.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from bs4 import BeautifulSoup
77
from loguru import logger
88
from PIL import Image
9-
from pydantic import ConfigDict, Field
9+
from pydantic import ConfigDict, Field, computed_field
1010

1111
from guidellm.config import settings
1212
from guidellm.core.serializable import Serializable
@@ -26,6 +26,14 @@ class ImageDescriptor(Serializable):
2626
description="Image filename.",
2727
)
2828

29+
@computed_field # type: ignore[misc]
30+
@property
31+
def image_resolution(self) -> List[int]:
32+
if self.images is None:
33+
return None
34+
else:
35+
return [im.size for im in self.images]
36+
2937

3038
def load_images(data: str, image_resolution: Optional[List[int]]) -> List[ImageDescriptor]:
3139
"""

0 commit comments

Comments
 (0)