PAIR-code / what-if-tool

Source code/webpage/demos for the What-If Tool
https://pair-code.github.io/what-if-tool
Apache License 2.0
923 stars 170 forks source link

Use WiT inside Streamlit app #175

Closed AlexGidiotis closed 3 years ago

AlexGidiotis commented 3 years ago

I am trying to create a small python service with WiT (for example wrap it in a Streamlit app). Is it possible to run the WitWidget outside a notebook?

If that's not possible then what would be a different way to go about it?

*Note: I have created a custom predict function and have a model that takes multiple inputs, so I could not get it working with tf-serving.

jameswex commented 3 years ago

The What-If Tool itself is definitely usable outside of notebooks, but not through the WitWidget API. We didn't architect WIT to be easily pluggable into any UI, but it should absolutely be possible. For example, our web demos on the WIT website embed the tool in a static webpage. In that case, the data loading and model inference are all done in javascript, using TensorFlow.js. But one could also take a similar approach as the demo apps do, but instead call back to a py server to get datapoints and model results.

The code in https://github.com/PAIR-code/what-if-tool/tree/master/wit_dashboard/demo shows how all the web demos work. See the BUILD file for how they are built using bazel, and see wit-demo.html and index.html for a simple demo of UCI census, or the other files for different web demos.

AlexGidiotis commented 3 years ago

Thanks for the answer. We decided to move forward with a different solution atm. But we may come back try out this approach in the future.