Comments (2)
same here. running this via the tweet package and got this traceback:
python3 tweet_generator.py
Traceback (most recent call last):
File "tweet_generator.py", line 6, in <module>
from textgenrnn import textgenrnn
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/textgenrnn/__init__.py", line 1, in <module>
from .textgenrnn import textgenrnn
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/textgenrnn/textgenrnn.py", line 1, in <module>
from tensorflow.keras.callbacks import LearningRateScheduler, Callback
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/keras/__init__.py", line 19, in <module>
from . import datasets
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/keras/datasets/__init__.py", line 14, in <module>
from . import imdb
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/keras/datasets/imdb/__init__.py", line 11, in <module>
from tensorflow.python.keras.datasets.imdb import get_word_index
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/keras/datasets/imdb.py", line 25, in <module>
from tensorflow.python.keras.preprocessing.sequence import _remove_long_seq
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/keras/preprocessing/__init__.py", line 26, in <module>
from tensorflow.python.keras.preprocessing import image
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/keras/preprocessing/image.py", line 24, in <module>
from keras_preprocessing import image
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras_preprocessing/image.py", line 20, in <module>
backend = get_keras_submodule('backend')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keras_preprocessing/__init__.py", line 24, in get_keras_submodule
raise ImportError('You need to first `import keras` '
ImportError: You need to first `import keras` in order to use `keras_preprocessing`. For instance, you can do:
\```
import keras
from keras_preprocessing import image
\```
Or, preferably, this equivalent formulation:
\```
from keras import preprocessing
\```
any ideas how to resolve this?
edit: okay, updating tensor flow fixed that for me and then it turned into another issue #197 (for which a fix was provided fortunately)
from textgenrnn.
Hi, I have spent quite a lot of time solving this problem.
The problem was in keras_applications.
There is two possible way to face this error message:
- When the keras_applications library version is too old
- When keras_applications are new but having trouble with TensorFlow's keras_preprocessing library
Anyway it occurred by .json file we can solve this problem by reinstalling Tensorflow and Keras-related things but I know that this works heavily stressful.
This is my personal recommendation for this kind of errors.
- If you are sure that you installed Keras perfectly then just skipping its check process of Keras backend.
First, find your path of 'keras_applications' are installed (It might be in such 'C:\ProgramData\Anaconda3\Lib\site-packages' Or, just use 'pip show keras_applications')
And then, open (imagenet_utils.py) than edit it like this
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import keras
import json
import warnings
import numpy as np
from . import get_keras_submodule
from . import set_keras_submodules
backend = set_keras_submodules('backend')
backed = 'backend'
keras_utils = get_keras_submodule('utils')
CLASS_INDEX = None
CLASS_INDEX_PATH = ('https://s3.amazonaws.com/deep-learning-models/'
'image-models/imagenet_class_index.json')
# Global tensor of imagenet mean for preprocessing symbolic inputs
_IMAGENET_MEAN = None
...
It's just editing check flag rightly (It should be checked by Keras backend API but because of version issue it impossible to check automatically sometimes).
- This is possibly happening with the 'keras_preprocessing' library for the recent version (because some parts of 'keras_applications' are moved to 'keras_preprocessing) in this case you should edit the same parts on 'keras_preprocessing'
I know that this is not a perfect solution for the code, But it works okay temporarily.
(But I still highly recommend resetting your env..!)
from textgenrnn.
Related Issues (20)
- train_on_texts gets stuck HOT 2
- Train to generate about Business HOT 2
- Why is the code so broken? HOT 6
- Failed to call ThenRnnForward HOT 1
- notebook errors HOT 4
- Unable to clone git using Colab HOT 2
- ImportError: cannot import name 'multi_gpu_model' from 'tensorflow.keras.utils' HOT 1
- disable progressbar on GENERATION HOT 5
- uses all my vram HOT 1
- what should you have before training. - txt HOT 1
- please use aitextgen for better results
- All dependencies are impossible to install or import.
- Can this "app" be run locally? If so, how? HOT 2
- textgen.generate(n) does not produce n lines.
- Using this module in browser
- How to train on question->answer dataset?
- Can't install on Linux HOT 2
- Can't install on Linux HOT 1
- change to float16 instead of 32?
- New PyPI package
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textgenrnn.