Spaces:
Sleeping
Sleeping
woletee
commited on
Commit
·
7146dfa
1
Parent(s):
4893ced
added for visualizing the generated output and the ground truth output as well
Browse files- app.py +15 -2
- templates/results.html +36 -2
app.py
CHANGED
@@ -11,7 +11,6 @@ os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
|
11 |
@app.route('/')
|
12 |
def index():
|
13 |
return render_template('index.html')
|
14 |
-
|
15 |
@app.route('/upload', methods=['POST'])
|
16 |
def upload():
|
17 |
if 'file' not in request.files:
|
@@ -49,10 +48,24 @@ def upload():
|
|
49 |
predicted_HLCs=predicted_HLCs
|
50 |
)
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
return render_template("results.html",
|
53 |
hlcs=predicted_HLCs,
|
54 |
input_output_pairs=input_output_pairs,
|
55 |
-
best_program=str(best_program)
|
|
|
|
|
|
|
|
|
56 |
|
57 |
if __name__ == '__main__':
|
58 |
app.run(host="0.0.0.0", port=7860)
|
|
|
11 |
@app.route('/')
|
12 |
def index():
|
13 |
return render_template('index.html')
|
|
|
14 |
@app.route('/upload', methods=['POST'])
|
15 |
def upload():
|
16 |
if 'file' not in request.files:
|
|
|
48 |
predicted_HLCs=predicted_HLCs
|
49 |
)
|
50 |
|
51 |
+
# 🔥 NEW PART: Compute predicted output from best_program on last input
|
52 |
+
last_input = input_output_pairs[-1][0]
|
53 |
+
last_ground_truth = input_output_pairs[-1][1]
|
54 |
+
|
55 |
+
try:
|
56 |
+
predicted_output = best_program.evaluate(last_input)
|
57 |
+
except Exception as e:
|
58 |
+
predicted_output = [["ERROR"]]
|
59 |
+
print("Error applying best_program:", e)
|
60 |
+
|
61 |
return render_template("results.html",
|
62 |
hlcs=predicted_HLCs,
|
63 |
input_output_pairs=input_output_pairs,
|
64 |
+
best_program=str(best_program),
|
65 |
+
last_input=last_input,
|
66 |
+
last_ground_truth=last_ground_truth,
|
67 |
+
predicted_output=predicted_output)
|
68 |
+
|
69 |
|
70 |
if __name__ == '__main__':
|
71 |
app.run(host="0.0.0.0", port=7860)
|
templates/results.html
CHANGED
@@ -51,6 +51,17 @@
|
|
51 |
border-radius: 8px;
|
52 |
background-color: #f4f4f4;
|
53 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
</style>
|
55 |
</head>
|
56 |
<body>
|
@@ -63,9 +74,28 @@
|
|
63 |
<h2>Best Program</h2>
|
64 |
<pre>{{ best_program }}</pre>
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
<script>
|
67 |
const inputOutputPairs = {{ input_output_pairs | tojson }};
|
68 |
const hlcs = {{ hlcs | tojson }};
|
|
|
|
|
|
|
69 |
|
70 |
const colorMap = {
|
71 |
0: "#FFFFFF", 1: "#0074D9", 2: "#FF4136", 3: "#2ECC40",
|
@@ -117,16 +147,20 @@
|
|
117 |
const conceptText = document.createElement("div");
|
118 |
conceptText.className = "concept-text";
|
119 |
conceptText.innerText = hlcs[index] || "N/A";
|
120 |
-
|
121 |
conceptDiv.appendChild(conceptTitle);
|
122 |
conceptDiv.appendChild(conceptText);
|
123 |
|
124 |
-
// Combine
|
125 |
container.appendChild(inputDiv);
|
126 |
container.appendChild(outputDiv);
|
127 |
container.appendChild(conceptDiv);
|
128 |
pairsContainer.appendChild(container);
|
129 |
});
|
|
|
|
|
|
|
|
|
|
|
130 |
</script>
|
131 |
|
132 |
</body>
|
|
|
51 |
border-radius: 8px;
|
52 |
background-color: #f4f4f4;
|
53 |
}
|
54 |
+
pre {
|
55 |
+
background-color: #f5f5f5;
|
56 |
+
padding: 15px;
|
57 |
+
font-family: Consolas, monospace;
|
58 |
+
font-size: 14px;
|
59 |
+
border-radius: 8px;
|
60 |
+
max-width: 900px;
|
61 |
+
margin: auto;
|
62 |
+
white-space: pre-wrap;
|
63 |
+
border: 1px solid #ddd;
|
64 |
+
}
|
65 |
</style>
|
66 |
</head>
|
67 |
<body>
|
|
|
74 |
<h2>Best Program</h2>
|
75 |
<pre>{{ best_program }}</pre>
|
76 |
|
77 |
+
<h2>Best Program Evaluation (Last Grid)</h2>
|
78 |
+
<div class="grid-container">
|
79 |
+
<div>
|
80 |
+
<div class="grid-title">Last Input Grid</div>
|
81 |
+
<div id="last-input-grid" class="grid-box"></div>
|
82 |
+
</div>
|
83 |
+
<div>
|
84 |
+
<div class="grid-title">Ground Truth Output</div>
|
85 |
+
<div id="last-ground-truth-grid" class="grid-box"></div>
|
86 |
+
</div>
|
87 |
+
<div>
|
88 |
+
<div class="grid-title">Predicted Output by Best Program</div>
|
89 |
+
<div id="predicted-output-grid" class="grid-box"></div>
|
90 |
+
</div>
|
91 |
+
</div>
|
92 |
+
|
93 |
<script>
|
94 |
const inputOutputPairs = {{ input_output_pairs | tojson }};
|
95 |
const hlcs = {{ hlcs | tojson }};
|
96 |
+
const lastInput = {{ last_input | tojson }};
|
97 |
+
const lastGroundTruth = {{ last_ground_truth | tojson }};
|
98 |
+
const predictedOutput = {{ predicted_output | tojson }};
|
99 |
|
100 |
const colorMap = {
|
101 |
0: "#FFFFFF", 1: "#0074D9", 2: "#FF4136", 3: "#2ECC40",
|
|
|
147 |
const conceptText = document.createElement("div");
|
148 |
conceptText.className = "concept-text";
|
149 |
conceptText.innerText = hlcs[index] || "N/A";
|
|
|
150 |
conceptDiv.appendChild(conceptTitle);
|
151 |
conceptDiv.appendChild(conceptText);
|
152 |
|
153 |
+
// Combine all parts
|
154 |
container.appendChild(inputDiv);
|
155 |
container.appendChild(outputDiv);
|
156 |
container.appendChild(conceptDiv);
|
157 |
pairsContainer.appendChild(container);
|
158 |
});
|
159 |
+
|
160 |
+
// Render best program application result
|
161 |
+
drawGrid(document.getElementById("last-input-grid"), lastInput);
|
162 |
+
drawGrid(document.getElementById("last-ground-truth-grid"), lastGroundTruth);
|
163 |
+
drawGrid(document.getElementById("predicted-output-grid"), predictedOutput);
|
164 |
</script>
|
165 |
|
166 |
</body>
|