Skip to content

Commit

Permalink
fix threads
Browse files Browse the repository at this point in the history
  • Loading branch information
kahst committed Feb 23, 2024
1 parent 89361b6 commit ffb7837
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ def analyzeFile(item):

# Set number of threads
if os.path.isdir(cfg.INPUT_PATH):
cfg.CPU_THREADS = int(args.threads)
cfg.CPU_THREADS = max(1, int(args.threads))
cfg.TFLITE_THREADS = 1
else:
cfg.CPU_THREADS = 1
cfg.TFLITE_THREADS = int(args.threads)
cfg.TFLITE_THREADS = max(1, int(args.threads))

# Set batch size
cfg.BATCH_SIZE = max(1, int(args.batchsize))
Expand Down
3 changes: 2 additions & 1 deletion segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
import argparse
import os
import multiprocessing
from multiprocessing import Pool

import numpy as np
Expand Down Expand Up @@ -268,7 +269,7 @@ def extractSegments(item: tuple[tuple[str, list[dict]], float, dict[str]]):
parser.add_argument(
"--seg_length", type=float, default=3.0, help="Length of extracted segments in seconds. Defaults to 3.0."
)
parser.add_argument("--threads", type=int, default=4, help="Number of CPU threads.")
parser.add_argument("--threads", type=int, default=min(8, max(1, multiprocessing.cpu_count() // 2)), help="Number of CPU threads.")

args = parser.parse_args()

Expand Down
2 changes: 1 addition & 1 deletion train.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def run_trial(self, trial, *args, **kwargs):
cfg.TRAIN_CACHE_MODE = args.cache_mode.lower()
cfg.TRAIN_CACHE_FILE = args.cache_file
cfg.TFLITE_THREADS = 1
cfg.CPU_THREADS = cfg.CPU_THREADS = max(1, int(args.threads))
cfg.CPU_THREADS = max(1, int(args.threads))

cfg.BANDPASS_FMIN = max(0, min(cfg.SIG_FMAX, int(args.fmin)))
cfg.BANDPASS_FMAX = max(cfg.SIG_FMIN, min(cfg.SIG_FMAX, int(args.fmax)))
Expand Down

0 comments on commit ffb7837

Please sign in to comment.