Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classfying the image is taking more time. #6

Open
sbind29893 opened this issue Nov 27, 2019 · 6 comments
Open

Classfying the image is taking more time. #6

sbind29893 opened this issue Nov 27, 2019 · 6 comments

Comments

@sbind29893
Copy link

Based on cfg/yolov3-voc.cfg

[net]

Testing

batch=1

subdivisions=1

Training

batch=64
subdivisions=32
width=608
height=608
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=400
max_batches=8000
policy=steps
steps=3800
scales=.1

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

Downsample

[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=32
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

Downsample

[convolutional]
batch_normalize=1
filters=128
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

Downsample

[convolutional]
batch_normalize=1
filters=256
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

Downsample

[convolutional]
batch_normalize=1
filters=512
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

Downsample

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

######################

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
size=1
stride=1
pad=1

filters = (num/3) * (5+classes)

filters=30
activation=linear

[yolo]
mask = 6,7,8
anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326
classes=5
num=9
jitter=.3
ignore_thresh = .9
truth_thresh = 1
random=1

[route]
layers = -4

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 61

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
size=1
stride=1
pad=1

filters = (num/3) * (5+classes)

filters=30
activation=linear

[yolo]
mask = 3,4,5
anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326
classes=5
num=9
jitter=.3
ignore_thresh = .9
truth_thresh = 1
random=1

[route]
layers = -4

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=4

[route]
layers = -1, 11

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1

filters = (num/3) * (5+classes)

filters=30
activation=linear

[yolo]
mask = 0,1,2
anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326
classes=5
num=9
jitter=.3
ignore_thresh = .9
truth_thresh = 1
random=1

above is my yolo configuration.

If i try to drecrease the height and width in this file...the results are
614 height & width -> 38 seconds
416 heigth & witdth -> 16 seconds
288 height & width -> 7 seconds

each and every steps for decreasing the heigth and width gives me less accuracy in detection.

can you help me out with performing classifcation bit more faster

@sbind29893
Copy link
Author

one more thing i wanted to ask..the darknet.exe which you have provided..that has been compiled with GPU=1 right??

@008karan
Copy link
Owner

its a trade-off . By increase in the size of the image will take a long time and vice-versa. for lesser inference time use GPU with bigger RAM.

@sbind29893
Copy link
Author

This output is my output when i try to run by cloning darknet repo from github directly..it is not reading

(base) msi@msi-GT72VR-6RE:~/TEST_PAN_OCR$ python pan.py -d -t
[+] Initializing Darknet
[+] Initializing Tesseract
BATCH_1_1.jpg
[+] Classifying Image
Classify Time: 0.5108251571655273
[+] Finding required text
pancards/BATCH_1_1.jpg
pancards/BATCH_1_1.jpg: Predicted in 0.263089 seconds.
Pan: 78%
Date: 46%
FathersName: 78%
Name: 82%
Pancard: 40%

[-] No label found in image.
[-] No text found!
TOTAL TIME TAKEN 0.5155026912689209

This out is yours which is using darknet.exe and it is working fine but taking more time.

(base) msi@msi-GT72VR-6RE:~/PAN_FINAL$ python pan.py -d -t
[+] Initializing Darknet
[+] Initializing Tesseract
BATCH_1_1.jpg
[+] Classifying Image
Classify Time: 36.83689022064209
[+] Finding required text
pancards/BATCH_1_1.jpg
pancards/BATCH_1_1.jpg: Predicted in 36.310761 seconds.
Pancard: 76% (left_x: 282 top_y: 41 width: 969 height: 662)
FathersName: 98% (left_x: 286 top_y: 319 width: 426 height: 56)
Pan: 52% (left_x: 299 top_y: 489 width: 260 height: 67)
Date: 84% (left_x: 307 top_y: 396 width: 203 height: 57)
Name: 57% (left_x: 309 top_y: 232 width: 273 height: 68)

[+] Found 5 label(s) in image.
[+] Performing OCR
Starting image...
Starting image...
Starting image...
Starting image...
Starting image...
==RESULT==(309, 232, 582, 300)
BALRAM SINGH

==RESULT==(307, 396, 510, 453)
49/01/1993

==RESULT==(286, 319, 712, 375)
MOHAN SINGH GURJAR

==RESULT==(282, 41, 1251, 703)
“om DEPARTMENT GOVT:OF INDIA
BALRAM SINGH :

MOHAN SINGH GURJAR
19/01/4993

Permanent Account Number

ppvPSseoss

Signature

==RESULT==(299, 489, 559, 556)
DPvPS8608B

OCR Time: 0.756535530090332
[+] Elapsed: 37.73825407028198
{'Pancard': '“om DEPARTMENT GOVT:OF INDIA\nBALRAM SINGH :\n\nMOHAN SINGH GURJAR\n19/01/4993\n\nPermanent Account Number\n\nppvPSseoss\n\nSignature', 'FathersName': 'MOHAN SINGH GURJAR', 'Pan': 'DPvPS8608B', 'Date': '49/01/1993', 'Name': 'BALRAM SINGH'}
TOTAL TIME TAKEN 37.74691987037659

please help me find out the exact issue.

@sbind29893
Copy link
Author

sbind29893 commented Nov 27, 2019

with this command, my classifier getting failed

	command = DARKNET_BINARY_LOCATION + " detector test " + DARKNET_DATA_FILE + " " + DARKNET_CFG_FILE \
		+ " " + DARKNET_WEIGHTS + " -thresh " + str(DARKNET_THRESH) + " -ext_output -dont_show"

with this command. it is giving me no label found error

command = DARKNET_BINARY_LOCATION + " detector test " + DARKNET_DATA_FILE + " " + DARKNET_CFG_FILE
+ " " + DARKNET_WEIGHTS + " -thresh " + str(DARKNET_THRESH)

@008karan
Copy link
Owner

Simple.because my repo has darknet plus tesseract. Labels are detected and passed through the tesseract. And darknet is only doing label detection. That's why less time.
Didn't you read the bog on it? I have covered all in that. Read before asking anything.

@sbind29893
Copy link
Author

Karan even i know you are using tesseract also...i read your blog it was really helpfull in my use case thats why im seeking help here. i have already configured tesseract with my darknet. i dont why in my command -ext_output -dont_show is not working.

Anyways thanks for your help till now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants