-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a search noteboook. * Move all user-facing notebooks under 'inference'. * Rename the active learning notebook to active_learning.ipynb * Automatically populate BootstrapConfig using the embedding run's config.json. * Add a missing model key to inference.models.model_class_map * Make explicit the option to disable speech filtering in the embedding notebook. PiperOrigin-RevId: 548262946
- Loading branch information
1 parent
02ad072
commit a05a268
Showing
9 changed files
with
612 additions
and
134 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# coding=utf-8 | ||
# Copyright 2023 The Chirp Authors. | ||
# | ||
# 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. | ||
|
||
"""Helper functions for user-facing colab notebooks.""" | ||
|
||
import warnings | ||
|
||
from absl import logging | ||
from chirp import config_utils | ||
from chirp.configs import config_globals | ||
from chirp.inference import embed_lib | ||
import tensorflow as tf | ||
|
||
|
||
def initialize(use_tf_gpu: bool = True, disable_warnings: bool = True): | ||
"""Apply notebook conveniences. | ||
Args: | ||
use_tf_gpu: If True, allows GPU use and sets Tensorflow to 'memory growth' | ||
mode (instead of reserving all available GPU memory at once). If False, | ||
Tensorflow is restricted to CPU operation. Must run before any TF | ||
computations to be effective. | ||
disable_warnings: If True, disables printed warnings from library code. | ||
""" | ||
if disable_warnings: | ||
logging.set_verbosity(logging.ERROR) | ||
warnings.filterwarnings('ignore') | ||
|
||
if not use_tf_gpu: | ||
tf.config.experimental.set_visible_devices([], 'GPU') | ||
else: | ||
for gpu in tf.config.list_physical_devices('GPU'): | ||
tf.config.experimental.set_memory_growth(gpu, True) |
Oops, something went wrong.