Skip to content

Commit

Permalink
Merge pull request ocropus-archive#274 from tmbdev/native-cleanup
Browse files Browse the repository at this point in the history
Native cleanup
  • Loading branch information
kba authored Dec 12, 2017
2 parents ed5b545 + dc0a09c commit d79fb4d
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 182 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,3 @@ retrain models as better recognizers become available.
After making CLSTM a full replacement for `ocropus-rtrain`/`ocropus-rpred`, the
next step will be to replace the binarization, text/image segmentation, and layout
analysis in OCRopus with trainable 2D LSTM models.

## Solution for clang

[Read README_OSX.md](README_OSX.md)
22 changes: 0 additions & 22 deletions README_OSX.md

This file was deleted.

8 changes: 5 additions & 3 deletions ocrolib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
__all__ = [
"binnednn","cairoextras","common","components","dbtables",
"fgen","gmmtree","gtkyield","hocr","lang","native",
"mlp","multiclass","default","lineest"
"common",
"hocr",
"lang",
"default",
"lineest",
]

################################################################
Expand Down
31 changes: 0 additions & 31 deletions ocrolib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,37 +767,6 @@ def ustrg2unicode(u,lig=ligatures.lig):
result += "<%d>"%value
return result

### code for instantiation native components

def pyconstruct(s):
"""Constructs a Python object from a constructor, an expression
of the form x.y.z.name(args). This ensures that x.y.z is imported.
In the future, more forms of syntax may be accepted."""
env = {}
if "(" not in s:
s += "()"
path = s[:s.find("(")]
if "." in path:
module = path[:path.rfind(".")]
print("import", module)
exec "import "+module in env
return eval(s,env)

def mkpython(name):
"""Tries to instantiate a Python class. Gives an error if it looks
like a Python class but can't be instantiated. Returns None if it
doesn't look like a Python class."""
if name is None or len(name)==0:
return None
elif type(name) is not str:
return name()
elif name[0]=="=":
return pyconstruct(name[1:])
elif "(" in name or "." in name:
return pyconstruct(name)
else:
return None

################################################################
### loading and saving components
################################################################
Expand Down
11 changes: 0 additions & 11 deletions ocrolib/lstm.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,6 @@ def sumouter(us,vs,lo=-1.0,hi=1.0,out=None):
result += outer(clip(u,lo,hi),v)
return result

def sumprod(us,vs,lo=-1.0,hi=1.0,out=None):
"""Sum the element-wise products of the `us` and `vs`.
Values are clipped into the range `[lo,hi]`.
This is mainly used for computing weight updates
in logistic regression layers."""
assert len(us[0])==len(vs[0])
result = out or zeros(len(us[0]))
for u,v in zip(us,vs):
result += clip(u,lo,hi)*v
return result

class Network:
"""General interface for networks. This mainly adds convenience
functions for `predict` and `train`.
Expand Down
70 changes: 0 additions & 70 deletions ocrolib/native.py

This file was deleted.

41 changes: 0 additions & 41 deletions ocrolib/nutils.py

This file was deleted.

0 comments on commit d79fb4d

Please sign in to comment.