From e825048337f4c0403cad04e230338fc1277a8489 Mon Sep 17 00:00:00 2001 From: aunetx Date: Wed, 4 Dec 2019 18:42:18 +0100 Subject: [PATCH] Made tqdm import optionnal --- .vscode/settings.json | 5 +++++ scripts/loulou.py | 7 +++++-- scripts/train.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..07c9f87 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "code-runner.executorMap": { + "python": "python3 $workspaceRoot/scripts/train.py" + } +} \ No newline at end of file diff --git a/scripts/loulou.py b/scripts/loulou.py index bc3fc0a..0af4c2a 100644 --- a/scripts/loulou.py +++ b/scripts/loulou.py @@ -1,4 +1,3 @@ -from tqdm import tqdm import numpy as np import json import sys @@ -92,7 +91,11 @@ def train(weights: list, trX: np.ndarray, trY: np.ndarray, teX: np.ndarray, teY: # Epochs loop for i in range(epochs): if reduce_output < 1: - + try: + from tqdm import tqdm + except ImportError: + print('Cannot find module `tqdm`!\nInstall it with `pip3 install tqdm` (or equivalent), or run the program with the argument `-r`.') + exit(1) pbar = tqdm(range(0, len(trX), batch)) else: pbar = range(0, len(trX), batch) diff --git a/scripts/train.py b/scripts/train.py index 053e30b..b871475 100755 --- a/scripts/train.py +++ b/scripts/train.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 -import json import argparse +import json from loulou import runTrain from utils import listToArch