<jupyter_start><jupyter_text>Import libraries<jupyter_code>import numpy as np
import cv2 as cv
import csv
import time
from tensorflow.python.keras.models import load_model<jupyter_output><empty_output><jupyter_text>Setting capture window parameters and loading labels<jupyter_code>frameWidth=640
frameHeight=480
brightness= 180
threshold= 0.95
font= cv.FONT_HERSHEY_SIMPLEX

with open('labels.csv', mode='r') as infile:
    reader = csv.reader(infile)
    mydict = {rows[0]:rows[1] for rows in reader}<jupyter_output><empty_output><jupyter_text>Loading our model<jupyter_code>model=load_model("tsc_model.h5")<jupyter_output><empty_output><jupyter_text>Preprocessing of frame<jupyter_code>def preprocess(img):
    
    img = cv.resize(img,(32,32))
    img = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
    img = cv.equalizeHist(img)    
    img=img/255    
    img=img[np.newaxis,:,:,np.newaxis]
    
    return img<jupyter_output><empty_output><jupyter_text>Generate output without OpenVINO<jupyter_code>cap= cv.VideoCapture(0)

prev_frame_time = 0
new_frame_time = 0

cap.set(3,frameWidth)
cap.set(4,frameHeight)
cap.set(10,brightness)

    
while True:
    
    success, imgOriginal = cap.read()
    img = np.asarray(imgOriginal)
     
    img = preprocess(img)
    new_frame_time = time.time()
    fps = 1/(new_frame_time-prev_frame_time)
    prev_frame_time = new_frame_time
  
    # converting the fps into integer
    fps = int(fps)
        
    cv.putText(imgOriginal, "CLASS: ",(20,35),font,0.75,(0,0,255),2,cv.LINE_AA)
    cv.putText(imgOriginal, "PROBABILITY: ",(20,75),font,0.75,(255,0,0),2,cv.LINE_AA)
    cv.putText(image, "FPS: ", (20,115), font, 0.75, (0, 255, 0), 2, cv.LINE_AA)
    

    predictions= model.predict(img)
    classIndex = np.argmax(predictions,axis=1)
   
    probabilityValue = np.amax(predictions)
    print(classIndex, probabilityValue)
    if probabilityValue>threshold:
        cv.putText(imgOriginal, str(classIndex)+" "+mydict[str(max(classIndex))],(120,35),font,0.75,(0,0,255),2,cv.LINE_AA)
        cv.putText(imgOriginal, str(round(probabilityValue,2)),(180,75),font,0.75,(255,0,0),2,cv.LINE_AA)
        cv.putText(image, str(fps),(180,115),font,0.75,(0,255,0),2,cv.LINE_AA)

    cv.imshow("Result", imgOriginal)
    
    k = cv.waitKey(20) & 0xFF == ord('q')
    if k==27:
        break

cap.release()
cap.destroyAllWindows()<jupyter_output>[38] 0.63092434
[38] 0.63092434
[38] 0.8442284
[35] 0.3327675
[12] 0.88579774
[38] 0.3086374
[15] 0.5256107
[38] 0.9701478
[38] 0.9872721
[15] 0.440107
[34] 0.57357395
[34] 0.99321
[38] 0.41962445
[38] 0.77447355
[34] 0.633279
[15] 0.39859846
[15] 0.6902812
[34] 0.27583793
[34] 0.3805951
[34] 0.82753295
[34] 0.8226939
[34] 0.32289162
[35] 0.57890475
[34] 0.8255685
[34] 0.5095796
[34] 0.974861
[34] 0.8614707
[35] 0.5194461
[35] 0.5349353
[12] 0.8382176
[12] 0.7319545
[35] 0.6569218
[33] 0.45910516
[12] 0.3416849
[32] 0.31106898
[12] 0.6187059
[12] 0.8003285
[12] 0.63037485
[12] 0.8737752
[33] 0.8242172
[7] 0.40251198
[12] 0.9151034
[8] 0.9103049
[12] 0.68584573
[12] 0.7159173
[38] 0.36161333
[12] 0.9311829
[12] 0.25431252
[12] 0.9792327
[35] 0.6906151
[38] 0.60376954
[12] 0.8572866
[34] 0.5033858
[12] 0.8015708
[12] 0.6792101
[12] 0.99206513
[12] 0.9910636
[12] 0.9679161
[12] 0.9968663
[12] 0.97727203
[12] 0.9756225
[12] 0.99478686
[12] 0.99907553
[12] 0.9988649
[12] 0.99903274
[12] 0.6[...]
{'fraction_non_alphanumeric': 0.16158626812666468, 'fraction_numerical': 0.2346848179934892, 'mean_word_length': 4.522875816993464, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '104602', 'license': 'MIT', 'n_tokens_mistral': 1994, 'n_tokens_neox': 1532, 'n_words': 266, 'path': 'code/TSC_without_OpenVINO.ipynb', 'repo_name': 'sarosijbose/TSCLite', 'size': '3379'}