Upload 7 files
Browse files- detact_color.zip +3 -0
- detact_icon.zip +3 -0
- ocr.zip +3 -0
- split.py +75 -0
- test.json +0 -0
- train.json +0 -0
- val.json +0 -0
detact_color.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:94ca7c177549c93d9d858748c85c360b029e19cb2c51143ee80c7575fe3632c0
|
| 3 |
+
size 65100
|
detact_icon.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:23bc186a65c405d0ac8d3a84749ac5aa770980920300f9391b98fd2e774a5df3
|
| 3 |
+
size 67139
|
ocr.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:74cbf1180c2263f34a723de1da93bd4d07dae8d3e0804a9c3cf00e608f3cad0a
|
| 3 |
+
size 200305
|
split.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from glob import glob
|
| 2 |
+
import os
|
| 3 |
+
import json
|
| 4 |
+
import random
|
| 5 |
+
|
| 6 |
+
train_cnt = 0
|
| 7 |
+
test_cnt = 0
|
| 8 |
+
val_cnt = 0
|
| 9 |
+
combined_cnt = 0
|
| 10 |
+
|
| 11 |
+
train_final = {}
|
| 12 |
+
test_final = {}
|
| 13 |
+
val_final = {}
|
| 14 |
+
combined_final = {}
|
| 15 |
+
for fn in glob("data/tasks/*/*"):
|
| 16 |
+
print(fn)
|
| 17 |
+
app_name = fn.split('/')[3]
|
| 18 |
+
app_type = fn.split('/')[2]
|
| 19 |
+
for i in range(1,10):
|
| 20 |
+
image = f"data/data/{app_type}/{app_name}/screen_{i}.png"
|
| 21 |
+
if os.path.exists(image) == False:
|
| 22 |
+
if i == 1:
|
| 23 |
+
print(image)
|
| 24 |
+
continue
|
| 25 |
+
ocr = f"ocr/{app_type}/{app_name}/screen_{i}.json"
|
| 26 |
+
assert os.path.exists(ocr), ocr
|
| 27 |
+
color = f"detact_color/{app_type}/{app_name}/screen_{i}.json"
|
| 28 |
+
assert os.path.exists(color), color
|
| 29 |
+
icon = f"detact_icon/{app_type}/{app_name}/screen_{i}.json"
|
| 30 |
+
assert os.path.exists(icon), icon
|
| 31 |
+
box = f"data/metadata/{app_type}/boxes/{app_name}/screen_{i}.json"
|
| 32 |
+
assert os.path.exists(box), box
|
| 33 |
+
script_to_task_fn = {}
|
| 34 |
+
cnt = 0
|
| 35 |
+
for task_fn in glob(f"{fn}/task_{i}.*.txt"):
|
| 36 |
+
txt = '\n'.join(open(task_fn).read().strip().split('\n')[1:])
|
| 37 |
+
if txt not in script_to_task_fn:
|
| 38 |
+
script_to_task_fn[txt] = []
|
| 39 |
+
script_to_task_fn[txt].append(task_fn)
|
| 40 |
+
cnt += 1
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
for k in script_to_task_fn:
|
| 44 |
+
c_tasks = script_to_task_fn[k]
|
| 45 |
+
rand = random.randint(1,10)
|
| 46 |
+
if rand <= 7:
|
| 47 |
+
for c in c_tasks:
|
| 48 |
+
train_final[train_cnt] = {"task": c, "image": image, "ocr": ocr, "color": color, "icon": icon, "box": box}
|
| 49 |
+
train_cnt += 1
|
| 50 |
+
combined_final[combined_cnt] = {"task": c, "image": image, "ocr": ocr, "color": color, "icon": icon, "box": box}
|
| 51 |
+
combined_cnt += 1
|
| 52 |
+
elif rand == 8:
|
| 53 |
+
for c in c_tasks:
|
| 54 |
+
val_final[val_cnt] = {"task": c, "image": image, "ocr": ocr, "color": color, "icon": icon, "box": box}
|
| 55 |
+
val_cnt += 1
|
| 56 |
+
combined_final[combined_cnt] = {"task": c, "image": image, "ocr": ocr, "color": color, "icon": icon, "box": box}
|
| 57 |
+
combined_cnt += 1
|
| 58 |
+
elif rand > 8:
|
| 59 |
+
for c in c_tasks:
|
| 60 |
+
test_final[test_cnt] = {"task": c, "image": image, "ocr": ocr, "color": color, "icon": icon, "box": box}
|
| 61 |
+
test_cnt += 1
|
| 62 |
+
combined_final[combined_cnt] = {"task": c, "image": image, "ocr": ocr, "color": color, "icon": icon, "box": box}
|
| 63 |
+
combined_cnt += 1
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
print(train_cnt)
|
| 68 |
+
print(val_cnt)
|
| 69 |
+
print(test_cnt)
|
| 70 |
+
print(combined_cnt)
|
| 71 |
+
|
| 72 |
+
json.dump(train_final, open('train.json', "w"), indent=4)
|
| 73 |
+
json.dump(val_final, open("val.json","w"), indent=4)
|
| 74 |
+
json.dump(test_final, open("test.json","w"), indent=4)
|
| 75 |
+
json.dump(combined_final, open('combined.json','w'), indent=4)
|
test.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
train.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
val.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|