Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for tif #19421

Merged
merged 11 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/lightning/data/streaming/data_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,11 @@ def is_path(element: Any) -> bool:
return False

element: str = str(Path(element).resolve())
return (
element.startswith(self.input_dir.path)
if self.input_dir.path is not None
else os.path.exists(element)
)
if _IS_IN_STUDIO and self.input_dir.path is not None:
if self.input_dir.path.startswith("/teamspace/studios/this_studio"):
return os.path.exists(element)
return element.startswith(self.input_dir.path)
return os.path.exists(element)

# For speed reasons, we assume starting with `self.input_dir` is enough to be a real file.
# Other alternative would be too slow.
Expand Down
4 changes: 2 additions & 2 deletions src/lightning/data/streaming/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
from torchvision.io import decode_jpeg
from torchvision.transforms.functional import pil_to_tensor


class Serializer(ABC):
"""The base interface for any serializers.

Expand Down Expand Up @@ -288,7 +287,7 @@ def serialize(self, filepath: str) -> Tuple[bytes, Optional[str]]:
return f.read(), file_extension.replace(".", "").lower()

def deserialize(self, data: bytes) -> Any:
pass
return data

def can_serialize(self, data: Any) -> bool:
return isinstance(data, str) and os.path.exists(data)
Expand Down Expand Up @@ -326,6 +325,7 @@ def can_serialize(self, data: Any) -> bool:
_SERIALIZERS = OrderedDict(
**{
"video": VideoSerializer(),
"tif": FileSerializer(),
"file": FileSerializer(),
"pil": PILSerializer(),
"int": IntSerializer(),
Expand Down
1 change: 1 addition & 0 deletions tests/tests_data/streaming/test_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
def test_serializers():
assert list(_SERIALIZERS.keys()) == [
"video",
"tif",
"file",
"pil",
"int",
Expand Down
Loading