public static Model loadModelGuess(InputStream stream, File tempDirectory) throws Exception {
        //Currently (Nov 2017): KerasModelImport doesn't support loading from input streams
        //Simplest solution here: write to a temporary file
        File f;
        if(tempDirectory == null){
            f = DL4JFileUtils.createTempFile("loadModelGuess",".bin");
        } else {
            f = File.createTempFile("loadModelGuess", ".bin", tempDirectory);
        }
        f.deleteOnExit();


        try (OutputStream os = new BufferedOutputStream(new FileOutputStream(f))) {
            IOUtils.copy(stream, os);
            os.flush();
            return loadModelGuess(f.getAbsolutePath());
        } catch (ModelGuesserException e){
            throw new ModelGuesserException("Unable to load model from input stream (invalid model file not a known model type)");
        } finally {
            f.delete();
        }
    }
public static Model loadModelGuess ( InputStream stream , File tempDirectory ) throws Exception { File f ; if ( tempDirectory == null ) { f = DL4JFileUtils . createTempFile ( "loadModelGuess" , ".bin" ) ; } else { f = File . createTempFile ( "loadModelGuess" , ".bin" , tempDirectory ) ; } f . deleteOnExit ( ) ; try ( OutputStream os = new BufferedOutputStream ( new FileOutputStream ( f ) ) ) { IOUtils . copy ( stream , os ) ; os . flush ( ) ; return loadModelGuess ( f . getAbsolutePath ( ) ) ; } catch ( ModelGuesserException e ) { throw new ModelGuesserException ( "Unable to load model from input stream (invalid model file not a known model type)" ) ; } finally { f . delete ( ) ; } }
As per {@link #loadModelGuess(InputStream)} but (optionally) allows copying to the specified temporary directory
@param stream        Stream of the model file
@param tempDirectory Temporary/working directory. May be null.