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 10 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
8 changes: 4 additions & 4 deletions flash_examples/image_embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# 1. Download the data and prepare the datamodule
datamodule = ImageClassificationData.from_datasets(
train_dataset=CIFAR10(".", download=True),
batch_size=4,
batch_size=2,
krshrimali marked this conversation as resolved.
Show resolved Hide resolved
)

# 2. Build the task
Expand All @@ -30,8 +30,8 @@
training_strategy="barlow_twins",
head="barlow_twins_head",
pretraining_transform="barlow_twins_transform",
training_strategy_kwargs={"latent_embedding_dim": 128},
pretraining_transform_kwargs={"size_crops": [32]},
training_strategy_kwargs={"latent_embedding_dim": 512},
# pretraining_transform_kwargs={"size_crops": [32]},
krshrimali marked this conversation as resolved.
Show resolved Hide resolved
)

# 3. Create the trainer and pre-train the encoder
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=1 if torch.cuda.device_count() > 1 else 0)
krshrimali marked this conversation as resolved.
Show resolved Hide resolved
trainer.fit(model, datamodule=datamodule)

# 4. Apply style transfer to a few images!
Expand Down
2 changes: 1 addition & 1 deletion requirements/datatype_image_extras.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
matplotlib
fiftyone
classy_vision
vissl>=0.1.5
classy-vision @ https://github.com/facebookresearch/ClassyVision/tarball/4785d5ee19d3bcedd5b28c1eb51ea1f59188b54d
krshrimali marked this conversation as resolved.
Show resolved Hide resolved
icevision>=0.8
icedata
effdet
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