Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Fix CI and attempt to improve flaky tests #1394

Merged
merged 20 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from 11 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
7 changes: 3 additions & 4 deletions flash/core/data/utilities/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@
TSV_EXTENSIONS = (".tsv",)


def _load_image_from_image(file, drop_alpha: bool = True):
def _load_image_from_image(file):
img = Image.open(file)
img.load()

if img.mode == "RGBA" and drop_alpha:
img = img.convert("RGB")
img = img.convert("RGB")
return img


Expand All @@ -74,7 +73,7 @@ def _load_image_from_numpy(file):


def _load_spectrogram_from_image(file):
img = _load_image_from_image(file, drop_alpha=False)
img = _load_image_from_image(file)
return np.array(img).astype("float32")


Expand Down
4 changes: 2 additions & 2 deletions flash_examples/image_embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
training_strategy="barlow_twins",
head="barlow_twins_head",
pretraining_transform="barlow_twins_transform",
training_strategy_kwargs={"latent_embedding_dim": 128},
training_strategy_kwargs={"latent_embedding_dim": 512},
pretraining_transform_kwargs={"size_crops": [32]},
krshrimali marked this conversation as resolved.
Show resolved Hide resolved
)

Expand All @@ -49,7 +49,7 @@
"data/hymenoptera_data/predict/153783656_85f9c3ac70.jpg",
"data/hymenoptera_data/predict/2039585088_c6f47c592e.jpg",
],
batch_size=3,
batch_size=2,
)
embeddings = trainer.predict(embedder, datamodule=datamodule)

Expand Down
2 changes: 1 addition & 1 deletion flash_examples/style_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
model = StyleTransfer(os.path.join(flash.ASSETS_ROOT, "starry_night.jpg"))

# 3. Create the trainer and train the model
trainer = flash.Trainer(max_epochs=3, gpus=torch.cuda.device_count())
trainer = flash.Trainer(max_epochs=1, gpus=torch.cuda.device_count())
trainer.fit(model, datamodule=datamodule)

# 4. Apply style transfer to a few images!
Expand Down
4 changes: 2 additions & 2 deletions tests/core/data/utilities/test_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ def test_speed(case):
formatter = get_target_formatter(targets)
end = time.perf_counter()

assert (end - start) / len(targets) < 1e-5 # 0.01ms per target
assert (end - start) / len(targets) < 1e-4 # 0.1ms per target

start = time.perf_counter()
_ = [formatter(t) for t in targets]
end = time.perf_counter()

assert (end - start) / len(targets) < 1e-5 # 0.01ms per target
assert (end - start) / len(targets) < 1e-4 # 0.1ms per target