Tutorial: Classify text with BERT Cannot install dependencies by pip in Colab
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 379
- Avg merge
- 3h 30m
- Merged PRs (30d)
- 8
Description
Hi, I am now tring to run the Classify text with BERT tutorial in Colab. But I got the following error when I run the cell.
import os
import shutil
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_text as text
from official.nlp import optimization # to create AdamW optimizer
import matplotlib.pyplot as plt
tf.get_logger().setLevel('ERROR')
ModuleNotFoundError Traceback (most recent call last)
in <cell line: 7>()
5 import tensorflow_hub as hub
6 import tensorflow_text as text
----> 7 from official.nlp import optimization # to create AdamW optimizer
8
9 import matplotlib.pyplot as pltModuleNotFoundError: No module named 'official'
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.To view examples of installing some common dependencies, click the
"Open Examples" button below.
In the previous cell, when I run !pip install -q tf-models-official==2.11.0 I got the following error.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.9/118.9 kB 4.3 MB/s eta 0:00:00 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.6/43.6 kB 3.2 MB/s eta 0:00:00Preparing metadata (setup.py) ... done
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 33.1 MB/s eta 0:00:00
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 240.6/240.6 kB 22.7 MB/s eta 0:00:00
ERROR: Could not find a version that satisfies the requirement opencv-python-headless==4.5.2.52 (from tf-models-official) (from versions: 3.4.10.37, 3.4.11.39, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.15.55, 3.4.16.59, 3.4.17.61, 3.4.17.63, 3.4.18.65, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64, 4.6.0.66, 4.7.0.68, 4.7.0.72)
ERROR: No matching distribution found for opencv-python-headless==4.5.2.52
I could install offcial by !pip install -q tf-models-official. But in the next cell I got the other error... Could you tell me the correct instruction to isntall the dependency?
import os
import shutilimport tensorflow as tf
import tensorflow_hub as hub
import tensorflow_text as text
from official.nlp import optimization # to create AdamW optimizerimport matplotlib.pyplot as plt
tf.get_logger().setLevel('ERROR')
AssertionError Traceback (most recent call last)
in <cell line: 7>()
5 import tensorflow_hub as hub
6 import tensorflow_text as text
----> 7 from official.nlp import optimization # to create AdamW optimizer
8
9 import matplotlib.pyplot as plt11 frames
/usr/local/lib/python3.10/dist-packages/tensorflow/python/saved_model/revived_types.py in register_revived_type(identifier, predicate, versions)
131
132 if identifier in _REVIVED_TYPE_REGISTRY:
--> 133 raise AssertionError(f"Duplicate registrations for type '{identifier}'")
134
135 _REVIVED_TYPE_REGISTRY[identifier] = (predicate, versions)AssertionError: Duplicate registrations for type 'experimentalOptimizer'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docs/tutorials/classify_text_with_bert.ipynb and reproduce the dependency-install and import cells in Colab. Check the reported tf-models-official, opencv-python-headless, and TensorFlow errors against the tutorial's documented versions. Done means the dependency cell completes and the subsequent imports run without errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, opencv, python, tensorflow
- Domain
- documentation, machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100