public class BoWSceneGraphParser extends AbstractSceneGraphParser
SemanticGraphEnhancer
, extracts objects and attributes using the
EntityExtractor
and a EntityClassifier
and predicts the relations between theese objects and attributes
to build a SceneGraph
.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_ENTITY_MODEL_PATH |
static java.lang.String |
DEFAULT_MODEL_PATH |
static java.lang.String |
IS_RELATION |
static java.lang.String |
NONE_RELATION |
pipeline
Constructor and Description |
---|
BoWSceneGraphParser(java.lang.String model,
java.lang.String entityModel,
Embedding embeddings)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Dataset<java.lang.String,java.lang.String> |
getTrainingExamples(java.lang.String trainingFile,
boolean sampleNeg)
Generate training examples.
|
static java.util.List<SceneGraphImage> |
loadImages(java.lang.String filename)
Loads scene graphs from JSON file.
|
static void |
main(java.lang.String[] args) |
SceneGraph |
parse(SemanticGraph sg) |
void |
train(java.lang.String trainingFile,
java.lang.String modelPath)
Trains a classifier using the examples in trainingFile and saves
it to modelPath.
|
parse, parse
public static final java.lang.String NONE_RELATION
public static final java.lang.String IS_RELATION
public static final java.lang.String DEFAULT_MODEL_PATH
public static final java.lang.String DEFAULT_ENTITY_MODEL_PATH
public BoWSceneGraphParser(java.lang.String model, java.lang.String entityModel, Embedding embeddings)
model
- Path to relation prediction model.entityModel
- Path to entity model.public SceneGraph parse(SemanticGraph sg)
parse
in class AbstractSceneGraphParser
public static java.util.List<SceneGraphImage> loadImages(java.lang.String filename) throws java.io.IOException
filename
- Path to JSON file.java.io.IOException
public Dataset<java.lang.String,java.lang.String> getTrainingExamples(java.lang.String trainingFile, boolean sampleNeg) throws java.io.IOException
trainingFile
- Path to JSON file with training images and scene graphs.sampleNeg
- Whether to sample the same number of negative examples as positive examples.java.io.IOException
public void train(java.lang.String trainingFile, java.lang.String modelPath) throws java.io.IOException
trainingFile
- Path to JSON file with images and scene graphs.modelPath
- java.io.IOException
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException