No OUTPUT from Jupyter Notebook. NO Error Shown - python-3.x

I am running a Jupyter notebook but I do not get any output or error telling me if something is wrong. I have tried installing tornado as some other threads have suggested as well as the command pip install notebook --upgrade
While I do not think there is a problem with my code here it is.
Any help is truly appreciated.
import os
import numpy as np
import pandas as pd
import cv2
from glob import glob
import tensorflow as tf
from tensorflow.keras.layers import *
from tensorflow.keras.applications import MobileNetV2
from tensorflow.keras.callbacks import ModelCheckpoint, ReduceLROnPlateau
from tensorflow.keras.optimizers import Adam
from sklearn.model_selection import train_test_split
if __name__=="_main_":
path="dog-breed-identification/"
train_path = os.path.join(path, "train/*")
train_path = os.path.join(path, "test/*")
train_path = os.path.join(path, "labels.csv")
labels_df = pd.read_csv(labels_path)
#name of column in csv
breed = labels_df["breed"].unique()
print("Number of Breed: ", len(breed))
enter code here

As it turns out, if I delete
if __name__=="_main_":
I get an output

Related

ImportError: cannot import name 'int_classes' from 'torch._six' (/usr/local/lib/python3.7/dist-packages/torch/_six.py)

I am working on healthcare image dataset for image segmentation. More specific, it is "Spinal Cord Gray Matter Segmentation Using PyTorch". When I am trying to install libraries initially using this code:
!pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.0-cp36-cp36m-linux_x86_64.whl
!pip3 install torchvision
!pip install medicaltorch
!pip3 install numpy==1.14.1
it is showing some errors in between required satisfied like this:
1st screenshot
2nd screenshot
After that I am importing libraries:
from collections import defaultdict
import time
import os
import numpy as np
from tqdm import tqdm
from medicaltorch import datasets as mt_datasets
from medicaltorch import models as mt_models
from medicaltorch import transforms as mt_transforms
from medicaltorch import losses as mt_losses
from medicaltorch import metrics as mt_metrics
from medicaltorch import filters as mt_filters
import torch
from torchvision import transforms
from torch.utils.data import DataLoader
from torch import autograd, optim
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torchvision.utils as vutils
cudnn.benchmark = True
import matplotlib.pyplot as plt
%matplotlib inline
This importing is throwing an error like this:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-8-80b8c583d1fe> in <module>()
20
21
---> 22 from medicaltorch import datasets as mt_datasets
23 from medicaltorch import models as mt_models
24 from medicaltorch import transforms as mt_transforms
/usr/local/lib/python3.7/dist-packages/medicaltorch/datasets.py in <module>()
11 from torch.utils.data import Dataset
12 import torch
---> 13 from torch._six import string_classes, int_classes
14
15 from PIL import Image
ImportError: cannot import name 'int_classes' from 'torch._six' (/usr/local/lib/python3.7/dist-packages/torch/_six.py)
---------------------------------------------------------------------------
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.
---------------------------------------------------------------------------
can someone help me resolve this?
In pytorch 1.9 int_classes variable in torch._six was removed. facebookresearch/TimeSformer#47
Use this code instead.
from torch._six import string_classes
int_classes = (bool, int)
See source here: https://github.com/visionml/pytracking/issues/272

tensorflow 2.0, tfds.load 'utf-8' codec error

Imports & Settings
%matplotlib inline
from pathlib import Path
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
import seaborn as sns
import tensorflow as tf
from tensorflow.keras.applications.densenet import DenseNet201
from tensorflow.keras.layers import Dense, BatchNormalization
from tensorflow.keras.models import Sequential
from tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping
from tensorflow.keras.regularizers import l1_l2
from tensorflow.keras.optimizers import Adam
import tensorflow_datasets as tfds
Load EuroSat Dataset
(raw_train, raw_validation), metadata = tfds.load('eurosat',
split=['train[:90%]','train[90%:]'],
with_info=True,
shuffle_files=False,
as_supervised=True,
data_dir='../data/tensorflow')
i got error message
how can i fix it?
i use tensorflow2
I guess there's a problem with the codec.

Tensorflow Lite Model Maker error: object has no attribute 'index_to_label'

I'm usign Tensorflow Lite Model Maker to adapt a model to citrus_leaves dataset, but following the documentation I get this error:
AttributeError: 'PrefetchDataset' object has no attribute
'index_to_label'
I'm making this code on Google colab:
!pip install -q tflite-model-maker
!pip install tensorflow-datasets
!pip install tfds-nightly
import os
import numpy as np
import tensorflow as tf
assert tf.__version__.startswith('2')
from tflite_model_maker import model_spec
from tflite_model_maker import image_classifier
from tflite_model_maker.config import ExportFormat
from tflite_model_maker.config import QuantizationConfig
from tflite_model_maker.image_classifier import DataLoader
import tensorflow_datasets as tfds
import matplotlib.pyplot as plt
(test_data, train_data), info = tfds.load('citrus_leaves', split=["train[:20%]", "train[20%:]"], shuffle_files=True, with_info=True, as_supervised=True)
model = image_classifier.create(train_data) # Here the error happens
loss, accuracy = model.evaluate(test_data)
Here is the Link to dataset
and here is the link to the docs that I was following.
I have no idea why this error is happening, I would be grateful if someone could help me.
Thanks!

Run TensorBoard on Colab

I have following code
!pip install timm
import timm
from torchsummary import summary
import torchvision.models as models
import torch
import os
from torch.utils.tensorboard import SummaryWriter
%load_ext tensorboard
#model = models.inception_v3(pretrained=False)
model = timm.create_model('inception_v4', pretrained=False)
#model.cuda()
summary(model, (3, 440, 440))
writer=SummaryWriter('/content/logsdir')
%tensorboard --logdir /content/logsdir
When the code is run, there is error as No graph definition files were found. What could be wrong?
Use Built-in magic commands https://ipython.readthedocs.io/en/stable/interactive/magics.html
Read reference document at https://colab.research.google.com/github/tensorflow/tensorboard/blob/master/docs/tensorboard_in_notebooks.ipynb

How can I solve this problem in vs code, ipython (tensorflow)?

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import check_util.checker as checker
from IPython.display import clear_output
from PIL import Image
import os
import time
import re
from glob import glob
import shutil
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow import keras
print('tensorflow version: {}'.format(tf.__version__))
print('GPU available: {}'.format(tf.test.is_gpu_available()))
When I run this, there is no error. But it shows as indefinitely in progress.
(Current 630..631..632...sec)

Resources