Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Does lucid work outside colab? #230

Open
segalinc opened this issue Feb 21, 2020 · 21 comments
Open

Does lucid work outside colab? #230

segalinc opened this issue Feb 21, 2020 · 21 comments

Comments

@segalinc
Copy link

I am trying to run one of the ipynb outside colab in a juoyter notebook but visualizations are not showed, some model don't work.

I am using latest version of lucid I think is 0.3.8 and tensorflow-gpu 1.14.0

@Uiuran
Copy link

Uiuran commented Feb 21, 2020

this may be related to the issue #229 i posted earlier, seems to be something related with the preprocessings of the input but i still cant say exactly what it is .

@Uiuran
Copy link

Uiuran commented Feb 21, 2020

iam also using all libs in (seeminly) right versions, however the assertion error persists, the image_T_only produces Nans

@segalinc
Copy link
Author

yeah,it loses it's usability if you can only play in their environment

@Uiuran
Copy link

Uiuran commented Feb 21, 2020 via email

@segalinc
Copy link
Author

for me is more a matter of no being able to load some of the attributes in some modules or visualize correctly the objects and also assertions errors as well. If I had the time I would re-implement what I need but I am lacking of that at the moment.

Keep me posted as well, thank you

@Uiuran
Copy link

Uiuran commented Feb 21, 2020 via email

@segalinc
Copy link
Author

I am playing around with the texture 3d synthesis. I can run in on colab but outside it's a mess.

@Uiuran
Copy link

Uiuran commented Feb 21, 2020 via email

@segalinc
Copy link
Author

that would be really cool!!

@Uiuran
Copy link

Uiuran commented Feb 21, 2020 via email

@Uiuran
Copy link

Uiuran commented Feb 21, 2020 via email

@Uiuran
Copy link

Uiuran commented Feb 21, 2020 via email

@Uiuran
Copy link

Uiuran commented Feb 21, 2020

You can use something like this to try to debug the code while the devs are busy to not attend this bug.

def debug_info(tensor, mode="value"):
    import matplotlib.pyplot as plt
    with tf.Session(graph=tf.get_default_graph()) as sess:
        opinit=tf.global_variables_initializer()
        sess.run(opinit)
        t = tensor.eval()
        print(t.shape)
        print(t)        
        plt.imshow((t[0,...]*255))

@Uiuran
Copy link

Uiuran commented Feb 21, 2020 via email

@colah
Copy link
Contributor

colah commented Feb 21, 2020

Thanks for reaching out @cristinasegalin and @Uiuran .

Lucid itself does not depend on colab, but code in the notebooks often relies on colab features to create visualizations of lucid's output. I personally use lucid outside of colab on a day to day basis, as do many of my colleagues.

In order to say more, I'd need to you to report specific failures with debugging details.

Please keep in mind that Lucid is research code. It's maintained by researchers actively engaged in interpretability research. We share it with the community in the hopes that it helpful, but we don't have the capacity to provide detailed user support or debugging.

@Uiuran
Copy link

Uiuran commented Feb 21, 2020 via email

@Uiuran
Copy link

Uiuran commented Feb 22, 2020

thank you again, iam trying the following (this is mentioned in the render_vis docstring)

with tf.get_default_graph().as_default() as graph, tf.Session() as sess:                                                                                                       

   T = render.make_vis_T(model, "mixed4a:300")                                                                                                                      
   tf.initialize_all_variables().run()
                                                                                                                                                                
   for i in range(500):       
       if 10*(i//10)-i == 0:
         print(i)
       sess.run([T("vis_op").outputs[0]])      
   print(T("input").eval()[0].shape)
   plt.imshow(255*T("input").eval()[0])

But something seens not to be working, since i only get gray images or nan (the algorithm is non deterministic in some place too ...)

@Uiuran
Copy link

Uiuran commented Feb 22, 2020

i cant get the code to work, nor the same notebook of the tutorial, nor this simpler version (or more boring as stated in the docstring). As Colah said, there may be numerical stability issues, but it never happened to me when i was working on the deep dream code, so i will be back to that code, and as soon as this works outside colab, then i came back to contribute.

An aside: the mere fact that one thing works optimally in the cloud, but not outside of it, even with same dependency (apparently ...), is bizarre (of course that's the reason why we are researching). That's mean that there is something out there that is a dependency to Lucid.

Another way to see it is if the authors contrib with scripts that would work outside colab, as to exemplify what type of source code they thing does the job in any environment or .... add more dependencies that now are not visible.

I am really anxious to see this work, because doing Art work with the old original deep dream is pretty tedious, iam having to structure a lot of code in the place of editing-images time. Also, the old deep dream has a lot of gimmick magick such those random tiles and laplacians, slowly i wanna see it understabled and usable by digital artists. I know you guys are author of the old Deep Dream too, so i hope we can work on these together.

Regards.

@segalinc
Copy link
Author

Sorry for the late response I had to work on other stuff. I also took time to run all the colab notebook outside colab and they actually work except for some few parts where I think there are some discrepancies between python2 and python3 (so change few things to adjust) or using svelte as I haven't set that up.
So I wasn't fully able to run the building blocks and activation atlas notebooks because of that but all the other works actually outside on a jupyter notebook. I guess as there are some dependencies on ipython then some of the function may not work if just using regular python environment

the ones that for me don't work and I am interested in are actually the texture synthesis and style 3d.
When I run them and try to visualize the results nothing is shown. I think is a problem with opengl as I get an error when trying to define renderer = glrenderer.MeshRenderer((512, 512)) or trying to visualize show.textured_mesh

@Uiuran
Copy link

Uiuran commented Mar 5, 2020

Can you post your configurations, versions and the versions of dependencies that you are running (i was not able to run nor texture 3D nor the basics). Maybe if i fix my dependencies, and maybe this would be placed as a commit to lucid install setup, than you can be helped with more hands.

@eddiem3
Copy link

eddiem3 commented Nov 20, 2020

Was there ever any resolution on this issue? I can't seem to get Lucid to run the code from the first tutorial outside of the collab

model = models.InceptionV1()
model.load_graphdef()
_ = render.render_vis(model, "mixed4a_pre_relu:476")

gives...

File "/home/emassey3/anaconda3/envs/tf1/lib/python3.7/site-packages/lucid/misc/io/serialize_array.py", line 51, in _normalize_array assert not np.isnan(array).any() AssertionError

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants