Computer Vision News - July 2022

51 Docker TESTING _ DIR = os.path.join(os.environ["BASE _ DIR"],'Test') print(TESTING _ DIR) MODEL _ DIR = os.environ["BASE _ DIR"] print(MODEL _ DIR) OUTPUT _ DIR = os.path.join(os.environ["BASE _ DIR"], 'Output') # List of classification labels classes=['DR','MH','DN','TSLN','ODC'] list _ of _ images = os.listdir(TESTING _ DIR) # Import pre-trained model model = keras.models.load _ model(MODEL _ DIR+'/multi _ CNN.h5') # Run model through test images and save result for img _ filename in list _ of _ images: img = data _ resizing _ process(os.path.join(TESTING _ DIR,img _ filename),img _ width,img _ height) result = model.predict(img) print(np.argmax(result)) plt.imshow(Image.open(os.path.join(TESTING _ DIR,img _ filename))) plt.title(classes[np.argmax(result)]) plt.savefig(os.path.join(OUTPUT _ DIR,img _ filename.split('/')[- 1 ])) print(os.path.join(OUTPUT _ DIR,img _ filename.split('/')[- 1 ])) #plt.show() if _ _ name _ _ == ' _ _ main _ _ ': infer() The next step to package our application is to create a Dockerfile, a simple text file which contains indications on what commands need to be executed in the docker environment for building an image. An important thing to note about Dockerfiles is that, besides running usual terminal commands such as mkdir or pip install, they can call other images (with the keyword FROM) which already contain sets of libraries. Moreover, they usually include commands to copy the necessary files into the new container.

RkJQdWJsaXNoZXIy NTc3NzU=