Error: local variable 'model_type' referenced before assignment