Skip to content

Commit 162276e

Browse files
authored
autopep8 action fixes
1 parent 3fdaaa7 commit 162276e

13 files changed

+501
-219
lines changed

examples/automl.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@
3333
"xception"]
3434

3535
for model in models:
36-
ImageClassification(model, "./train", f"cars{model}", epochs=1, graph=False)
36+
ImageClassification(
37+
model,
38+
"./train",
39+
f"cars{model}",
40+
epochs=1,
41+
graph=False)

examples/text_fine_tuning.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44

55
from quickai import TextFineTuning
66

7-
TextFineTuning("./aclImdb", "./FUNCTIONTESTCLASSIFICATION", "classification", ["pos", "neg"],
8-
epochs=1) # Text classification
7+
TextFineTuning("./aclImdb", "./FUNCTIONTESTCLASSIFICATION",
8+
"classification", ["pos", "neg"], epochs=1) # Text classification
99

10-
TextFineTuning("./wnut17train.conll", "./FUNCTIONTESTTOKENCLASSIFICATION", "token_classification",
11-
epochs=1) # Token Classification
10+
TextFineTuning(
11+
"./wnut17train.conll",
12+
"./FUNCTIONTESTTOKENCLASSIFICATION",
13+
"token_classification",
14+
epochs=1) # Token Classification
1215

1316
TextFineTuning("./squad", "./FUNCTIONTESTQA", "q+a",
1417
epochs=1) # Q+A

examples/yolov4_image.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from quickai import YOLOV4
22

3-
YOLOV4(media_type="image", image="kite.jpg", weights="./checkpoints/yolov4-416")
3+
YOLOV4(media_type="image", image="kite.jpg",
4+
weights="./checkpoints/yolov4-416")

examples/yolov4_video.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from quickai import YOLOV4
22

3-
YOLOV4(media_type="video", video="road.mp4", weights="./checkpoints/yolov4-416")
3+
YOLOV4(media_type="video", video="road.mp4",
4+
weights="./checkpoints/yolov4-416")

quickai/image_classification.py

+27-27
Original file line numberDiff line numberDiff line change
@@ -88,32 +88,32 @@ def use(self):
8888
self.use()
8989
"""
9090

91-
modeldata = {"eb0": [tf.keras.applications.EfficientNetB0, 224],
92-
"eb1": [tf.keras.applications.EfficientNetB1, 240],
93-
"eb2": [tf.keras.applications.EfficientNetB2, 260],
94-
"eb3": [tf.keras.applications.EfficientNetB3, 300],
95-
"eb4": [tf.keras.applications.EfficientNetB4, 340],
96-
"eb5": [tf.keras.applications.EfficientNetB5, 456],
97-
"eb6": [tf.keras.applications.EfficientNetB6, 528],
98-
"eb7": [tf.keras.applications.EfficientNetB7, 600],
99-
"vgg16": [tf.keras.applications.VGG16, 224],
100-
"vgg19": [tf.keras.applications.VGG19, 224],
101-
"dn121": [tf.keras.applications.DenseNet121, 224],
102-
"dn169": [tf.keras.applications.DenseNet169, 224],
103-
"dn201": [tf.keras.applications.DenseNet201, 224],
104-
"irnv2": [tf.keras.applications.InceptionResNetV2, 299],
105-
"iv3": [tf.keras.applications.InceptionV3, 299],
106-
"mn": [tf.keras.applications.MobileNet, 224],
107-
"mnv2": [tf.keras.applications.MobileNetV2, 224],
108-
"mnv3l": [tf.keras.applications.MobileNetV3Large, 224],
109-
"mnv3s": [tf.keras.applications.MobileNetV3Small, 224],
110-
"rn101": [tf.keras.applications.ResNet101, 224],
111-
"rn101v2": [tf.keras.applications.ResNet101V2, 224],
112-
"rn152": [tf.keras.applications.ResNet152, 224],
113-
"rn152v2": [tf.keras.applications.ResNet152V2, 224],
114-
"rn50": [tf.keras.applications.ResNet50, 224],
115-
"rn50v2": [tf.keras.applications.ResNet50V2, 224],
116-
"xception": [tf.keras.applications.Xception, 299]}
91+
modeldata = {"eb0": [tf.keras.applications.EfficientNetB0, 224],
92+
"eb1": [tf.keras.applications.EfficientNetB1, 240],
93+
"eb2": [tf.keras.applications.EfficientNetB2, 260],
94+
"eb3": [tf.keras.applications.EfficientNetB3, 300],
95+
"eb4": [tf.keras.applications.EfficientNetB4, 340],
96+
"eb5": [tf.keras.applications.EfficientNetB5, 456],
97+
"eb6": [tf.keras.applications.EfficientNetB6, 528],
98+
"eb7": [tf.keras.applications.EfficientNetB7, 600],
99+
"vgg16": [tf.keras.applications.VGG16, 224],
100+
"vgg19": [tf.keras.applications.VGG19, 224],
101+
"dn121": [tf.keras.applications.DenseNet121, 224],
102+
"dn169": [tf.keras.applications.DenseNet169, 224],
103+
"dn201": [tf.keras.applications.DenseNet201, 224],
104+
"irnv2": [tf.keras.applications.InceptionResNetV2, 299],
105+
"iv3": [tf.keras.applications.InceptionV3, 299],
106+
"mn": [tf.keras.applications.MobileNet, 224],
107+
"mnv2": [tf.keras.applications.MobileNetV2, 224],
108+
"mnv3l": [tf.keras.applications.MobileNetV3Large, 224],
109+
"mnv3s": [tf.keras.applications.MobileNetV3Small, 224],
110+
"rn101": [tf.keras.applications.ResNet101, 224],
111+
"rn101v2": [tf.keras.applications.ResNet101V2, 224],
112+
"rn152": [tf.keras.applications.ResNet152, 224],
113+
"rn152v2": [tf.keras.applications.ResNet152V2, 224],
114+
"rn50": [tf.keras.applications.ResNet50, 224],
115+
"rn50v2": [tf.keras.applications.ResNet50V2, 224],
116+
"xception": [tf.keras.applications.Xception, 299]}
117117

118118
img_size = modeldata[self.model][1]
119119
train, val, class_num = self.load_img_data(
@@ -167,7 +167,7 @@ def use(self):
167167

168168
if self.save_ios:
169169
image_input = ct.ImageType(shape=(1, 224, 224, 3,),
170-
bias=[-1, -1, -1], scale=1/127)
170+
bias=[-1, -1, -1], scale=1 / 127)
171171

172172
classifier_config = ct.ClassifierConfig(self.class_names)
173173

quickai/text_finetuning.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def encode_tags(tags, encodings, tag2id):
4141
arr_offset = np.array(doc_offset)
4242

4343
doc_enc_labels[(arr_offset[:, 0] == 0) & (
44-
arr_offset[:, 1] != 0)] = doc_labels
44+
arr_offset[:, 1] != 0)] = doc_labels
4545
encoded_labels.append(doc_enc_labels.tolist())
4646

4747
return encoded_labels

quickai/text_inferance.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,15 @@ def summarization(text, length_max, length_min):
6868

6969

7070
def classification_ft(path, classes):
71-
model = AutoModelForSequenceClassification.from_pretrained(path, from_tf=True)
71+
model = AutoModelForSequenceClassification.from_pretrained(
72+
path, from_tf=True)
7273
tokenizer = AutoTokenizer.from_pretrained('distilbert-base-uncased')
73-
classifier = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
74+
classifier = pipeline(
75+
'sentiment-analysis',
76+
model=model,
77+
tokenizer=tokenizer)
7478

7579
result = classifier("I love this movie")[0]
7680
out_class = result['label'].replace('LABEL_', '')
77-
return [result['label'], round(result['score'], 4), classes[int(out_class)]]
81+
return [result['label'], round(
82+
result['score'], 4), classes[int(out_class)]]

quickai/yolo/backbone.py

+79-35
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
import tensorflow as tf
55
from .common import *
66

7+
78
def darknet53(input_data):
89

9-
input_data = convolutional(input_data, (3, 3, 3, 32))
10-
input_data = convolutional(input_data, (3, 3, 32, 64), downsample=True)
10+
input_data = convolutional(input_data, (3, 3, 3, 32))
11+
input_data = convolutional(input_data, (3, 3, 32, 64), downsample=True)
1112

1213
for i in range(1):
13-
input_data = residual_block(input_data, 64, 32, 64)
14+
input_data = residual_block(input_data, 64, 32, 64)
1415

15-
input_data = convolutional(input_data, (3, 3, 64, 128), downsample=True)
16+
input_data = convolutional(input_data, (3, 3, 64, 128), downsample=True)
1617

1718
for i in range(2):
18-
input_data = residual_block(input_data, 128, 64, 128)
19+
input_data = residual_block(input_data, 128, 64, 128)
1920

2021
input_data = convolutional(input_data, (3, 3, 128, 256), downsample=True)
2122

@@ -36,74 +37,118 @@ def darknet53(input_data):
3637

3738
return route_1, route_2, input_data
3839

40+
3941
def cspdarknet53(input_data):
4042

41-
input_data = convolutional(input_data, (3, 3, 3, 32), activate_type="mish")
42-
input_data = convolutional(input_data, (3, 3, 32, 64), downsample=True, activate_type="mish")
43+
input_data = convolutional(input_data, (3, 3, 3, 32), activate_type="mish")
44+
input_data = convolutional(
45+
input_data, (3, 3, 32, 64), downsample=True, activate_type="mish")
4346

4447
route = input_data
4548
route = convolutional(route, (1, 1, 64, 64), activate_type="mish")
46-
input_data = convolutional(input_data, (1, 1, 64, 64), activate_type="mish")
49+
input_data = convolutional(
50+
input_data, (1, 1, 64, 64), activate_type="mish")
4751
for i in range(1):
48-
input_data = residual_block(input_data, 64, 32, 64, activate_type="mish")
49-
input_data = convolutional(input_data, (1, 1, 64, 64), activate_type="mish")
52+
input_data = residual_block(
53+
input_data, 64, 32, 64, activate_type="mish")
54+
input_data = convolutional(
55+
input_data, (1, 1, 64, 64), activate_type="mish")
5056

5157
input_data = tf.concat([input_data, route], axis=-1)
52-
input_data = convolutional(input_data, (1, 1, 128, 64), activate_type="mish")
53-
input_data = convolutional(input_data, (3, 3, 64, 128), downsample=True, activate_type="mish")
58+
input_data = convolutional(
59+
input_data, (1, 1, 128, 64), activate_type="mish")
60+
input_data = convolutional(
61+
input_data, (3, 3, 64, 128), downsample=True, activate_type="mish")
5462
route = input_data
5563
route = convolutional(route, (1, 1, 128, 64), activate_type="mish")
56-
input_data = convolutional(input_data, (1, 1, 128, 64), activate_type="mish")
64+
input_data = convolutional(
65+
input_data, (1, 1, 128, 64), activate_type="mish")
5766
for i in range(2):
58-
input_data = residual_block(input_data, 64, 64, 64, activate_type="mish")
59-
input_data = convolutional(input_data, (1, 1, 64, 64), activate_type="mish")
67+
input_data = residual_block(
68+
input_data, 64, 64, 64, activate_type="mish")
69+
input_data = convolutional(
70+
input_data, (1, 1, 64, 64), activate_type="mish")
6071
input_data = tf.concat([input_data, route], axis=-1)
6172

62-
input_data = convolutional(input_data, (1, 1, 128, 128), activate_type="mish")
63-
input_data = convolutional(input_data, (3, 3, 128, 256), downsample=True, activate_type="mish")
73+
input_data = convolutional(
74+
input_data, (1, 1, 128, 128), activate_type="mish")
75+
input_data = convolutional(
76+
input_data, (3, 3, 128, 256), downsample=True, activate_type="mish")
6477
route = input_data
6578
route = convolutional(route, (1, 1, 256, 128), activate_type="mish")
66-
input_data = convolutional(input_data, (1, 1, 256, 128), activate_type="mish")
79+
input_data = convolutional(
80+
input_data, (1, 1, 256, 128), activate_type="mish")
6781
for i in range(8):
68-
input_data = residual_block(input_data, 128, 128, 128, activate_type="mish")
69-
input_data = convolutional(input_data, (1, 1, 128, 128), activate_type="mish")
82+
input_data = residual_block(
83+
input_data, 128, 128, 128, activate_type="mish")
84+
input_data = convolutional(
85+
input_data, (1, 1, 128, 128), activate_type="mish")
7086
input_data = tf.concat([input_data, route], axis=-1)
7187

72-
input_data = convolutional(input_data, (1, 1, 256, 256), activate_type="mish")
88+
input_data = convolutional(
89+
input_data, (1, 1, 256, 256), activate_type="mish")
7390
route_1 = input_data
74-
input_data = convolutional(input_data, (3, 3, 256, 512), downsample=True, activate_type="mish")
91+
input_data = convolutional(
92+
input_data, (3, 3, 256, 512), downsample=True, activate_type="mish")
7593
route = input_data
7694
route = convolutional(route, (1, 1, 512, 256), activate_type="mish")
77-
input_data = convolutional(input_data, (1, 1, 512, 256), activate_type="mish")
95+
input_data = convolutional(
96+
input_data, (1, 1, 512, 256), activate_type="mish")
7897
for i in range(8):
79-
input_data = residual_block(input_data, 256, 256, 256, activate_type="mish")
80-
input_data = convolutional(input_data, (1, 1, 256, 256), activate_type="mish")
98+
input_data = residual_block(
99+
input_data, 256, 256, 256, activate_type="mish")
100+
input_data = convolutional(
101+
input_data, (1, 1, 256, 256), activate_type="mish")
81102
input_data = tf.concat([input_data, route], axis=-1)
82103

83-
input_data = convolutional(input_data, (1, 1, 512, 512), activate_type="mish")
104+
input_data = convolutional(
105+
input_data, (1, 1, 512, 512), activate_type="mish")
84106
route_2 = input_data
85-
input_data = convolutional(input_data, (3, 3, 512, 1024), downsample=True, activate_type="mish")
107+
input_data = convolutional(
108+
input_data, (3, 3, 512, 1024), downsample=True, activate_type="mish")
86109
route = input_data
87110
route = convolutional(route, (1, 1, 1024, 512), activate_type="mish")
88-
input_data = convolutional(input_data, (1, 1, 1024, 512), activate_type="mish")
111+
input_data = convolutional(
112+
input_data, (1, 1, 1024, 512), activate_type="mish")
89113
for i in range(4):
90-
input_data = residual_block(input_data, 512, 512, 512, activate_type="mish")
91-
input_data = convolutional(input_data, (1, 1, 512, 512), activate_type="mish")
114+
input_data = residual_block(
115+
input_data, 512, 512, 512, activate_type="mish")
116+
input_data = convolutional(
117+
input_data, (1, 1, 512, 512), activate_type="mish")
92118
input_data = tf.concat([input_data, route], axis=-1)
93119

94-
input_data = convolutional(input_data, (1, 1, 1024, 1024), activate_type="mish")
120+
input_data = convolutional(
121+
input_data, (1, 1, 1024, 1024), activate_type="mish")
95122
input_data = convolutional(input_data, (1, 1, 1024, 512))
96123
input_data = convolutional(input_data, (3, 3, 512, 1024))
97124
input_data = convolutional(input_data, (1, 1, 1024, 512))
98125

99-
input_data = tf.concat([tf.nn.max_pool(input_data, ksize=13, padding='SAME', strides=1), tf.nn.max_pool(input_data, ksize=9, padding='SAME', strides=1)
100-
, tf.nn.max_pool(input_data, ksize=5, padding='SAME', strides=1), input_data], axis=-1)
126+
input_data = tf.concat(
127+
[
128+
tf.nn.max_pool(
129+
input_data,
130+
ksize=13,
131+
padding='SAME',
132+
strides=1),
133+
tf.nn.max_pool(
134+
input_data,
135+
ksize=9,
136+
padding='SAME',
137+
strides=1),
138+
tf.nn.max_pool(
139+
input_data,
140+
ksize=5,
141+
padding='SAME',
142+
strides=1),
143+
input_data],
144+
axis=-1)
101145
input_data = convolutional(input_data, (1, 1, 2048, 512))
102146
input_data = convolutional(input_data, (3, 3, 512, 1024))
103147
input_data = convolutional(input_data, (1, 1, 1024, 512))
104148

105149
return route_1, route_2, input_data
106150

151+
107152
def cspdarknet53_tiny(input_data):
108153
input_data = convolutional(input_data, (3, 3, 3, 32), downsample=True)
109154
input_data = convolutional(input_data, (3, 3, 32, 64), downsample=True)
@@ -146,6 +191,7 @@ def cspdarknet53_tiny(input_data):
146191

147192
return route_1, input_data
148193

194+
149195
def darknet53_tiny(input_data):
150196
input_data = convolutional(input_data, (3, 3, 3, 16))
151197
input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)
@@ -163,5 +209,3 @@ def darknet53_tiny(input_data):
163209
input_data = convolutional(input_data, (3, 3, 512, 1024))
164210

165211
return route_1, input_data
166-
167-

0 commit comments

Comments
 (0)