!7 lib 1400166 // jython 2.7 import org.python.core.*; import org.python.modules.cPickle; static LS colors = splitAtComma("red, blue, green, orange, yellow, gray"); p-exp { File f = userDir("dev/Relational_Network_Tensorflow-master/data/sort-of-clevr.100-10.pickle"); PyFile pyFile = new(bufferedInputStream(f)); O o = cPickle.load(pyFile); print("Loaded: " + className(o)); L trainAndTest = cast o; for (L x : (L) trainAndTest) { print(l(x) + " examples"); L entry = cast first(x); print(l(entry)); L> img = (L) entry.get(0); L relations = cast entry.get(1); L norelations = cast entry.get(2); //print("img: " + sfu(img)); // img is a LLL showImage(rgbImageFromLLLDouble255((L) img)); LL relQuestions = (L) first(relations); L relAnswers = (L) second(relations); LL norelQuestions = (L) first(norelations); L norelAnswers = (L) second(norelations); print("relations:" + sfu(relations)); print("norelations:" + sfu(norelations)); for i over norelQuestions: { L q = norelQuestions.get(i); Int a = norelAnswers.get(i); S color = get(colors, indexOf(q, 1.0)); S subtype = get( ll("query shape->rectangle/circle", "query horizontal position->yes/no", "query vertical position->yes/no"), indexOf(q, 8, 1.0)-8); print("norel: " + q + " => " + a + ". color: " + color + ", subtype: " + subtype); } } }