Skip to content

Commit

Permalink
Merge pull request #219 from jonnor/installable-package
Browse files Browse the repository at this point in the history
Create installable Python package
  • Loading branch information
majianjia authored Apr 7, 2024
2 parents 71f6dc0 + cc78135 commit dd4d0b7
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 24 deletions.
3 changes: 1 addition & 2 deletions docs/api_nnom.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# NNoM Utils - Structured API

What makes NNoM easy to use is the models can be deployed to MCU automatically or manually with the help of NNoM utils.
These functions are located in `scripts/nnom.py`
These functions are located in the `nnom` Python package.

This tools, will generate NNoM model using **Structured API** instead of 'layer API' in the previous script.

Expand All @@ -11,7 +11,6 @@ Usage in short, in your python file, add the scripts the directory to your envir
~~~
import sys
import os
sys.path.append(os.path.abspath("../../scripts"))
from nnom import *
~~~

Expand Down
2 changes: 0 additions & 2 deletions examples/auto_test/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import sys
import os
sys.path.append(os.path.abspath("../../scripts"))
print(sys.path)

from tensorflow.keras import *
from tensorflow.keras.datasets import mnist
Expand Down
2 changes: 0 additions & 2 deletions examples/keyword_spotting/kws-rnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

import matplotlib.pyplot as plt
import os
nnscript = os.path.abspath('../../scripts')
os.sys.path.append(nnscript)

from tensorflow.keras import *
from tensorflow.keras.datasets import mnist
Expand Down
2 changes: 0 additions & 2 deletions examples/keyword_spotting/kws.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

import matplotlib.pyplot as plt
import os
nnscript = os.path.abspath('../../scripts')
os.sys.path.append(nnscript)

from tensorflow.keras import *
from tensorflow.keras.datasets import mnist
Expand Down
2 changes: 0 additions & 2 deletions examples/mnist-densenet/mnist_densenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

import matplotlib.pyplot as plt
import os
nnscript = os.path.abspath('../../scripts')
os.sys.path.append(nnscript)

from tensorflow.keras import *
from tensorflow.keras.datasets import mnist
Expand Down
2 changes: 0 additions & 2 deletions examples/mnist-simple/mnist_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

import matplotlib.pyplot as plt
import os
nnscript = os.path.abspath('../../scripts')
os.sys.path.append(nnscript)

from tensorflow.keras import *
from tensorflow.keras.datasets import mnist
Expand Down
2 changes: 0 additions & 2 deletions examples/octave-conv/mnist_octaveconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

import matplotlib.pyplot as plt
import os
nnscript = os.path.abspath('../../scripts')
os.sys.path.append(nnscript)

from tensorflow.keras import *
from tensorflow.keras.datasets import mnist
Expand Down
4 changes: 0 additions & 4 deletions examples/rnn-denoise/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
import tensorflow as tf
import numpy as np

import sys
sys.path.append(os.path.abspath("../../scripts"))
print(sys.path)

from gen_dataset import *
from nnom import *

Expand Down
2 changes: 0 additions & 2 deletions examples/uci-har-rnn/uci_rnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

import matplotlib.pyplot as plt
import os
nnscript = os.path.abspath('../../scripts')
os.sys.path.append(nnscript)

from tensorflow.keras import *
from tensorflow.keras.datasets import mnist
Expand Down
2 changes: 0 additions & 2 deletions examples/uci-inception/uci_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

import matplotlib.pyplot as plt
import os
nnscript = os.path.abspath('../../scripts')
os.sys.path.append(nnscript)

from tensorflow.keras import *
from tensorflow.keras.datasets import mnist
Expand Down
35 changes: 35 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["scripts", "src", "inc", "port"]

[tool.hatch.build.targets.wheel.sources]
"scripts" = "nnom"
"src" = "nnom_core/src"
"inc" = "nnom_core/inc"
"port" = "nnom_core/port"

[project]
name = "nnom"
readme = "README.md"
requires-python = ">= 3.8"
keywords = ["machine learning", "deep learning", "microcontroller", "embedded"]
version = "0.5.0a1"

dependencies = [
"keras<3.0.0",
]

classifiers = [
"License :: OSI Approved :: MIT License",
]


[project.urls]
Homepage = "https://github.com/majianjia/nnom"
Documentation = "https://majianjia.github.io/nnom/"
Repository = "https://github.com/majianjia/nnom"

4 changes: 4 additions & 0 deletions scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@

# package

from .nnom import *

4 changes: 2 additions & 2 deletions scripts/nnom.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import tensorflow.keras.backend as K
from tensorflow.keras import *
from tensorflow.keras.layers import *
from fully_connected_opt_weight_generation import *
from gen_config import *
from .fully_connected_opt_weight_generation import *
from .gen_config import *
import scipy.stats
import time
import warnings
Expand Down

0 comments on commit dd4d0b7

Please sign in to comment.