Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/weights
detect_text/ocr.py
/output
34 changes: 34 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Single Test",
"type": "python",
"request": "launch",
"program": "run_single.py",
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "Python: Tune Test",
"type": "python",
"request": "launch",
"program": "run_testing.py",
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "Python: Batch Test",
"type": "python",
"request": "launch",
"program": "run_batch.py",
"console": "integratedTerminal",
"justMyCode": false,
"args": [
"--cat","poster"]
}
]
}
6 changes: 4 additions & 2 deletions cnn/CNN.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import keras
from keras.applications.resnet50 import ResNet50
# from keras.applications.resnet50 import ResNet50
from tensorflow.keras.applications.resnet50 import ResNet50
from keras.models import Model,load_model
from keras.layers import Dense, Activation, Flatten, Dropout
from sklearn.metrics import confusion_matrix
Expand Down Expand Up @@ -87,7 +88,8 @@ def predict(self, imgs, compos, load=False, show=False):
return
for i in range(len(imgs)):
X = self.preprocess_img(imgs[i])
Y = self.class_map[np.argmax(self.model.predict(X))]
# verbose=0: for no log output for keras model.
Y = self.class_map[np.argmax(self.model.predict(X,verbose=0))]
compos[i].category = Y
if show:
print(Y)
Expand Down
Binary file modified cnn/__pycache__/CNN.cpython-35.pyc
Binary file not shown.
Binary file added cnn/__pycache__/CNN.cpython-37.pyc
Binary file not shown.
Binary file added cnn/__pycache__/CNN.cpython-39.pyc
Binary file not shown.
8 changes: 4 additions & 4 deletions config/CONFIG.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
from os.path import join as pjoin
import os


ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
class Config:

def __init__(self):
# setting CNN (graphic elements) model
self.image_shape = (64, 64, 3)
# self.MODEL_PATH = 'E:\\Mulong\\Model\\UI2CODE\\cnn6_icon.h5'
# self.class_map = ['button', 'input', 'icon', 'img', 'text']
self.CNN_PATH = 'E:/Mulong/Model/rico_compos/cnn-rico-1.h5'
self.CNN_PATH = ROOT + '/weights/cnn-rico-1.h5'
self.element_class = ['Button', 'CheckBox', 'Chronometer', 'EditText', 'ImageButton', 'ImageView',
'ProgressBar', 'RadioButton', 'RatingBar', 'SeekBar', 'Spinner', 'Switch',
'ToggleButton', 'VideoView', 'TextView']
self.class_number = len(self.element_class)

# setting EAST (ocr) model
self.EAST_PATH = 'E:/Mulong/Model/East/east_icdar2015_resnet_v1_50_rbox'
self.EAST_PATH = ROOT + '/weights/east_icdar2015_resnet_v1_50_rbox'

self.COLOR = {'Button': (0, 255, 0), 'CheckBox': (0, 0, 255), 'Chronometer': (255, 166, 166),
'EditText': (255, 166, 0),
Expand All @@ -25,7 +25,7 @@ def __init__(self):
'RatingBar': (0, 166, 255), 'SeekBar': (0, 166, 10), 'Spinner': (50, 21, 255),
'Switch': (80, 166, 66), 'ToggleButton': (0, 66, 80), 'VideoView': (88, 66, 0),
'TextView': (169, 255, 0), 'NonText': (0,0,255),
'Compo':(0, 0, 255), 'Text':(169, 255, 0), 'Block':(80, 166, 66)}
'Compo':(0, 0, 255), 'Text':(169, 140, 0), 'Block':(80, 166, 66)}

def build_output_folders(self):
# setting data flow paths
Expand Down
Binary file modified config/__pycache__/CONFIG.cpython-35.pyc
Binary file not shown.
Binary file modified config/__pycache__/CONFIG.cpython-37.pyc
Binary file not shown.
Binary file added config/__pycache__/CONFIG.cpython-39.pyc
Binary file not shown.
Binary file modified config/__pycache__/CONFIG_UIED.cpython-35.pyc
Binary file not shown.
Binary file modified config/__pycache__/CONFIG_UIED.cpython-37.pyc
Binary file not shown.
Binary file added config/__pycache__/CONFIG_UIED.cpython-39.pyc
Binary file not shown.
Binary file added data/output/ip/30800.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
279 changes: 279 additions & 0 deletions data/output/ip/30800.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
{
"img_shape": [
800,
494,
3
],
"compos": [
{
"id": 1,
"class": "ImageView",
"column_min": 18,
"row_min": 25,
"column_max": 79,
"row_max": 47,
"width": 61,
"height": 22
},
{
"id": 2,
"class": "SeekBar",
"column_min": 403,
"row_min": 23,
"column_max": 429,
"row_max": 50,
"width": 26,
"height": 27
},
{
"id": 3,
"class": "ImageView",
"column_min": 84,
"row_min": 26,
"column_max": 142,
"row_max": 51,
"width": 58,
"height": 25
},
{
"id": 4,
"class": "ImageView",
"column_min": 464,
"row_min": 25,
"column_max": 471,
"row_max": 47,
"width": 7,
"height": 22
},
{
"id": 5,
"class": "ImageButton",
"column_min": 446,
"row_min": 73,
"column_max": 489,
"row_max": 117,
"width": 43,
"height": 44
},
{
"id": 6,
"class": "ImageView",
"column_min": 6,
"row_min": 81,
"column_max": 43,
"row_max": 110,
"width": 37,
"height": 29
},
{
"id": 7,
"class": "ImageView",
"column_min": 98,
"row_min": 88,
"column_max": 181,
"row_max": 106,
"width": 83,
"height": 18
},
{
"id": 8,
"class": "ImageView",
"column_min": 187,
"row_min": 88,
"column_max": 218,
"row_max": 106,
"width": 31,
"height": 18
},
{
"id": 9,
"class": "ImageView",
"column_min": 219,
"row_min": 88,
"column_max": 261,
"row_max": 109,
"width": 42,
"height": 21
},
{
"id": 10,
"class": "TextView",
"column_min": 266,
"row_min": 88,
"column_max": 309,
"row_max": 106,
"width": 43,
"height": 18
},
{
"id": 11,
"class": "ImageView",
"column_min": 314,
"row_min": 88,
"column_max": 394,
"row_max": 106,
"width": 80,
"height": 18
},
{
"id": 12,
"class": "ImageView",
"column_min": 216,
"row_min": 190,
"column_max": 276,
"row_max": 249,
"width": 60,
"height": 59
},
{
"id": 13,
"class": "ImageView",
"column_min": 0,
"row_min": 352,
"column_max": 493,
"row_max": 592,
"width": 493,
"height": 240
},
{
"id": 14,
"class": "ImageView",
"column_min": 9,
"row_min": 618,
"column_max": 14,
"row_max": 659,
"width": 5,
"height": 41
},
{
"id": 15,
"class": "ImageView",
"column_min": 29,
"row_min": 620,
"column_max": 50,
"row_max": 654,
"width": 21,
"height": 34
},
{
"id": 16,
"class": "ImageView",
"column_min": 83,
"row_min": 619,
"column_max": 420,
"row_max": 655,
"width": 337,
"height": 36
},
{
"id": 17,
"class": "ImageView",
"column_min": 453,
"row_min": 631,
"column_max": 464,
"row_max": 644,
"width": 11,
"height": 13
},
{
"id": 18,
"class": "ImageView",
"column_min": 203,
"row_min": 664,
"column_max": 218,
"row_max": 671,
"width": 15,
"height": 7
},
{
"id": 19,
"class": "ImageView",
"column_min": 25,
"row_min": 682,
"column_max": 74,
"row_max": 729,
"width": 49,
"height": 47
},
{
"id": 20,
"class": "ImageView",
"column_min": 123,
"row_min": 682,
"column_max": 171,
"row_max": 732,
"width": 48,
"height": 50
},
{
"id": 21,
"class": "ImageView",
"column_min": 222,
"row_min": 681,
"column_max": 270,
"row_max": 730,
"width": 48,
"height": 49
},
{
"id": 22,
"class": "ImageView",
"column_min": 321,
"row_min": 682,
"column_max": 369,
"row_max": 732,
"width": 48,
"height": 50
},
{
"id": 23,
"class": "SeekBar",
"column_min": 420,
"row_min": 682,
"column_max": 467,
"row_max": 729,
"width": 47,
"height": 47
},
{
"id": 24,
"class": "TextView",
"column_min": 0,
"row_min": 737,
"column_max": 493,
"row_max": 795,
"width": 493,
"height": 58
},
{
"id": 25,
"class": "ImageView",
"column_min": 26,
"row_min": 441,
"column_max": 56,
"row_max": 475,
"width": 30,
"height": 34
},
{
"id": 26,
"class": "ImageView",
"column_min": 72,
"row_min": 441,
"column_max": 97,
"row_max": 476,
"width": 25,
"height": 35
},
{
"id": 27,
"class": "TextView",
"column_min": 0,
"row_min": 737,
"column_max": 190,
"row_max": 793,
"width": 190,
"height": 56
}
]
}
Binary file added data/output/ip/result.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/output/merge/30800.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading