diff --git a/misc/frugally-deep/Makefile b/misc/frugally-deep/Makefile index a982a6092fb2..019e11246a1d 100644 --- a/misc/frugally-deep/Makefile +++ b/misc/frugally-deep/Makefile @@ -1,36 +1,53 @@ PORTNAME= frugally-deep DISTVERSIONPREFIX= v -DISTVERSION= 0.16.2 +DISTVERSION= 0.19.2 CATEGORIES= misc # deep-learning MAINTAINER= yuri@FreeBSD.org COMMENT= C++ header-only library to use Keras models in C++ with ease WWW= https://github.com/Dobiasd/frugally-deep LICENSE= MIT LICENSE_FILE= ${WRKSRC}/LICENSE HPP_DEPENDS= functionalplus>0:devel/functionalplus \ nlohmann-json>0:devel/nlohmann-json BUILD_DEPENDS= ${HPP_DEPENDS} -RUN_DEPENDS= ${HPP_DEPENDS} -TEST_DEPENDS= doctest>0:devel/doctest \ - ${PYTHON_PKGNAMEPREFIX}keras>0:math/py-keras@${PY_FLAVOR} +RUN_DEPENDS= ${HPP_DEPENDS} \ + ${PYTHON_PKGNAMEPREFIX}keras>0:math/py-keras@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}tensorflow>0:science/py-tensorflow@${PY_FLAVOR} +TEST_DEPENDS= doctest>0:devel/doctest USES= cmake compiler:c++14-lang eigen:3,build,run python:test USE_GITHUB= yes GH_ACCOUNT= Dobiasd NO_BUILD= yes NO_ARCH= yes BINARY_ALIAS= python3=${PYTHON_CMD} -do-test: # tests are broken because they require tensorflow which is currently not available on FreeBSD +test-quick: # compiled files/example-* (from README) into executable test-quick + @${MKDIR} ${TEST_WRKSRC}/test-quick && \ + cd ${TEST_WRKSRC}/test-quick && \ + ${ECHO} "Creating Keras model and converting it to frugally-deep format ..." && \ + ${PYTHON_CMD} ${FILESDIR}/example-create-model.py && \ + ${PYTHON_CMD} ${WRKSRC}/keras_export/convert_model.py keras_model.keras fdeep_model.json && \ + ${ECHO} "Compiling example-run.cpp ..." && \ + ${CXX} ${CXXFLAGS} \ + -I${STAGEDIR}${LOCALBASE}/include \ + -I${LOCALBASE}/include \ + -I${LOCALBASE}/include/eigen3 \ + ${FILESDIR}/example-run.cpp \ + -o test-quick && \ + ${ECHO} "Running test-quick ..." && \ + ./test-quick + +do-test: # tests fail to compile, see https://github.com/Dobiasd/frugally-deep/issues/462 @cd ${BUILD_WRKSRC} && \ ${SETENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} -DFDEEP_BUILD_UNITTEST:BOOL=ON ${CMAKE_SOURCE_PATH} && \ ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} ${ALL_TARGET} && \ ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} test .include diff --git a/misc/frugally-deep/distinfo b/misc/frugally-deep/distinfo index 6a715e07b72f..4daa0d5eaca6 100644 --- a/misc/frugally-deep/distinfo +++ b/misc/frugally-deep/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1737681871 -SHA256 (Dobiasd-frugally-deep-v0.16.2_GH0.tar.gz) = b16af09606dcf02359de53b7c47323baaeda9a174e1c87e126c3127c55571971 -SIZE (Dobiasd-frugally-deep-v0.16.2_GH0.tar.gz) = 195509 +TIMESTAMP = 1777392520 +SHA256 (Dobiasd-frugally-deep-v0.19.2_GH0.tar.gz) = b78fc8b59ec2dc745fae514384d1edc8a22f7ba92b6627b771fb5966576624f2 +SIZE (Dobiasd-frugally-deep-v0.19.2_GH0.tar.gz) = 202644 diff --git a/misc/frugally-deep/files/example-create-model.py b/misc/frugally-deep/files/example-create-model.py new file mode 100644 index 000000000000..b802ed86a725 --- /dev/null +++ b/misc/frugally-deep/files/example-create-model.py @@ -0,0 +1,16 @@ +# create_model.py +import numpy as np +from keras.layers import Input, Dense +from keras.models import Model + +inputs = Input(shape=(4,)) +x = Dense(5, activation='relu')(inputs) +predictions = Dense(3, activation='softmax')(x) +model = Model(inputs=inputs, outputs=predictions) +model.compile(loss='categorical_crossentropy', optimizer='nadam') + +model.fit( + np.asarray([[1, 2, 3, 4], [2, 3, 4, 5]]), + np.asarray([[1, 0, 0], [0, 0, 1]]), epochs=10) + +model.save('keras_model.keras') diff --git a/misc/frugally-deep/files/example-run.cpp b/misc/frugally-deep/files/example-run.cpp new file mode 100644 index 000000000000..beb2daaad9eb --- /dev/null +++ b/misc/frugally-deep/files/example-run.cpp @@ -0,0 +1,15 @@ +// from README.md + +#include + +int main() { + try { + const auto model = fdeep::load_model("fdeep_model.json"); + const auto result = model.predict( + {fdeep::tensor(fdeep::tensor_shape(static_cast(4)), + std::vector{1, 2, 3, 4})}); + std::cout << fdeep::show_tensors(result) << std::endl; + } catch (std::runtime_error exception) { + std::cerr << "Error: " << exception.what() << std::endl; + } +} diff --git a/misc/frugally-deep/pkg-plist b/misc/frugally-deep/pkg-plist index 123b3d1a2292..74b12e7f2104 100644 --- a/misc/frugally-deep/pkg-plist +++ b/misc/frugally-deep/pkg-plist @@ -1,78 +1,92 @@ include/fdeep/base64.hpp include/fdeep/common.hpp include/fdeep/convolution.hpp include/fdeep/convolution3d.hpp include/fdeep/depthwise_convolution.hpp include/fdeep/fdeep.hpp include/fdeep/filter.hpp include/fdeep/import_model.hpp include/fdeep/layers/activation_layer.hpp include/fdeep/layers/add_layer.hpp include/fdeep/layers/additive_attention_layer.hpp include/fdeep/layers/attention_layer.hpp include/fdeep/layers/average_layer.hpp include/fdeep/layers/average_pooling_3d_layer.hpp include/fdeep/layers/batch_normalization_layer.hpp include/fdeep/layers/category_encoding_layer.hpp +include/fdeep/layers/celu_layer.hpp include/fdeep/layers/centercrop_layer.hpp include/fdeep/layers/concatenate_layer.hpp include/fdeep/layers/conv_2d_layer.hpp +include/fdeep/layers/conv_2d_transpose_layer.hpp +include/fdeep/layers/conv_3d_layer.hpp +include/fdeep/layers/conv_3d_transpose_layer.hpp include/fdeep/layers/cropping_3d_layer.hpp include/fdeep/layers/dense_layer.hpp include/fdeep/layers/depthwise_conv_2d_layer.hpp include/fdeep/layers/dot_layer.hpp include/fdeep/layers/elu_layer.hpp include/fdeep/layers/embedding_layer.hpp include/fdeep/layers/exponential_layer.hpp include/fdeep/layers/flatten_layer.hpp include/fdeep/layers/gelu_layer.hpp include/fdeep/layers/global_average_pooling_3d_layer.hpp include/fdeep/layers/global_max_pooling_3d_layer.hpp include/fdeep/layers/global_pooling_layer.hpp +include/fdeep/layers/hard_shrink_layer.hpp include/fdeep/layers/hard_sigmoid_layer.hpp +include/fdeep/layers/hard_tanh_layer.hpp include/fdeep/layers/input_layer.hpp include/fdeep/layers/layer.hpp include/fdeep/layers/layer_normalization_layer.hpp include/fdeep/layers/leaky_relu_layer.hpp include/fdeep/layers/linear_layer.hpp +include/fdeep/layers/log_sigmoid_layer.hpp +include/fdeep/layers/log_softmax_layer.hpp include/fdeep/layers/max_pooling_3d_layer.hpp include/fdeep/layers/maximum_layer.hpp include/fdeep/layers/minimum_layer.hpp include/fdeep/layers/model_layer.hpp include/fdeep/layers/multi_head_attention_layer.hpp include/fdeep/layers/multiply_layer.hpp include/fdeep/layers/normalization_layer.hpp include/fdeep/layers/permute_layer.hpp include/fdeep/layers/pooling_3d_layer.hpp include/fdeep/layers/prelu_layer.hpp include/fdeep/layers/relu_layer.hpp include/fdeep/layers/repeat_vector_layer.hpp include/fdeep/layers/rescaling_layer.hpp include/fdeep/layers/reshape_layer.hpp include/fdeep/layers/resizing_layer.hpp include/fdeep/layers/selu_layer.hpp include/fdeep/layers/separable_conv_2d_layer.hpp include/fdeep/layers/sigmoid_layer.hpp +include/fdeep/layers/soft_shrink_layer.hpp include/fdeep/layers/softmax_layer.hpp include/fdeep/layers/softplus_layer.hpp include/fdeep/layers/softsign_layer.hpp +include/fdeep/layers/sparse_plus_layer.hpp +include/fdeep/layers/square_plus_layer.hpp include/fdeep/layers/subtract_layer.hpp include/fdeep/layers/swish_layer.hpp include/fdeep/layers/tanh_layer.hpp +include/fdeep/layers/tanh_shrink_layer.hpp +include/fdeep/layers/threshold_layer.hpp include/fdeep/layers/time_distributed_layer.hpp include/fdeep/layers/unit_normalization_layer.hpp include/fdeep/layers/upsampling_1d_layer.hpp include/fdeep/layers/upsampling_2d_layer.hpp +include/fdeep/layers/upsampling_3d_layer.hpp include/fdeep/layers/zero_padding_3d_layer.hpp include/fdeep/model.hpp include/fdeep/node.hpp include/fdeep/recurrent_ops.hpp include/fdeep/shape2.hpp include/fdeep/shape3.hpp include/fdeep/tensor.hpp include/fdeep/tensor_pos.hpp include/fdeep/tensor_shape.hpp include/fdeep/tensor_shape_variable.hpp lib/cmake/frugally-deep/frugally-deepConfig.cmake lib/cmake/frugally-deep/frugally-deepConfigVersion.cmake lib/cmake/frugally-deep/frugally-deepTargets.cmake