Repository: keras-team/autokeras

Issue:
tqdm doesn't work on google colab
<!---
**If you are reporting a bug:**
*  Verify that your issue is not being currently addressed by other issues or pull requests.
*  Please note that Auto-Keras is only compatible with **Python 3.6**.
*  Tag the issue with the `bug report` tag.
-->

### Bug Description
As mentioned by @shyamalschandra.

According to [tqdm issue#558](https://github.com/tqdm/tqdm/issues/558)
tqdm.notebook can't work on Google Colab due to the lack of **ipywidgets**

### Reproducing Steps
Steps to reproduce the behavior:
  * Step 1: pip3 install autokeras on google colab
  * Step 2: run example/mnist.py by coping and pasting the code in Google Colab.

### Expected Behavior
Should be working without error

### Setup Details
Include the details about the versions of:
 - OS type and version: Google Colab
 - Python: 3.6
 - autokeras: 0.2.18
 - scikit-learn: 0.19.1
 - numpy: 1.14.5
 - keras: 2.2.2
 - scipy:
 - tensorflow: 1.10.0
 - pytorch: 0.4.1
 - tqdm: 4.25.0

### Additional context
Could be solved by replacing 
```python
from tqdm.autonotebook import tqdm
```
to
```python
from tqdm import tqdm
```
***However, the final progress bar will remain on the terminal***
tqdm doesn't work on google colab
<!---
**If you are reporting a bug:**
*  Verify that your issue is not being currently addressed by other issues or pull requests.
*  Please note that Auto-Keras is only compatible with **Python 3.6**.
*  Tag the issue with the `bug report` tag.
-->

### Bug Description
As mentioned by @shyamalschandra.

According to [tqdm issue#558](https://github.com/tqdm/tqdm/issues/558)
tqdm.notebook can't work on Google Colab due to the lack of **ipywidgets**

### Reproducing Steps
Steps to reproduce the behavior:
  * Step 1: pip3 install autokeras on google colab
  * Step 2: run example/mnist.py by coping and pasting the code in Google Colab.

### Expected Behavior
Should be working without error

### Setup Details
Include the details about the versions of:
 - OS type and version: Google Colab
 - Python: 3.6
 - autokeras: 0.2.18
 - scikit-learn: 0.19.1
 - numpy: 1.14.5
 - keras: 2.2.2
 - scipy:
 - tensorflow: 1.10.0
 - pytorch: 0.4.1
 - tqdm: 4.25.0

### Additional context
Could be solved by replacing 
```python
from tqdm.autonotebook import tqdm
```
to
```python
from tqdm import tqdm
```
***However, the final progress bar will remain on the terminal***


Discussion:

Resolving patch:
diff --git a/autokeras/nn/model_trainer.py b/autokeras/nn/model_trainer.py
--- a/autokeras/nn/model_trainer.py
+++ b/autokeras/nn/model_trainer.py
@@ -6,7 +6,7 @@
 import numpy as np
 import torch
 from torchvision import utils as vutils
-from tqdm.autonotebook import tqdm
+from tqdm import tqdm
 from autokeras.constant import Constant
 from autokeras.utils import get_device
 
diff --git a/autokeras/preprocessor.py b/autokeras/preprocessor.py
--- a/autokeras/preprocessor.py
+++ b/autokeras/preprocessor.py
@@ -100,6 +100,7 @@ def __call__(self, img):
 
 class DataTransformer(ABC):
     """A superclass for all the DataTransformer."""
+
     def __init__(self):
         pass
 
@@ -140,6 +141,7 @@ def text_transform(compose_list, data, targets):
 
 class TextDataTransformer(DataTransformer):
     """ A DataTransformer class for the text data."""
+
     def __init__(self):
         super().__init__()
 
@@ -303,6 +305,7 @@ def __len__(self):
 
 class BatchDataset(Dataset):
     """A torch.Dataset class that can read data batch by batch."""
+
     def __init__(self, csv_file_path, image_path, has_target=True):
         file_names, target = read_csv_file(csv_file_path)
 
diff --git a/autokeras/utils.py b/autokeras/utils.py
--- a/autokeras/utils.py
+++ b/autokeras/utils.py
@@ -47,7 +47,7 @@ def pickle_to_file(obj, path):
     """Save the pickle file to the specified path."""
     pickle.dump(obj, open(path, 'wb'))
 
-
+# TODO cannot detect nvidia-smi in Windows normally. We need a fall back for windows
 def get_device():
     """ If CUDA is available, use CUDA device, else use CPU device.
 


Test patch: