Skip to content

Commit

Permalink
chore: fix linting with black
Browse files Browse the repository at this point in the history
  • Loading branch information
RitheeshBaradwaj committed Jul 21, 2024
1 parent 7e94bc9 commit 5eafb75
Show file tree
Hide file tree
Showing 14 changed files with 694 additions and 641 deletions.
34 changes: 19 additions & 15 deletions Convolution Layer/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@

# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-m", "--model", required=True,
help="path to trained model model")
ap.add_argument("-l", "--labelbin", required=True,
help="path to label binarizer")
ap.add_argument("-i", "--image", required=True,
help="path to input image")
ap.add_argument("-m", "--model", required=True, help="path to trained model model")
ap.add_argument("-l", "--labelbin", required=True, help="path to label binarizer")
ap.add_argument("-i", "--image", required=True, help="path to input image")
args = vars(ap.parse_args())

# load the image
image = cv2.imread(args["image"])
output = imutils.resize(image, width=400)

# pre-process the image for classification
image = cv2.resize(image, (96, 96))
image = image.astype("float") / 255.0
Expand All @@ -44,18 +41,25 @@
idxs = np.argsort(proba)[::-1][:2]

# loop over the indexes of the high confidence class labels
for (i, j) in enumerate(idxs):
# build the label and draw the label on the image
label = "{}: {:.2f}%".format(mlb.classes_[j], proba[j] * 100)
cv2.putText(output, label, (10, (i * 30) + 25),
cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 255, 0), 2)
for i, j in enumerate(idxs):
# build the label and draw the label on the image
label = "{}: {:.2f}%".format(mlb.classes_[j], proba[j] * 100)
cv2.putText(
output,
label,
(10, (i * 30) + 25),
cv2.FONT_HERSHEY_SIMPLEX,
0.7,
(0, 255, 0),
2,
)

# show the probabilities for each of the individual labels
for (label, p) in zip(mlb.classes_, proba):
print("{}: {:.2f}%".format(label, p * 100))
for label, p in zip(mlb.classes_, proba):
print("{}: {:.2f}%".format(label, p * 100))

# show the output image
cv2.imshow("Output", output)
cv2.waitKey(0)

# 0-striped 1-lining 2-square 3-dotted
# 0-striped 1-lining 2-square 3-dotted
96 changes: 48 additions & 48 deletions Convolution Layer/pyimagesearch/smallervggnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,59 @@
from keras.layers.core import Dense
from keras import backend as K


class SmallerVGGNet:
@staticmethod
def build(width, height, depth, classes, finalAct="softmax"):
# initialize the model along with the input shape to be
# "channels last" and the channels dimension itself
model = Sequential()
inputShape = (height, width, depth)
chanDim = -1
@staticmethod
def build(width, height, depth, classes, finalAct="softmax"):
# initialize the model along with the input shape to be
# "channels last" and the channels dimension itself
model = Sequential()
inputShape = (height, width, depth)
chanDim = -1

# if we are using "channels first", update the input shape
# and channels dimension
if K.image_data_format() == "channels_first":
inputShape = (depth, height, width)
chanDim = 1
# if we are using "channels first", update the input shape
# and channels dimension
if K.image_data_format() == "channels_first":
inputShape = (depth, height, width)
chanDim = 1

# CONV => RELU => POOL
model.add(Conv2D(32, (3, 3), padding="same",
input_shape=inputShape))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=chanDim))
model.add(MaxPooling2D(pool_size=(3, 3)))
model.add(Dropout(0.25))
# CONV => RELU => POOL
model.add(Conv2D(32, (3, 3), padding="same", input_shape=inputShape))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=chanDim))
model.add(MaxPooling2D(pool_size=(3, 3)))
model.add(Dropout(0.25))

# (CONV => RELU) * 2 => POOL
model.add(Conv2D(64, (3, 3), padding="same"))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=chanDim))
model.add(Conv2D(64, (3, 3), padding="same"))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=chanDim))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
# (CONV => RELU) * 2 => POOL
model.add(Conv2D(64, (3, 3), padding="same"))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=chanDim))
model.add(Conv2D(64, (3, 3), padding="same"))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=chanDim))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))

# (CONV => RELU) * 2 => POOL
model.add(Conv2D(128, (3, 3), padding="same"))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=chanDim))
model.add(Conv2D(128, (3, 3), padding="same"))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=chanDim))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
# (CONV => RELU) * 2 => POOL
model.add(Conv2D(128, (3, 3), padding="same"))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=chanDim))
model.add(Conv2D(128, (3, 3), padding="same"))
model.add(Activation("relu"))
model.add(BatchNormalization(axis=chanDim))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))

# first (and only) set of FC => RELU layers
model.add(Flatten())
model.add(Dense(1024))
model.add(Activation("relu"))
model.add(BatchNormalization())
model.add(Dropout(0.5))
# first (and only) set of FC => RELU layers
model.add(Flatten())
model.add(Dense(1024))
model.add(Activation("relu"))
model.add(BatchNormalization())
model.add(Dropout(0.5))

# softmax classifier
model.add(Dense(classes))
model.add(Activation(finalAct))
# softmax classifier
model.add(Dense(classes))
model.add(Activation(finalAct))

# return the constructed network architecture
return model
# return the constructed network architecture
return model
28 changes: 10 additions & 18 deletions multipupose-client/test1/client.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import socket


s=socket.socket()

s.connect(('127.0.0.1',8000))

s = socket.socket()
s.connect(("127.0.0.1", 8000))
print("connecton")

while True:
a=input("first number")
msg=a
if msg=="back":
a = input("first number")
msg = a
if msg == "back":
s.close()
break
s.send(msg.encode())
ms=s.recv(1024)
print("Answer:"+ms.decode())
# msg=input("Bob:")
# s.send(msg.encode())





ms = s.recv(1024)
print("Answer:" + ms.decode())
# msg=input("Bob:")
# s.send(msg.encode())
29 changes: 14 additions & 15 deletions multipupose-client/test1/server.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
import socket
import socket
import logging
import threading
import time


def thread(c):
print("connection is established")
while(True):
while True:
try:
msg=c.recv(1024)
msg = c.recv(1024)
print(c)
print(msg.decode())
f=int(msg.decode())
t=str(f*f)
f = int(msg.decode())
t = str(f * f)
time.sleep(2)
c.send(t.encode())
except:
c.close()
break

s=socket.socket()
port=8000
s.bind(('',port))

s = socket.socket()
port = 8000
s.bind(("", port))
print("server started")
format = "%(asctime)s: %(message)s"
while(True):
logging.basicConfig(format=format, level=logging.INFO,datefmt="%H:%M:%S")
while True:
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
s.listen(6)
c,addr=s.accept()
c, addr = s.accept()
x = threading.Thread(target=thread, args=(c,))
x.start()
print("connection is established")




Loading

0 comments on commit 5eafb75

Please sign in to comment.