Skip to content

Instantly share code, notes, and snippets.

@AbdelmajidB
Last active January 26, 2020 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbdelmajidB/fccb871836746dd4f0d6e32828eadcdf to your computer and use it in GitHub Desktop.
Save AbdelmajidB/fccb871836746dd4f0d6e32828eadcdf to your computer and use it in GitHub Desktop.
public class MyPathLabelGenerator implements PathLabelGenerator{
protected static final Logger log = LoggerFactory.getLogger(MyPathLabelGenerator.class);
String labelsDir;
private static NativeImageLoader imageLoader = new NativeImageLoader(96, 96, 1);
File file;
public MyPathLabelGenerator(String path) {
labelsDir=path;
}
public Writable getLabelForPath(String path) {
// TODO Auto-generated method stub
String dirName;
file=new File(path);
if(path.contains("testI"))
dirName=labelsDir+"/testI/rois/"+file.getName();
else
dirName=labelsDir+"/trainI/rois/"+file.getName();
try
{
INDArray origImg=imageLoader.asMatrix(new File(dirName));
return new NDArrayWritable(origImg);
}
catch(IOException ioe)
{
ioe.printStackTrace();
return null;
}
}
public Writable getLabelForPath(URI uri) {
// TODO Auto-generated method stub
return null;
}
public boolean inferLabelClasses() {
// TODO Auto-generated method stub
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment