Detectron MetadaCatalog and DatasetCatalog import Failed - python

I'm trying the include of Detectron2.data on Google Colab. I made the connection for colab & my drive. And after that:
!pip install pyyaml
!pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.7/index.html
It worked without any error.
i have been trying this;
import numpy as np
import os, json, cv2, random
from google.colab.patches import cv2_imshow
import detectron2
from detectron2.data import MetadataCatalog, DatasetCatalog
from detectron2.utils.visualizer import Visualizer
from detectron2 import model_zoo
But the outputs like this:
enter image description here
How can i fix that?

I fixed like this:
!pip install pyyaml==5.1
import torch, torchvision
print(torch.__version__, torch.cuda.is_available())
!gcc --version
import torch
assert torch.__version__.startswith("1.8")
!pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.8/index.html
# exit(0) # After installation, you need to "restart runtime" in Colab. This line can also restart runtime
from: https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5#scrollTo=ZyAvNCJMmvFF

Related

Cannot import tensorflow_io

I am getting ModuleNotFoundError when I try to import tensorflow_io.
I tried to fix the error as described in ModuleNotFoundError: No module named 'tensorflow_io' but it didn't work with me
I did the following and I was able to have the module imported in my machine,
pip install tensorflow
pip install tensorflow_io
then in a file.py you can import them
import tensorflow as tf
import tensorflow_io as tfio
I figure you need the tensorflow module installed if you want to use the tensorflow_io.

Installed transforemers but cannot be imported on Google CoLab / StableDiffusion

I am trying to run the stablediffusion example from this link: https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/stable_diffusion.ipynb#scrollTo=zTDA0fvtuOIQ
!pip install diffusers==0.3.0
!pip install transformers scipy ftfy
!pip install "ipywidgets>=7,<8"
!pip install transformers
from google.colab import output
output.enable_custom_widget_manager()
from huggingface_hub import notebook_login
notebook_login()
I installed the required dependencies and restarted the runtime and then ran the following code:
import torch from diffusers import StableDiffusionPipeline pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", revision="fp16", torch_dtype=torch.float16, use_auth_token=True)
But It spits out the following errors:
ImportError: cannot import name 'CLIPFeatureExtractor' from 'transformers' (/usr/local/lib/python3.7/dist-packages/transformers/init.py)
How should I fix the problem?

ModuleNotFoundError: No module named 'tensorflow.contrib' Error

I am getting such an error in the keras codes ,wrote in pycharm.Tried the solutions on the internet but I couldn't find a solution. Do you have any suggestions?
Error Image
Pip List
Please install the tensorflow and pillow using pip install tensorflow and pip install pillow then do a little changes as below while importing libraries to fix this error:
import numpy as np
from PIL import Image
from tensorflow import keras
from tensorflow.keras.applications import resnet50
from tensorflow.keras.preprocessing import image
Note: Please mention the error code in your question not in the form of a screenshot which will be easy to replicate the issue.

module 'tensorflow_federated.python' has no attribute 'federated_computation'

I follow the instructions in the github that says to install Tensorflow Federated with Collab we need to install version 0.20.0 but I get this error when I try to run the toturials.
!pip install --quiet tensorflow-federated==0.20.0 # The latest version of tensorflow-federated is not working with the colab python version
!pip install --quiet --upgrade nest-asyncio
from __future__ import absolute_import, division, print_function
import collections
from six.moves import range
import numpy as np
import tensorflow as tf
# from tensorflow import compat
from tensorflow_federated import python as tff
np.random.seed(0)
tf.compat.v1.enable_v2_behavior()
tff.federated_computation(lambda: 'Hello, World!')()
Error:
module 'tensorflow_federated.python' has no attribute 'federated_computation'
What is the problem I don't understand? How can I install it on google colab. There is no resource for this problem.
Are you sure you need to import this
from tensorflow_federated import python as tff
instead of
import tensorflow_federated as tff
According to the Tensorflow docs, the federated_computation was under tensorflow_federated directly.

GraphViz's executables not found error in Anaconda?

I wrote the following code to build the decision tree, but I got the following error. can you help me?
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
import pandas as pd
import numpy as np
from six import StringIO
from sklearn.tree import export_graphviz
from sklearn import tree
import pydot
from IPython.display import Image
import pydotplus
import graphviz
dot_data = StringIO()
export_graphviz(decisionTree1, out_file =dot_data, filled=True,
rounded =True, special_characters=True)
graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
Image(graph.create_png())
If you are using Linux try this in cmd: sudo apt-get install graphviz
If using macOS, try this brew install graphviz
i) If on windows install it by conda conda install graphviz and add path env variables C:\Users\username\Anaconda3\Library\bin\graphviz
ii) Try to install it via conda install python-graphviz

Categories

Resources