keplr-io / quiver

Interactive convnet features visualization for Keras
https://keplr-io.github.io/quiver/
MIT License
1.75k stars 223 forks source link

Quiverboard does not show the model #73

Closed jorgeribeiro closed 3 months ago

jorgeribeiro commented 5 years ago

I can see the images I placed inside the folder, but on the left panel nothing in shown. I am using load_model from keras to use my own trained model (VGG16), saved as h5.

Also, there is an error in the browser's console when the page opens: TypeError: e.config.map is not a function The browser says the error is in app.14b8092d6ea379715007.js line 44. I don't know if there is a relation between both errors.

Does any of you know how to solve this?

jorgeribeiro commented 5 years ago

Some updates about this issue: I tried to use my own model as described, and my model is Sequential. The models used in the tutorials are Functional API and maybe (I am not sure about this) quiver is developed to work only with Functional API models. ASAP I will try to make a model as Functional API, and use it with quiver.

To solve my problem, I used VGG16 from Keras and it worked just fine, the only problem was that I had to train the network from scratch.

sudheerExperiments commented 5 years ago

Hello @jorgimello, I have similar issue. I am using custom network architecture built using functional API. When I launch quiver server, model architecture and images shows up, but when I select a layer, nothing shows up. I am getting error, 'No data to display'. How did you solve this issue?

jorgeribeiro commented 5 years ago

Hello @sudheerExperiments, have you selected a different layer? Because the first layers sometimes won't show anything, and it shows the message 'No data to display'. But the following layers maybe show something. Try it

sudheerExperiments commented 5 years ago

I tried for all layers. Same problem with other layers too..

Update: Checked again, issue still exists.

Is there any specific data format for quiver @jorgimello

jorgeribeiro commented 5 years ago

Well, I gotta try some new things, because I don't know the cause of your problem. But can you check your browser's console after running the application? See if any error is shown.

What you mean by data format? You mean the images to test?

sudheerExperiments commented 5 years ago

Hi,

I had problems with pip installed version of quiver, so I installed from git. Its working fine and I have all the latest updates.

I pinpointed the problem. It's because of my data format. Quiver requires input data to have (nrows, ncols, nchannels), however, my data uses (nchannels, nrows, ncols). The first format is called 'tf' format and the second format is called 'th' format. My model uses 'th' format. Similarly, the conv and max pooling layers also use 'th' format.

Somehow quiver doesn't handle layers which use 'th' format. I raised a new issue on this. Hope someone can help.

https://github.com/keplr-io/quiver/issues/74

Yeah the vgg16 one works. But mine doesn't.

Sebs030 commented 5 years ago

Hi, I am having the same issue as @jorgimello, the images show up, but the model architecture doesn´t. Instead the error TypeError: e.config.map is not a function is displayed in the google chrome console. I am using a custom sequential model, but i don´t think that´s the issue. Has anyone found a solution to this problem so far?

jorgeribeiro commented 5 years ago

Well, I haven't. My solution was to use the models provided by Keras.

945226956 commented 5 years ago

I come a same problem. really hope fix soooooooooooooooooon ... :)

ghylander commented 3 years ago

Some updates about this issue: I tried to use my own model as described, and my model is Sequential. The models used in the tutorials are Functional API and maybe (I am not sure about this) quiver is developed to work only with Functional API models. ASAP I will try to make a model as Functional API, and use it with quiver.

To solve my problem, I used VGG16 from Keras and it worked just fine, the only problem was that I had to train the network from scratch.

i have the problem too i have been able to take my sequential model and translate it to functional by simply replicating it, but i still get the same console error.

I think the problem might have to do with what sudheerExperiments says about the channels

avaritia95 commented 2 years ago

I found out that the problem comes from a javascript function try to use map on the wrong type.
I use VGG16 model from Keras 2.9. The server response to "/model" request is

{
    backend: "tensorflow",
    class_name: "Functional",
    config: {
        input_layers: [["input_1", 0, 0]]
        layers: [{class_name: "InputLayer",…}, {class_name: "Conv2D",…}, {class_name: "Conv2D",…},…]
        name: "vgg16"
    },
    output_layers: [["block5_pool", 0, 0]]
}

Because class_name is not "Model", the function computeCytoscapeGraph (quiverboard/src/ModelGraph/util.js) invoke getSequentialCytoscapeGraph instead of getModelCytoscapeGraph. The former function tries to use map on "config" while it is an dictionary, hence the error.

ghylander commented 2 years ago

Because class_name is not "Model", the function computeCytoscapeGraph (quiverboard/src/ModelGraph/util.js) invoke getSequentialCytoscapeGraph instead of getModelCytoscapeGraph. The former function tries to use map on "config" while it is an dictionary, hence the error.

That's a great find! I had given up on this project and implemented a manual visualization tool using fchollet's work, but getting this to work would be great, both as a personal battle and because it's prettier.

I had removed my previous version of quiver and reinstalled just in hope we can make it work again. This led me to find out that Quiver is not currently compatible with python3.10, as I get the following error stack:

python3.10 pip install quiver_engine error ``` ERROR: Command errored out with exit status 1: command: /home/ghylander/miniconda3/envs/CH/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-dxqfv_2r/quiver-engine_efdd254386bc4d63b679aaef339b2a90/setup.py'"'"'; __file__='"'"'/tmp/pip-install-dxqfv_2r/quiver-engine_efdd254386bc4d63b679aaef339b2a90/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ehx0pyab cwd: /tmp/pip-install-dxqfv_2r/quiver-engine_efdd254386bc4d63b679aaef339b2a90/ Complete output (1 lines): error in quiver_engine setup command: "values of 'package_data' dict" must be a list of strings (got 'quiverboard/dist/*') ```

I don't have experience with js, html or anything web-related. Wave you managed some progress? I tried modifying the 'util.js' under quiverboard>src>components>ModelGraph:

export function computeCytoscapeGraph(kerasGraph, prefix) {
    return kerasGraph.class_name === 'Functional'
        ? getModelCytoscapeGraph(kerasGraph, prefix)
        : getSequentialCytoscapeGraph(kerasGraph, prefix);
}

and

function isNodeSubgraph(layer) {
    return ['Sequential', 'Functional'].indexOf(layer.class_name) !== -1;
}

But it's not working. I don't know if quiver is using those files though. I had to install quiver using pip, since when I tried to download the repo and build from source, I got many errors from npm. Installing quiver from pip resulted in a quiver_engine folder missing the quiverboard folder, so I copied over the quiveboard folder from the repo to the quiver_engine python site-packages folder.

ghylander commented 2 years ago

Managed to "solve" the Model != Functional issue

I edited the compiled js file (inmy case, it was called "app.14b8092d6ea379715007.js"

Had to change it in 2 spots:

This seems to load the model correctly and apply the map function to it, but results in countless new errors. These errors I assume are coming from unhandled layers. Screenshot of some of the errors: image

avaritia95 commented 2 years ago

I edited the compiled js file (inmy case, it was called "app.14b8092d6ea379715007.js"

If you are building from source, please change the code in quiverboard/src/ModelGraph/util.js and then use the command npm deploy:prod while in quiverboard directory. Ignore any error with UglifyJs for now. The command will create a new .js file in quiverboard/dist, and your code change will be picked up by the server.

I tried to use my own model as described, and my model is Sequential.

Not really relevant to the topic but I wonder if your Sequential model has problem with inbound_nodes. My browser shows this error Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'length') for my VGG16 model because it has no property inbound_nodes.