keras2circom is a python tool that transpiles a tf.keras model into a circom circuit.
First, clone the repository:
git clone https://github.com/socathie/keras2circom.gitThen, install the dependencies. You can use pip:
pip install -r requirements.txtIf you use conda, you can also create a new environment with the following command:
conda env create -f environment.ymlYou will also need to install circom and snarkjs. You can run the following commands to install them:
bash setup-circom.shLast but not least, run
npm installTo use the package, you can run the following command:
python main.py <model_path> [-o <output_dir>] [--raw]For example, to transpile the model in models/model.h5 into a circom circuit, you can run:
python main.py models/model.h5The output will be in the output directory.
If you want to transpile the model into a circom circuit with "raw" output, i.e. no ArgMax at the end, you can run:
python main.py models/model.h5 --rawTo test the package, you can run the following command:
npm test