com.github.chen0040.tensorflow.classifiers.demo.Cifar10AudioClassifierDemo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-tensorflow-music Show documentation
Show all versions of java-tensorflow-music Show documentation
Java implementation of music classifier, encoder, search engine and recommender using Tensorflow nd Java
The newest version!
package com.github.chen0040.tensorflow.classifiers.demo;
import com.github.chen0040.tensorflow.classifiers.models.cifar10.Cifar10AudioClassifier;
import com.github.chen0040.tensorflow.classifiers.utils.FileUtils;
import com.github.chen0040.tensorflow.classifiers.utils.ResourceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Cifar10AudioClassifierDemo {
private static final Logger logger = LoggerFactory.getLogger(Cifar10AudioClassifierDemo.class);
public static void main(String[] args) throws IOException {
Cifar10AudioClassifier classifier = new Cifar10AudioClassifier();
classifier.load_model();
List paths = FileUtils.getAudioFiles();
Collections.shuffle(paths);
for (String path : paths) {
System.out.println("Predicting " + path + " ...");
File f = new File(path);
String label = classifier.predict_audio(f);
System.out.println("Predicted: " + label);
}
}
}