添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hi all, I am running an example in colab but when I get to this code I’m getting an error!

class PrettyWidget(QtGui.QWidget):
SyntaxError: unexpected EOF while parsing,

As a solution, I installed the specific packages for PyQt5 and the QtGui modules as PyQt4 is not working but that was futile!

I tried this solution Ui_Widget(QtWidgets.QWidget) based on my google search but that did not work also!

can some one guide with this procedure, please? My limited understanding is hindering my processing forward.

thank you in advance for acknowledging my digital presence!

MY CODE:

For the current version:

!pip install --upgrade tensorflow
!pip install tfLearn
!pip install tqdm
!pip install keras
!apt-get -qq install -y libfluidsynth1
!pip install numpy
!pip install PyQt5
!pip install QtGui
!pip install QtWidgets

from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation
from keras.regularizers import l2
from keras.optimizers import SGD ,Adagrad
from scipy.io import loadmat, savemat
from keras.models import model_from_json
import theano.tensor as T
import theano
import csv
import configparser
import collections
import time
import csv
from math import factorial
import os
from os import listdir
import skimage.transform
from skimage import color
from os.path import isfile, join
import numpy as np
import numpy
from datetime import datetime
from scipy.spatial.distance import cdist,pdist,squareform
import theano.sandbox
#import c3D_model
#import Initialization_function
#from moviepy.editor import VideoFileClip
#from IPython.display import Image, display
import matplotlib.pyplot as plt
import cv2
import os, sys
import pickle
from PyQt5 import QtGui # If PyQt4 is not working in your case, you can try PyQt5
import qtwidgets
seed = 7
numpy.random.seed(seed)

def load_model(json_path):
model = model_from_json(open(json_path).read())
return model

def load_weights(model, weight_path):
dict2 = loadmat(weight_path)
dict = conv_dict(dict2)
i = 0
for layer in model.layers:
weights = dict[str(i)]
layer.set_weights(weights)
i += 1
return model

def conv_dict(dict2): # Helper function to save the model
i = 0
dict = {}
for i in range(len(dict2)):
if str(i) in dict2:
if dict2[str(i)].shape == (0, 0):
dict[str(i)] = dict2[str(i)]
else:
weights = dict2[str(i)][0]
weights2 =
for weight in weights:
if weight.shape in [(1, x) for x in range(0, 5000)]:
weights2.append(weight[0])
else:
weights2.append(weight)
dict[str(i)] = weights2
return dict

def savitzky_golay(y, window_size, order, deriv=0, rate=1):
#try:
window_size = np.abs(np.int(window_size))
order = np.abs(np.int(order))
#except ValueError, msg:
#raise ValueError(“window_size and order have to be of type int”)

if window_size % 2 != 1 or window_size < 1:
    raise TypeError("window_size size must be a positive odd number")
if window_size < order + 2:
    raise TypeError("window_size is too small for the polynomials order")
order_range = range(order + 1)
half_window = (window_size - 1) // 2
b = np.mat([[k ** i for i in order_range] for k in range(-half_window, half_window + 1)])
m = np.linalg.pinv(b).A[deriv] * rate ** deriv * factorial(deriv)
firstvals = y[0] - np.abs(y[1:half_window + 1][::-1] - y[0])
lastvals = y[-1] + np.abs(y[-half_window - 1:-1][::-1] - y[-1])
y = np.concatenate((firstvals, y, lastvals))
return np.convolve(m[::-1], y,mode='valid')

Loading The Video Data

def load_dataset_One_Video_Features(Test_Video_Path):

VideoPath =Test_Video_Path
f = open(VideoPath, "r")
words = f.read().split()
num_feat = len(words) / 4096
# Number of features per video to be loaded. In our case num_feat=32, as we divide the video into 32 segments. Npte that
# we have already computed C3D features for the whole video and divide the video features into 32 segments.
count = -1;
VideoFeatues = []
for feat in range(0, int(num_feat)):
    feat_row1 = np.float32(words[feat * 4096:feat * 4096 + 4096])
    count = count + 1
    if count == 0:
        VideoFeatues = feat_row1
    if count > 0:
        VideoFeatues = np.vstack((VideoFeatues, feat_row1))
AllFeatures = VideoFeatues
return  AllFeatures

class PrettyWidget(QtGui.QWidget):

ERROR:
File “”, line 1
class PrettyWidget(QtGui.QWidget):
SyntaxError: unexpected EOF while parsing

HI DB,

I tried your solution by adding all of the code, I tried thisbefore but still the error persist! so I was trying to figure out line by line where the error is! please see the code for the demo taken from the link at very top of ALL OF The CODE!

I checked the packages in the foldder based on the error and the file is there but I am not sure why this error persist!

Can you guide me with this error, please so that I can understand what I am doing wrong? thanx in advance!

ALL OF THE CODE

#Example Taken From:
GitHub !pip install matplotlib

from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation
from keras.regularizers import l2
from keras.optimizers import SGD ,Adagrad
from scipy.io import loadmat, savemat
from keras.models import model_from_json
import theano.tensor as T
import theano
import csv
import configparser
import collections
import time
import csv
from math import factorial
import os
from os import listdir
import skimage.transform
from skimage import color
from os.path import isfile, join
import numpy as np
import numpy
from datetime import datetime
from scipy.spatial.distance import cdist,pdist,squareform
import theano.sandbox
#import c3D_model
#import Initialization_function
#from moviepy.editor import VideoFileClip
#from IPython.display import Image, display
import matplotlib.pyplot as plt
import cv2
import os, sys
import pickle
from PyQt5 import QtGui # If PyQt4 is not working in your case, you can try PyQt5
import qtwidgets
seed = 7
numpy.random.seed(seed)

def load_model(json_path):
model = model_from_json(open(json_path).read())
return model

def load_weights(model, weight_path):
dict2 = loadmat(weight_path)
dict = conv_dict(dict2)
i = 0
for layer in model.layers:
weights = dict[str(i)]
layer.set_weights(weights)
i += 1
return model

def conv_dict(dict2): # Helper function to save the model
i = 0
dict = {}
for i in range(len(dict2)):
if str(i) in dict2:
if dict2[str(i)].shape == (0, 0):
dict[str(i)] = dict2[str(i)]
else:
weights = dict2[str(i)][0]
weights2 =
for weight in weights:
if weight.shape in [(1, x) for x in range(0, 5000)]:
weights2.append(weight[0])
else:
weights2.append(weight)
dict[str(i)] = weights2
return dict

def savitzky_golay(y, window_size, order, deriv=0, rate=1):
#try:
window_size = np.abs(np.int(window_size))
order = np.abs(np.int(order))
#except ValueError, msg:
#raise ValueError(“window_size and order have to be of type int”)

if window_size % 2 != 1 or window_size < 1:
    raise TypeError("window_size size must be a positive odd number")
if window_size < order + 2:
    raise TypeError("window_size is too small for the polynomials order")
order_range = range(order + 1)
half_window = (window_size - 1) // 2
b = np.mat([[k ** i for i in order_range] for k in range(-half_window, half_window + 1)])
m = np.linalg.pinv(b).A[deriv] * rate ** deriv * factorial(deriv)
firstvals = y[0] - np.abs(y[1:half_window + 1][::-1] - y[0])
lastvals = y[-1] + np.abs(y[-half_window - 1:-1][::-1] - y[-1])
y = np.concatenate((firstvals, y, lastvals))
return np.convolve(m[::-1], y,mode='valid')
# Loading The Video Data

def load_dataset_One_Video_Features(Test_Video_Path):

VideoPath =Test_Video_Path
f = open(VideoPath, "r")
words = f.read().split()
num_feat = len(words) / 4096
# Number of features per video to be loaded. In our case num_feat=32, as we divide the video into 32 segments. Npte that
# we have already computed C3D features for the whole video and divide the video features into 32 segments.
count = -1;
VideoFeatues = []
for feat in range(0, int(num_feat)):
    feat_row1 = np.float32(words[feat * 4096:feat * 4096 + 4096])
    count = count + 1
    if count == 0:
        VideoFeatues = feat_row1
    if count > 0:
        VideoFeatues = np.vstack((VideoFeatues, feat_row1))
AllFeatures = VideoFeatues
return  AllFeatures

class PrettyWidget(QtGui.QWidget):

def init(self):
super(PrettyWidget, self).init()
self.initUI()

def initUI(self):
self.setGeometry(500, 100, 500, 500)
self.setWindowTitle(‘Anomaly Detection’)
btn = QtGui.QPushButton(‘ANOMALY DETECTION SYSTEM \n Please select video’, self)

    Model_dir = '/home/cvlab/Waqas_Data/Anomaly_Data/Pre_TrainedModels/L1L2/'
    weights_path = Model_dir + 'weights_L1L2.mat'
    model_path = Model_dir + 'model.json'
    ########################################
    ######    LOAD ABNORMALITY MODEL   ######
    global model
    model = load_model(model_path)
    load_weights(model, weights_path)
    #####   LOAD C3D Pre-Trained Network #####
   # global score_function
   # score_function = Initialization_function.get_prediction_function()

def init(self):
super(PrettyWidget, self).init()
self.initUI()

def initUI(self):
self.setGeometry(500, 100, 500, 500)
self.setWindowTitle(‘Anomaly Detection’)
btn = QtGui.QPushButton(‘ANOMALY DETECTION SYSTEM \n Please select video’, self)

    Model_dir = '/home/cvlab/Waqas_Data/Anomaly_Data/Pre_TrainedModels/L1L2/'
    weights_path = Model_dir + 'weights_L1L2.mat'
    model_path = Model_dir + 'model.json'
    ########################################
    ######    LOAD ABNORMALITY MODEL   ######
    global model
    model = load_model(model_path)
    load_weights(model, weights_path)
    #####   LOAD C3D Pre-Trained Network #####
   # global score_function
   # score_function = Initialization_function.get_prediction_function()
    btn.resize(btn.sizeHint())
    btn.clicked.connect(self.SingleBrowse)
    btn.move(150, 200)
    self.show()

def SingleBrowse(self):
video_path = QtGui.QFileDialog.getOpenFileName(self,
‘Single File’,
“/home/cvlab/Waqas_Data/Anomaly_Data/Normal_test_abn”)

    print(video_path)
    cap = cv2.VideoCapture(video_path)
    #Total_frames = cap.get(cv2.CV_CAP_PROP_FRAME_COUNT)
    print(cv2)
    Total_frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)
    total_segments = np.linspace(1, Total_frames, num=33)
    total_segments = total_segments.round()
    FeaturePath=(video_path)
    FeaturePath = FeaturePath[0:-4]
    FeaturePath = FeaturePath+ '.txt'
    inputs = load_dataset_One_Video_Features(FeaturePath)
    #inputs = np.reshape(inputs, (32, 4096))
    predictions = model.predict_on_batch(inputs)
    Frames_Score = []
    count = -1;
    for iv in range(0, 32):
        F_Score = np.matlib.repmat(predictions[iv],1,(int(total_segments[iv+1])-int(total_segments[iv])))
        count = count + 1
        if count == 0:
          Frames_Score = F_Score
        if count > 0:
          Frames_Score = np.hstack((Frames_Score, F_Score))
    cap = cv2.VideoCapture((video_path))
    while not cap.isOpened():
        cap = cv2.VideoCapture((video_path))
        cv2.waitKey(1000)
        print ("Wait for the header")
    pos_frame = cap.get(cv2.CAP_PROP_POS_FRAMES)
    Total_frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)
    print ("Anomaly Prediction")
    x = np.linspace(1, Total_frames, Total_frames)
    scores = Frames_Score
    scores1=scores.reshape((scores.shape[1],))
    scores1 = savitzky_golay(scores1, 101, 3)
    plt.close()
    break_pt=min(scores1.shape[0], x.shape[0])
    plt.axis([0, Total_frames, 0, 1])
    while True:
        flag, frame = cap.read()
        if flag:
            i = i + 1
            cv2.imshow('video', frame)
            jj=i%25
            if jj==1:
                plt.plot(x[:i], scores1[:i], color='r', linewidth=3)
                plt.draw()
                plt.pause(0.000000000000000000000001)
            pos_frame = cap.get(cv2.CAP_PROP_POS_FRAMES)
            print (str(pos_frame) + " frames")
        else:
            # The next frame is not ready, so we try to read it again
            cap.set(cv2.CAP_PROP_POS_FRAMES, pos_frame - 1)
            print("frame is not ready")
            # It is better to wait for a while for the next frame to be ready
            cv2.waitKey(1000)
        if cv2.waitKey(10) == 27:
            break
        if cap.get(cv2.CAP_PROP_POS_FRAMES)== break_pt:
            #cap.get(cv2.CAP_PROP_FRAME_COUNT):
            # If the number of captured frames is equal to the total number of frames,
            # we stop
            break

def main():
app = QtGui.QApplication(sys.argv)
w = PrettyWidget()
app.exec_()

main()

OUTPUT*******

Requirement already satisfied: wheel>=0.26 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (0.35.1)
Requirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.15.0)
Requirement already satisfied: numpy<1.19.0,>=1.16.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.18.5)
Requirement already satisfied: absl-py>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (0.10.0)
Requirement already satisfied: google-pasta>=0.1.8 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (0.2.0)
Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (1.7.0)
Requirement already satisfied: requests<3,>=2.21.0 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (2.23.0)
Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (1.0.1)
Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (0.4.2)
Requirement already satisfied: setuptools>=41.0.0 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (50.3.2)
Requirement already satisfied: google-auth<2,>=1.6.3 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (1.17.2)
Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (3.3.3)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (2.10)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (2020.6.20)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (1.24.3)
Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<3,>=2.3.0->tensorflow) (1.3.0)
Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (0.2.8)
Requirement already satisfied: cachetools<5.0,>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (4.1.1)
Requirement already satisfied: rsa<5,>=3.1.4; python_version >= “3” in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (4.6)
Requirement already satisfied: importlib-metadata; python_version < “3.8” in /usr/local/lib/python3.6/dist-packages (from markdown>=2.6.8->tensorboard<3,>=2.3.0->tensorflow) (2.0.0)
Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.6/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<3,>=2.3.0->tensorflow) (3.1.0)
Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /usr/local/lib/python3.6/dist-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (0.4.8)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata; python_version < “3.8”->markdown>=2.6.8->tensorboard<3,>=2.3.0->tensorflow) (3.4.0)
Collecting tensorflow
Downloading (320.4MB)
|████████████████████████████████| 320.4MB 48kB/s
Requirement already satisfied, skipping upgrade: gast==0.3.3 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (0.3.3)
Requirement already satisfied, skipping upgrade: astunparse==1.6.3 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.6.3)
Requirement already satisfied, skipping upgrade: google-pasta>=0.1.8 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (0.2.0)
Requirement already satisfied, skipping upgrade: opt-einsum>=2.3.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (3.3.0)
Requirement already satisfied, skipping upgrade: tensorflow-estimator<2.4.0,>=2.3.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (2.3.0)
Requirement already satisfied, skipping upgrade: wrapt>=1.11.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.12.1)
Requirement already satisfied, skipping upgrade: numpy<1.19.0,>=1.16.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.18.5)
Requirement already satisfied, skipping upgrade: six>=1.12.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.15.0)
Requirement already satisfied, skipping upgrade: grpcio>=1.8.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.33.2)
Requirement already satisfied, skipping upgrade: termcolor>=1.1.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.1.0)
Requirement already satisfied, skipping upgrade: h5py<2.11.0,>=2.10.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (2.10.0)
Requirement already satisfied, skipping upgrade: protobuf>=3.9.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (3.12.4)
Requirement already satisfied, skipping upgrade: tensorboard<3,>=2.3.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (2.3.0)
Requirement already satisfied, skipping upgrade: keras-preprocessing<1.2,>=1.1.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (1.1.2)
Requirement already satisfied, skipping upgrade: wheel>=0.26 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (0.35.1)
Requirement already satisfied, skipping upgrade: absl-py>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (0.10.0)
Requirement already satisfied, skipping upgrade: setuptools in /usr/local/lib/python3.6/dist-packages (from protobuf>=3.9.2->tensorflow) (50.3.2)
Requirement already satisfied, skipping upgrade: markdown>=2.6.8 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (3.3.3)
Requirement already satisfied, skipping upgrade: google-auth<2,>=1.6.3 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (1.17.2)
Requirement already satisfied, skipping upgrade: werkzeug>=0.11.15 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (1.0.1)
Requirement already satisfied, skipping upgrade: google-auth-oauthlib<0.5,>=0.4.1 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (0.4.2)
Requirement already satisfied, skipping upgrade: requests<3,>=2.21.0 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (2.23.0)
Requirement already satisfied, skipping upgrade: tensorboard-plugin-wit>=1.6.0 in /usr/local/lib/python3.6/dist-packages (from tensorboard<3,>=2.3.0->tensorflow) (1.7.0)
Requirement already satisfied, skipping upgrade: importlib-metadata; python_version < “3.8” in /usr/local/lib/python3.6/dist-packages (from markdown>=2.6.8->tensorboard<3,>=2.3.0->tensorflow) (2.0.0)
Requirement already satisfied, skipping upgrade: rsa<5,>=3.1.4; python_version >= “3” in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (4.6)
Requirement already satisfied, skipping upgrade: cachetools<5.0,>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (4.1.1)
Requirement already satisfied, skipping upgrade: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (0.2.8)
Requirement already satisfied, skipping upgrade: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<3,>=2.3.0->tensorflow) (1.3.0)
Requirement already satisfied, skipping upgrade: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (2.10)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (2020.6.20)
Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (1.24.3)
Requirement already satisfied, skipping upgrade: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.21.0->tensorboard<3,>=2.3.0->tensorflow) (3.0.4)
Requirement already satisfied, skipping upgrade: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata; python_version < “3.8”->markdown>=2.6.8->tensorboard<3,>=2.3.0->tensorflow) (3.4.0)
Requirement already satisfied, skipping upgrade: pyasn1>=0.1.3 in /usr/local/lib/python3.6/dist-packages (from rsa<5,>=3.1.4; python_version >= “3”->google-auth<2,>=1.6.3->tensorboard<3,>=2.3.0->tensorflow) (0.4.8)
Requirement already satisfied, skipping upgrade: oauthlib>=3.0.0 in /usr/local/lib/python3.6/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<3,>=2.3.0->tensorflow) (3.1.0)
Installing collected packages: tensorflow
Found existing installation: tensorflow 2.3.0
Uninstalling tensorflow-2.3.0:
Successfully uninstalled tensorflow-2.3.0
Successfully installed tensorflow-2.3.1
Collecting tfLearn
Downloading (98kB)
|████████████████████████████████| 102kB 2.8MB/s
Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from tfLearn) (1.18.5)
Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from tfLearn) (1.15.0)
Requirement already satisfied: Pillow in /usr/local/lib/python3.6/dist-packages (from tfLearn) (7.0.0)
Building wheels for collected packages: tfLearn
Building wheel for tfLearn (setup.py) … done
Created wheel for tfLearn: filename=tflearn-0.3.2-cp36-none-any.whl size=128207 sha256=1a63c58ac94e163773108e37553d5303d8600b8e11807282537a50c474ce8ba7
Stored in directory: /root/.cache/pip/wheels/d0/f6/69/0ef3ee395aac2e5d15d89efd29a9a216f3c27767b43b72c006
Successfully built tfLearn
Installing collected packages: tfLearn
Successfully installed tfLearn-0.3.2
Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (4.41.1)
Requirement already satisfied: keras in /usr/local/lib/python3.6/dist-packages (2.4.3)
Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from keras) (2.10.0)
Requirement already satisfied: pyyaml in /usr/local/lib/python3.6/dist-packages (from keras) (3.13)
Requirement already satisfied: numpy>=1.9.1 in /usr/local/lib/python3.6/dist-packages (from keras) (1.18.5)
Requirement already satisfied: scipy>=0.14 in /usr/local/lib/python3.6/dist-packages (from keras) (1.4.1)
Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from h5py->keras) (1.15.0)
Requirement already satisfied: sklearn in /usr/local/lib/python3.6/dist-packages (0.0)
Requirement already satisfied: scikit-learn in /usr/local/lib/python3.6/dist-packages (from sklearn) (0.22.2.post1)
Requirement already satisfied: numpy>=1.11.0 in /usr/local/lib/python3.6/dist-packages (from scikit-learn->sklearn) (1.18.5)
Requirement already satisfied: scipy>=0.17.0 in /usr/local/lib/python3.6/dist-packages (from scikit-learn->sklearn) (1.4.1)
Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.6/dist-packages (from scikit-learn->sklearn) (0.17.0)
Selecting previously unselected package libfluidsynth1:amd64.
(Reading database … 144628 files and directories currently installed.)
Preparing to unpack …/libfluidsynth1_1.1.9-1_amd64.deb …
Unpacking libfluidsynth1:amd64 (1.1.9-1) …
Setting up libfluidsynth1:amd64 (1.1.9-1) …
Processing triggers for libc-bin (2.27-3ubuntu1.2) …
/sbin/ldconfig.real: /usr/local/lib/python3.6/dist-packages/ideep4py/lib/libmkldnn.so.0 is not a symbolic link

Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (1.18.5)
Collecting PyQt5
Downloading (71.6MB)
|████████████████████████████████| 71.6MB 51kB/s
Collecting PyQt5-sip<13,>=12.8
Downloading (278kB)
|████████████████████████████████| 286kB 44.3MB/s
Installing collected packages: PyQt5-sip, PyQt5
Successfully installed PyQt5-5.15.1 PyQt5-sip-12.8.1
Collecting QtGui
Downloading
Building wheels for collected packages: QtGui
Building wheel for QtGui (setup.py) … done
Created wheel for QtGui: filename=qtgui-0.0.1-cp36-none-any.whl size=10317 sha256=e6dcc8a542b8d8f5d2f41a11540550294f0a676c15d7f0f93ffdd0e970efd1f2
Stored in directory: /root/.cache/pip/wheels/dc/24/19/968e6c14da845bd653d59c2de3bd550c0d636afb15b53020ed
Successfully built QtGui
Installing collected packages: QtGui
Successfully installed QtGui-0.0.1
Collecting QtWidgets
Downloading
Building wheels for collected packages: QtWidgets
Building wheel for QtWidgets (setup.py) … done
Created wheel for QtWidgets: filename=qtwidgets-0.16-cp36-none-any.whl size=24878 sha256=c57989ae17c41a4966c5c697dd65c5c07f623e3df59696468a0451a27960d220
Stored in directory: /root/.cache/pip/wheels/66/b8/47/32f696c520626c873efb59ad1d930450d5218d668ff48467fc
Successfully built QtWidgets
Installing collected packages: QtWidgets
Successfully installed QtWidgets-0.16
Requirement already satisfied: matplotlib in /usr/local/lib/python3.6/dist-packages (3.2.2)
Requirement already satisfied: numpy>=1.11 in /usr/local/lib/python3.6/dist-packages (from matplotlib) (1.18.5)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib) (1.3.1)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib) (2.8.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib) (2.4.7)
Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from cycler>=0.10->matplotlib) (1.15.0)

ERRORS OBSERVED*************

AttributeError Traceback (most recent call last)
in ()
130 return AllFeatures
–> 132 class PrettyWidget(QtGui.QWidget):
134 def init(self):

AttributeError: module ‘PyQt5.QtGui’ has no attribute ‘QWidget’

OK. The error is now this:

AttributeError: module ‘PyQt5.QtGui’ has no attribute ‘QWidget’

You identified this as an error in another file. The problem is that QWidget is part of the PyQt5.QtWidgets module in PyQt 5.

A lot of the code looks like it is written to use PyQt 4, so you are going to encounter more errors like this one. Look for lines with QtGui and check to see if the classes they use are now in the QtWidgets module.

Hi DB, it seems that is was written to encompass the PyQt4 for the demo file via the link but the author mentioned that it may not work with the PyQt4 and I can try the PyQt5!??!

What I find strange is that when I apply the PyQt4 the packages are not available and is stated as missing!

Really trying to understand this, it’s a pain especially when I cannot see the error! Thanx for responding pal! standing by for your response!!

YOUR Last Instruction;
" Look for lines with QtGui and check to see if the classes they use are now in the QtWidgets module"

ME: How? Can you guide me, please?
is there a show packages statement that I am not aware of?
let me know please!

Please see the errors is;

ModuleNotFoundError Traceback (most recent call last)
in ()
47 import os, sys
48 import pickle
—> 49 from PyQt4 import QtGui # If PyQt4 is not working in your case, you can try PyQt5
50 import qtwidgets
51 seed = 7

ModuleNotFoundError: No module named ‘PyQt4’

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.

It seems that you don’t have PyQt 4 installed because it wasn’t working and are trying to use PyQt 5 instead. If so, just focus on fixing the errors related to QtGui and forget about PyQt 4. It will probably help you in the long run because PyQt 4 is now very old and code that uses it will need to be updated.

The program you show in one of your earlier replies contains lines like this one:

Matpari:

btn = QtGui.QPushButton(‘ANOMALY DETECTION SYSTEM \n Please select video’, self)

In PyQt 5, QPushButton is not part of the QtGui module. You need to find lines like this and fix them to use QtWidgets instead.

Ok no probs will work on this now! thanx for redirecting me! I will notify you concerning the upgrades!

thanx once more DB, really appreciate this!

Ha Ha Ha! David, guess what?

The entire thing continually crashes when applying the changes you suggested lolz, but it did run by the way without any errors prompts, so coo-do’s for that pal!!!

I am now searching to see where I can view the details or logs on why this occurred!