|
| 1 | +#!/usr/bin/env python2.7 |
| 2 | +# Copyright 2014 G.K SUDHARSHAN <sudharpun90@gmail.com> IIT Madras |
| 3 | +# Copyright 2014 Abil N George<mail@abilng.in> IIT Madras |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 12 | +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED |
| 13 | +# WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, |
| 14 | +# MERCHANTABLITY OR NON-INFRINGEMENT. |
| 15 | +# See the Apache 2 License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +from utils.load_conf import load_model |
| 21 | +import sys |
| 22 | + |
| 23 | +import logging |
| 24 | +logger = logging.getLogger(__name__) |
| 25 | +from io_modules import setLogger |
| 26 | + |
| 27 | + |
| 28 | +def setLoggerLevel(modelConfig): |
| 29 | + # Set the level which determines what you see |
| 30 | + try: |
| 31 | + level = modelConfig['logger_level'] |
| 32 | + except KeyError: |
| 33 | + level = "INFO" |
| 34 | + |
| 35 | + if level == "INFO": |
| 36 | + logger.setLevel(logging.INFO) |
| 37 | + elif level == "DEBUG": |
| 38 | + logger.setLevel(logging.DEBUG) |
| 39 | + elif level == "ERROR": |
| 40 | + logger.setLevel(logging.ERROR) |
| 41 | + else: |
| 42 | + logger.setLevel(logging.WARNING) |
| 43 | + |
| 44 | + |
| 45 | +def runNet(modelConfig): |
| 46 | + nnetType = modelConfig ['nnetType'] |
| 47 | + logger.info("Loading Other Configuration for %s",nnetType); |
| 48 | + if nnetType == 'CNN': |
| 49 | + from run.run_CNN import runCNN as runModel |
| 50 | + elif nnetType == 'RBM': |
| 51 | + from run.run_DBN import runRBM as runModel |
| 52 | + elif nnetType == 'SDA': |
| 53 | + from run.run_SDA import runSdA as runModel |
| 54 | + else : |
| 55 | + logger.error('Unknown nnet Type') |
| 56 | + return 1 |
| 57 | + runModel(modelConfig) |
| 58 | + |
| 59 | + |
| 60 | +if __name__ == '__main__': |
| 61 | + setLogger(); |
| 62 | + modelConfig = load_model(sys.argv[1]) |
| 63 | + setLoggerLevel(modelConfig) |
| 64 | + runNet(modelConfig) |
0 commit comments