Could you post the model.py code?
If seems that you have some training procedure code in there without protecting it with
if __name__=='__main__:
Importing a Python module calls each “global” line in the script. You should therefore move all code into functions like in the imagenet example 46.
The main function won’t be called when you import the module, just if you call it directly (e.g. from your terminal).