code, rec, code2, rec2,x= test(minibatch,threshold) img2=change(rec) cv2.imwrite(path1,img2) return code, code2 def load(): print("****") com.load_weights('checkpoints/enc20_0.0001.npy') rec.load_weights('checkpoins/dec20_0.0001.npy') com,rec = ComCNN(),RecCNN() com.summary() rec.summary() import time if __name__ == '__main__': test = get_defense() get_session().run(ct.gvi()) load() start = time.time() path='adv.png' path3="temp_imagenet/" mkdir(path3) Divided_Pach(path,path3) for i in range(1,50): mkdir("temp_imagenet/") mkdir("com_imagenet_temp/") path1="temp_imagenet/"+str(i)+'.png' path2="com_imagenet_temp/"+str(i)+'.png' print(path2) Compression(path1,path2) concated=mergeimage('com_imagenet_temp/') #print(concated.shape)
# some cv2 shit. import cv2 import numpy as np import tensorflow as tf import time import canton as ct from canton import * from cv2tools import vis,filt from lucas_kanade import app from drone_detector_canton3 import classifier clf = classifier() get_session().run(ct.gvi()) # global init clf.load_weights('clf.npz') def pyr(i,scale): j = i.copy() if scale>0: for k in range(scale): j = cv2.pyrUp(j) elif scale<0: for k in range(-scale): j = cv2.pyrDown(j) else: j = j return j class theapp(app):