Giter VIP home page Giter VIP logo

Comments (6)

Zahlii avatar Zahlii commented on June 7, 2024 1

Have you downloaded the actual utils.py file as described in the readme?

!wget https://raw.githubusercontent.com/Zahlii/colab-tf-utils/master/utils.py

Make sure that the folder where the utils.py is located is in your sys.path as well.

from colab-tf-utils.

SandSandu avatar SandSandu commented on June 7, 2024

--2018-06-21 13:58:07-- https://raw.githubusercontent.com/Zahlii/colab-tf-utils/master/utils.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6935 (6.8K) [text/plain]
Saving to: ‘utils.py.2’

utils.py.2 100%[===================>] 6.77K --.-KB/s in 0.1s

2018-06-21 13:58:09 (69.3 KB/s) - ‘utils.py.2’ saved [6935/6935]


get_ipython().system('wget https://raw.githubusercontent.com/Zahlii/colab-tf-utils/master/utils.py')
 56         import os

---> 57 import utils
58 import keras
59

ModuleNotFoundError: No module named 'utils'

yes @Zahlii but it's showing the same error
in google colab i mounted a folder as working directory and running code from that..
import os
os.chdir("drive/sandupro/sampleproject/model")

Make sure that the folder where the utils.py is located is in your sys.path as well.** sorry, I didn't understand this. am I doing anything wrong?

from colab-tf-utils.

Zahlii avatar Zahlii commented on June 7, 2024

I think the problem is that wget is downloading the file as utils.py.2 or utils.py.1.

Try to remove all previous versions:
!rm utils.*

Do you use chdir before or after importing utils? Because if you chdir to another directory, utils.py will not be in it unless you move the file into that new directory.

What does %pwd give you? What does !ls -la give you?

from colab-tf-utils.

SandSandu avatar SandSandu commented on June 7, 2024

%pwd
'/content/drive/sandupro/pix2code-master/model'

!ls -la

total 148
drwxr-xr-x 2 root root 4096 Jun 3 10:48 .
drwxr-xr-x 2 root root 4096 Jun 3 10:48 ..
-rw-r--r-- 1 root root 3349 Jun 3 10:48 build_datasets.py
drwxr-xr-x 2 root root 4096 Jun 3 10:48 classes
-rw-r--r-- 1 root root 1160 Jun 3 10:48 convert_imgs_to_arrays.py
-rw-r--r-- 1 root root 2128 Jun 3 10:48 converts to numpy array.ipynb
drwxr-xr-x 2 root root 4096 Jun 19 12:50 drive
-rw-r--r-- 1 root root 1798 Jun 3 10:48 generate.py
-rw-r--r-- 1 root root 0 Jun 3 10:48 init.py
drwxr-xr-x 2 root root 4096 Jun 3 10:48 .ipynb_checkpoints
-rw-r--r-- 1 root root 1443 Jun 3 10:48 pix2code
drwxr-xr-x 2 root root 4096 Jun 22 11:36 pycache
-rw-r--r-- 1 root root 1672 Jun 3 10:48 sample.py
-rw-r--r-- 1 root root 5214 Jun 22 11:36 tboard.py
-rw-r--r-- 1 root root 29687 Jun 22 12:09 test_train.ipynb
-rw-r--r-- 1 root root 1839 Jun 3 10:48 train2.py
-rw-r--r-- 1 root root 4887 Jun 18 13:31 train3.ipynb
-rw-r--r-- 1 root root 5859 Jun 18 13:40 train_f1.ipynb
-rw-r--r-- 1 root root 2310 Jun 3 10:48 train.py
-rw-r--r-- 1 root root 33651 Jun 3 10:48 Untitled.ipynb
-rw-r--r-- 1 root root 6935 Jun 21 13:21 utils.py
-rw-r--r-- 1 root root 6935 Jun 21 13:22 utils.py.1
-rw-r--r-- 1 root root 6935 Jun 21 13:58 utils.py.2
-rw-r--r-- 1 root root 6935 Jun 22 11:36 utils.py.3

yeah the wiget is downloading the file as utilis.py1,py2 etc .. so as you said i run the code !rm utilis.*

but after that i got error like below

--2018-06-22 12:13:26-- https://raw.githubusercontent.com/Zahlii/colab-tf-utils/master/utils.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6935 (6.8K) [text/plain]
Saving to: ‘utils.py’

utils.py 100%[===================>] 6.77K --.-KB/s in 0.09s

2018-06-22 12:13:28 (75.9 KB/s) - ‘utils.py’ saved [6935/6935]

Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (4.23.4)
Requirement already satisfied: keras in /usr/local/lib/python3.6/dist-packages (2.1.2)
Requirement already satisfied: numpy>=1.9.1 in /usr/local/lib/python3.6/dist-packages (from keras) (1.13.3)
Requirement already satisfied: scipy>=0.14 in /usr/local/lib/python3.6/dist-packages (from keras) (0.19.1)
Requirement already satisfied: pyyaml in /usr/local/lib/python3.6/dist-packages (from keras) (3.12)
Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.6/dist-packages (from keras) (1.11.0)
--2018-06-22 12:13:43-- https://raw.githubusercontent.com/mixuala/colab_utils/master/tboard.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5214 (5.1K) [text/plain]
Saving to: ‘tboard.py’

tboard.py 100%[===================>] 5.09K --.-KB/s in 0.09s

2018-06-22 12:13:45 (54.4 KB/s) - ‘tboard.py’ saved [5214/5214]


ModuleNotFoundError Traceback (most recent call last)

in run(input_path, output_path, is_memory_intensive, pretrained_model)
55 get_ipython().system('wget https://raw.githubusercontent.com/Zahlii/colab-tf-utils/master/utils.py')
56 import os
---> 57 import utils
58 import keras
59

/content/drive/sandupro/pix2code-master/model/utils.py in ()
9
10 import os
---> 11 import tboard
12 import copy
13 from tqdm import tqdm

ModuleNotFoundError: No module named 'tboard'

from colab-tf-utils.

Zahlii avatar Zahlii commented on June 7, 2024

This hints that something is wrong with your working directory as this project here attempts to download another external python file called tboard.py. It actually manages to download, but as you can see here:
ModuleNotFoundError: No module named 'tboard' it fails to localize this package. Can you try to post a minimum working example of when it fails? Also, make sure to clear out the colab kernel by clicking reconnect

from colab-tf-utils.

SandSandu avatar SandSandu commented on June 7, 2024
import os
os.chdir("drive/sandupro/pix2code-master/model")

from __future__ import print_function
from __future__ import absolute_import
__author__ = 'Tony Beltramelli - www.tonybeltramelli.com'
import tensorflow as tf
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
import sys
from classes.dataset.Generator import *
from classes.model.pix2code import *
def run(input_path, output_path, is_memory_intensive=False, pretrained_model=None):
    np.random.seed(1234)
    
    dataset = Dataset()
    dataset.load(input_path, generate_binary_sequences=True)
    dataset.save_metadata(output_path)
    dataset.voc.save(output_path)
    gui_paths, img_paths = Dataset.load_paths_only(input_path)
    input_shape = dataset.input_shape
    output_size = dataset.output_size
    steps_per_epoch = dataset.size / BATCH_SIZE
    voc = Vocabulary()
    voc.retrieve(output_path)
    generator = Generator.data_generator(voc, gui_paths, img_paths, batch_size=BATCH_SIZE, generate_binary_sequences=True)

    model = pix2code(input_shape, output_size, output_path)

    !wget https://raw.githubusercontent.com/Zahlii/colab-tf-utils/master/utils.py
    import os
    import utils
    import keras

    def compare(best, new):
      return best.losses['val_acc'] < new.losses['val_acc']

    def path(new):
         if new.losses['val_acc'] > 0.8:
          return 'VGG16_%s.h5' % new.losses['val_acc']    

    callbacks = cb = [ utils.GDriveCheckpointer(compare,path),keras.callbacks.TensorBoard(log_dir=os.path.join(utils.LOG_DIR,'VGG16')) ]
    model.fit_generator(generator, steps_per_epoch=steps_per_epoch)

  if __name__ == "__main__":
    input_path = '../datasets/web/training_features'  
    output_path = '/bin'
    use_generator = True
    pretrained_weigths = None
    run(input_path, output_path, is_memory_intensive=use_generator, pretrained_model=pretrained_weigths)

#############################################################

Loading data...
Generating sparse vectors...
Dataset size: 144017
Vocabulary size: 19
Input shape: (256, 256, 3)
Output size: 19
Parsing data...
--2018-06-22 13:02:50-- https://raw.githubusercontent.com/Zahlii/colab-tf-utils/master/utils.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.52.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.52.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6935 (6.8K) [text/plain]
Saving to: ‘utils.py’

utils.py 100%[===================>] 6.77K --.-KB/s in 0.09s

2018-06-22 13:02:52 (74.4 KB/s) - ‘utils.py’ saved [6935/6935]

Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (4.23.4)
Requirement already satisfied: keras in /usr/local/lib/python3.6/dist-packages (2.1.2)
Requirement already satisfied: scipy>=0.14 in /usr/local/lib/python3.6/dist-packages (from keras) (0.19.1)
Requirement already satisfied: numpy>=1.9.1 in /usr/local/lib/python3.6/dist-packages (from keras) (1.13.3)
Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.6/dist-packages (from keras) (1.11.0)
Requirement already satisfied: pyyaml in /usr/local/lib/python3.6/dist-packages (from keras) (3.12)
--2018-06-22 13:03:07-- https://raw.githubusercontent.com/mixuala/colab_utils/master/tboard.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5214 (5.1K) [text/plain]
Saving to: ‘tboard.py’

tboard.py 100%[===================>] 5.09K --.-KB/s in 0.1s

2018-06-22 13:03:10 (52.9 KB/s) - ‘tboard.py’ saved [5214/5214]


ModuleNotFoundError Traceback (most recent call last)
in ()
58 pretrained_weigths = None
59
---> 60 run(input_path, output_path, is_memory_intensive=use_generator, pretrained_model=pretrained_weigths)

in run(input_path, output_path, is_memory_intensive, pretrained_model)
36 get_ipython().system('wget https://raw.githubusercontent.com/Zahlii/colab-tf-utils/master/utils.py')
37 import os
---> 38 import utils
39 import keras
40

/content/drive/sandupro/pix2code-master/model/utils.py in ()
9
10 import os
---> 11 import tboard
12 import copy
13 from tqdm import tqdm

ModuleNotFoundError: No module named 'tboard'


this is the code which I was trying to run. am I doing anything wrong? @Zahlii

from colab-tf-utils.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.