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

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 20, 2021
1 parent e9182fc commit 334763f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion flash/core/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.

import os.path
import zipfile
import tarfile
import zipfile
from typing import Any, Callable, Dict, Iterable, Mapping, Optional, Set, Type

import requests
Expand Down
9 changes: 2 additions & 7 deletions flash/image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
ImageClassificationPreprocess,
ImageClassifier,
)
from flash.image.detection import ( # noqa: F401
ObjectDetectionData,
ObjectDetector,
)
from flash.image.face_detection import ( # noqa: F401
FaceDetector,
)
from flash.image.detection import ObjectDetectionData, ObjectDetector # noqa: F401
from flash.image.embedding import ImageEmbedder # noqa: F401
from flash.image.face_detection import FaceDetector # noqa: F401
from flash.image.segmentation import ( # noqa: F401
SemanticSegmentation,
SemanticSegmentationData,
Expand Down
4 changes: 2 additions & 2 deletions flash/image/face_detection/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
# limitations under the License.
from typing import Any, Callable, Dict, Optional, Sequence, Tuple

from torch.utils.data import Dataset

from flash.core.data.data_source import DataSource, DefaultDataKeys, DefaultDataSources
from flash.core.data.process import Preprocess
from flash.core.utilities.imports import _TORCHVISION_AVAILABLE
from flash.image.data import ImagePathsDataSource
from flash.image.detection.transforms import default_transforms

from torch.utils.data import Dataset

if _TORCHVISION_AVAILABLE:
from torchvision.datasets.folder import default_loader

Expand Down
5 changes: 1 addition & 4 deletions flash/image/face_detection/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from flash.core.data.process import Preprocess, Serializer
from flash.core.model import Task
from flash.core.utilities.imports import _FASTFACE_AVAILABLE

from flash.image.detection.finetuning import ObjectDetectionFineTuning
from flash.image.detection.serialization import DetectionLabels
from flash.image.face_detection.data import FaceDetectionPreprocess
Expand Down Expand Up @@ -62,9 +61,7 @@ def __init__(
self.save_hyperparameters()

if model in ff.list_pretrained_models():
model = FaceDetector.get_model(
model, pretrained, **kwargs
)
model = FaceDetector.get_model(model, pretrained, **kwargs)
else:
ValueError(f"{model} is not supported yet.")

Expand Down
11 changes: 3 additions & 8 deletions flash_examples/face_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import flash
from flash.core.data.data_module import DataModule
from flash.core.utilities.imports import _FASTFACE_AVAILABLE
from flash.image import FaceDetector
from flash.image.face_detection.data import FaceDetectionPreprocess
from flash.core.data.data_module import DataModule

if _FASTFACE_AVAILABLE:
import fastface as ff
Expand All @@ -27,19 +27,14 @@
val_dataset = ff.dataset.FDDBDataset(source_dir="data/", phase="val")

datamodule = DataModule.from_data_source(
"fastface",
train_data=train_dataset,
val_data=val_dataset,
preprocess=FaceDetectionPreprocess()
"fastface", train_data=train_dataset, val_data=val_dataset, preprocess=FaceDetectionPreprocess()
)

# 2. Build the task
model = FaceDetector(model="lffd_slim")

# 3. Create the trainer and finetune the model
trainer = flash.Trainer(max_epochs=3,
limit_train_batches=0.1,
limit_val_batches=0.1)
trainer = flash.Trainer(max_epochs=3, limit_train_batches=0.1, limit_val_batches=0.1)

trainer.finetune(model, datamodule=datamodule, strategy="freeze")

Expand Down

0 comments on commit 334763f

Please sign in to comment.