Closed camoconnell closed 4 years ago
Hello!
I'm not sure that I'm following the goals of this.
model.save
on an a model instance, rather than the abstract graph (ie. Model.save
)? (That isn't an intended use of save and we should make it impossible.)Normally, you'd have a one script construct and export your model, then import it in another script for visualization.
Hi Colah,
Apologies, excuse the naive questions, i'm still getting familiar (conceptually) with how Style Transfer works.
The goal is to generate a saved_model.pb from the Style Transfer example and convert it via tensorflowjs_converter to the json web format, so i can run it in the browser. Therefore the flow is;
To answer your first two points; In the example we create an instance of the InceptionV1 model and retrain it. Having read the "Importing Models into Lucid" documentation on GH i had assumed that the code to retrain ( construct the model inference graph ) was, as per the snippet above;
param_f = lambda: style_transfer_param(content_image, style_image)
...
vis = render.render_vis(model, objective, param_f=param_f, thresholds=[40], verbose=False, print_objectives=[content_obj, style_obj])[-1]
Hence why i went about wrapping the code in a session and calling model.save() after render.render_vis().
edit : sorry , just realised i'm logged in with my other account, this is camoconnell
You might want to look at Interactive Stefan Sietzen and Manuela Waldner work on Feature Visualization in the Browser.
Unfortunately, exporting a visualization graph like this isn't a supported use of lucid, and you're likely to run into a number of issues:
Model.save()
is intended to export models (ie. the object you call model
) and not visualization graphs. You're likely to run into places where the code makes assumptions that don't hold for the visualization graph.I would recommend using tfjs to run your model, and implementing style transfer using Stefan's code or from scratch in javascript.
Thanks for taking the time to reply,
Ok, makes sense. The 'Feature Visualization in the Browser' link looks incredible.
Will be in contact if i get an example running in tfjs using a Lucid trained model.
Hi there,
I'm working on saving a model out of the style transfer example on seedbank.
I have managed to generate a saved model by wrapping the with the following code;
however, judging by the logs below, it appears to be exporting an empty saved_model.pb
Should i be running sess.run() in the gram_matrix or activation_difference functions to populate the graph?
thanks