This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c84e94
commit 4c62482
Showing
8 changed files
with
78 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright The PyTorch Lightning team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from flash.core.utilities.flash_cli import FlashCLI | ||
from flash.image.face_detection.data import FaceDetectionData | ||
from flash.image.face_detection.model import FaceDetector | ||
|
||
__all__ = ["face_detection"] | ||
|
||
|
||
def from_fddb( | ||
batch_size: int = 1, | ||
**data_module_kwargs, | ||
) -> FaceDetectionData: | ||
"""Downloads and loads the FDDB data set.""" | ||
import fastface as ff | ||
|
||
train_dataset = ff.dataset.FDDBDataset(source_dir="data/", phase="train") | ||
val_dataset = ff.dataset.FDDBDataset(source_dir="data/", phase="val") | ||
|
||
return FaceDetectionData.from_datasets( | ||
train_dataset=train_dataset, | ||
val_dataset=val_dataset, | ||
batch_size=batch_size, | ||
**data_module_kwargs, | ||
) | ||
|
||
|
||
def face_detection(): | ||
"""Detect faces in images.""" | ||
cli = FlashCLI( | ||
FaceDetector, | ||
FaceDetectionData, | ||
default_datamodule_builder=from_fddb, | ||
default_arguments={ | ||
"trainer.max_epochs": 3, | ||
}, | ||
) | ||
|
||
cli.trainer.save_checkpoint("face_detection_model.pt") | ||
|
||
|
||
if __name__ == "__main__": | ||
face_detection() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters