Skip to content

Instantly share code, notes, and snippets.

def top_5_preds(preds): return np.argsort(preds.numpy())[:, ::-1][:, :5]
def top_5_pred_labels(preds, classes):
top_5 = top_5_preds(preds)
labels = []
for i in range(top_5.shape[0]):
labels.append(' '.join([classes[idx] for idx in top_5[i]]))
return labels
@AntonBespalov
AntonBespalov / gist:43409a5fc14bf8c57221f9ed93782709
Created May 3, 2019 16:34
extract files from archive to folder, Python
import zipfile as zf
files = zf.ZipFile("archive_name.zip", 'r')
files.extractall('./extrac_to_path')
files.close()
@AntonBespalov
AntonBespalov / gist:ed0e125a4b754aa52ca5ce9aebd3dcf5
Last active May 3, 2019 16:31
rename files in folder to (file_num + .jpeg) format, Python
import shutil
import os
path = "E:/folder_name/"
files = os.listdir(path)
for key in range(0, len(files)):
shutil.move(path + files[key], path + str(key) + ".jpeg")