Skip to content

Commit 516851d

Browse files
committed
commit npz file format
1 parent 70e762a commit 516851d

File tree

10 files changed

+136
-0
lines changed

10 files changed

+136
-0
lines changed

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Current File",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal"
13+
}
14+
]
15+
}

scripts/35_rename_files_os.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# https://www.geeksforgeeks.org/rename-multiple-files-using-python/
2+
# Pythono3 code to rename multiple
3+
# files in a directory or folder
4+
5+
# importing os module
6+
import os
7+
8+
# Function to rename multiple files
9+
def main():
10+
i = 0
11+
import pdb; pdb.set_trace()
12+
for filename in os.listdir("/home/superadmin/mrcnn/IDRBT Cheque Image Dataset/300"):
13+
dst = str(i) + ".jpg"
14+
src = "/home/superadmin/mrcnn/IDRBT Cheque Image Dataset/300/" + filename
15+
dst = "/home/superadmin/mrcnn/IDRBT Cheque Image Dataset/300/" + dst
16+
17+
# rename() function will
18+
# rename all the files
19+
os.rename(src, dst)
20+
i += 1
21+
22+
# Driver Code
23+
if __name__ == '__main__':
24+
25+
# Calling main() function
26+
main()

scripts/36_json_npy_file.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
import numpy as np
3+
import json
4+
def load_tester(path):
5+
with open(path) as f:
6+
data = json.load(f)
7+
print(data)
8+
return np.asarray(data)
9+
10+
d = load_tester('/home/superadmin/Downloads/via_export_coco (3).json')
11+
12+
print(type(d))
13+
14+
np.save('mask.npy',d)

scripts/CV/read_hd5.py

Whitespace-only changes.

scripts/CV/softmax.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# http://dataaspirant.com/2017/03/07/difference-between-softmax-function-and-sigmoid-function/
2+
import numpy as np
3+
4+
def softmax(inputs):
5+
6+
"""
7+
Calculate the softmax for the give inputs (array)
8+
:param inputs:
9+
:return:
10+
"""
11+
import pdb; pdb.set_trace()
12+
l = np.exp(inputs)
13+
print(f"np.exp(l) is {l} and its type is {type(l)}")
14+
sum_l = print(f"np.exp(l) is {float(sum(np.exp(inputs)))} and its type is {type(float(sum(np.exp(inputs))))}")
15+
16+
return np.exp(inputs)/ float(sum(np.exp(inputs)))
17+
softmax_inputs=[ 2,3,5,6]
18+
print(f"softmax functions output:: {softmax(softmax_inputs)}")

scripts/CV/tiff_png.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
from PIL import Image
3+
4+
# yourpath = os.getcwd()
5+
yourpath='/home/superadmin/mrcnn/IDRBT Cheque Image Dataset/300/'
6+
# import pdb; pdb.set_trace()
7+
for root, dirs, files in os.walk(yourpath, topdown=False):
8+
for name in files:
9+
print(os.path.join(root, name))
10+
if os.path.splitext(os.path.join(root, name))[1].lower() == ".tif":
11+
if os.path.isfile(os.path.splitext(os.path.join(root, name))[0] + ".jpg"):
12+
print "A jpeg file already exists for %s" % name
13+
# If a jpeg is *NOT* present, create one from the tiff.
14+
else:
15+
outfile = os.path.splitext(os.path.join(root, name))[0] + ".jpg"
16+
try:
17+
im = Image.open(os.path.join(root, name))
18+
print "Generating jpeg for %s" % name
19+
im.thumbnail(im.size)
20+
im.save(outfile, "JPEG", quality=100)
21+
except Exception, e:
22+
print e

scripts/NLP/bow.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
sentences = """Thomas Jefferson began building Monticello at the\
2+
age of 26.\n"""
3+
sentences += """Construction was done mostly by local masons and\
4+
carpenters.\n"""
5+
sentences += "He moved into the South Pavilion in 1770. the \n"
6+
sentences += """Turning Monticello into a neoclassical masterpiece\
7+
was Jefferson's obsession."""
8+
corpus = {}
9+
for i, sent in enumerate(sentences.split('\n')):
10+
corpus['sent{}'.format(i)] = dict((tok, 1) for tok in sent.split())
11+
print(corpus.keys())
12+
for k,v in corpus.items():
13+
print(k,v)

scripts/mask.npy

18.4 KB
Binary file not shown.

scripts/py_algorithms/fib3.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from typing import Dict
2+
memo : Dict[int, int] = { 0:0, 1:1}
3+
4+
print(f'memo is {memo}')
5+
6+
def fib3(n : int) -> int:
7+
# breakpoint()
8+
if n not in memo:
9+
print(f' n is {n}')
10+
memo[n] = fib3(n-1) + fib3(n-2)
11+
print(f' Dict memo is {memo[n]}')
12+
return memo[n]
13+
14+
if __name__ == "__main__":
15+
print(f' calling fib n = {fib3(5)} ')

scripts/py_algorithms/fibonaci.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def fib1(n: int) -> int:
2+
return fib1(n - 1) + fib1(n - 2)
3+
4+
5+
def fib2(n: int) -> int:
6+
if n < 2: # base case
7+
return n
8+
# breakpoint()
9+
return fib2(n - 2) + fib2(n - 1)
10+
# recursive case
11+
12+
if __name__ == "__main__":
13+
print(fib2(5))

0 commit comments

Comments
 (0)