woletee commited on
Commit
f60fef5
·
1 Parent(s): 3537d48

Switch to Flask with HTML visualization

Browse files
Files changed (5) hide show
  1. app.py +5 -2
  2. static/styles.css +28 -0
  3. templates/index.html +4 -4
  4. templates/results.html +15 -5
  5. utils.py +1 -0
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from flask import Flask, request, render_template, redirect, url_for
2
  import os
3
  import json
4
  from Vit_concept import run_inference, model
@@ -49,7 +49,10 @@ def upload():
49
  predicted_HLCs=predicted_HLCs
50
  )
51
 
52
- return render_template("results.html", hlcs=predicted_HLCs, program=str(best_program))
 
 
 
53
 
54
  if __name__ == '__main__':
55
  app.run(host="0.0.0.0", port=7860)
 
1
+ from flask import Flask, request, render_template
2
  import os
3
  import json
4
  from Vit_concept import run_inference, model
 
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)
static/styles.css CHANGED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ font-family: Arial, sans-serif;
3
+ background-color: #111;
4
+ color: white;
5
+ text-align: center;
6
+ }
7
+
8
+ h1, h2, h3 {
9
+ color: #FFD700;
10
+ }
11
+
12
+ .grid-wrapper {
13
+ background-color: #222;
14
+ padding: 15px;
15
+ margin: 20px auto;
16
+ border-radius: 10px;
17
+ width: 80%;
18
+ box-shadow: 0 0 10px #fff2;
19
+ }
20
+
21
+ pre {
22
+ background: #000;
23
+ color: #0f0;
24
+ padding: 10px;
25
+ border-radius: 5px;
26
+ text-align: left;
27
+ overflow-x: auto;
28
+ }
templates/index.html CHANGED
@@ -2,14 +2,14 @@
2
  <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
5
- <title>ARC Task Solver</title>
6
- <link rel="stylesheet" href="/static/styles.css">
7
  </head>
8
  <body>
9
- <h1>Upload ARC Task File</h1>
10
  <form action="/upload" method="post" enctype="multipart/form-data">
11
  <input type="file" name="file" accept=".json" required>
12
- <button type="submit">Upload & Solve</button>
13
  </form>
14
  </body>
15
  </html>
 
2
  <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
5
+ <title>ARC Task Upload</title>
6
+ <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
7
  </head>
8
  <body>
9
+ <h1>Upload ARC Task</h1>
10
  <form action="/upload" method="post" enctype="multipart/form-data">
11
  <input type="file" name="file" accept=".json" required>
12
+ <button type="submit">Submit</button>
13
  </form>
14
  </body>
15
  </html>
templates/results.html CHANGED
@@ -2,18 +2,28 @@
2
  <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
5
- <title>Results</title>
6
- <link rel="stylesheet" href="/static/styles.css">
7
  </head>
8
  <body>
9
- <h1>Predicted Concepts</h1>
10
  <ul>
11
  {% for hlc in hlcs %}
12
  <li>{{ hlc }}</li>
13
  {% endfor %}
14
  </ul>
15
 
16
- <h2>Best Genetic Program</h2>
17
- <pre>{{ program }}</pre>
 
 
 
 
 
 
 
 
 
 
18
  </body>
19
  </html>
 
2
  <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
5
+ <title>ARC Results</title>
6
+ <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
7
  </head>
8
  <body>
9
+ <h1>Predicted High-Level Concepts</h1>
10
  <ul>
11
  {% for hlc in hlcs %}
12
  <li>{{ hlc }}</li>
13
  {% endfor %}
14
  </ul>
15
 
16
+ <h2>Input / Output Pairs</h2>
17
+ {% for pair in input_output_pairs %}
18
+ <div class="grid-wrapper">
19
+ <h3>Input Grid</h3>
20
+ <pre>{{ pair[0] }}</pre>
21
+ <h3>Output Grid</h3>
22
+ <pre>{{ pair[1] }}</pre>
23
+ </div>
24
+ {% endfor %}
25
+
26
+ <h2>Best Program</h2>
27
+ <pre>{{ best_program }}</pre>
28
  </body>
29
  </html>
utils.py CHANGED
@@ -5,6 +5,7 @@ from random import choice, randint, sample, shuffle, uniform
5
 
6
  from dsl import *
7
 
 
8
 
9
  global rng
10
  rng = []
 
5
 
6
  from dsl import *
7
 
8
+ from typing import Tuple, Any
9
 
10
  global rng
11
  rng = []