Giter Site home page Giter Site logo

Comments (6)

adrelino avatar adrelino commented on June 18, 2024 1

I found out that labels is actually unused and just filled with 0, so can be ignore.

In my fork, I refactored the code a bit so that visualize_expressions now also returns the output of the pre-trained network in addition to the groundtruth. Can be found here:

https://github.com/adrelino/CSGNet/blob/master/visualize_expressions.py

from csgnet.

Hippogriff avatar Hippogriff commented on June 18, 2024

You can look at the test_synthetic.py file for testing the model. You can also also use visualize_expressions.py script to visualize the induced programs in the form of images.

from csgnet.

7675t avatar 7675t commented on June 18, 2024

Thank you, it much helps to visualize the test results. I can close this issue. Also see my PR.

Can you consider to append a simple command which just apply the network to specified single image, visualize the predicted image and CSG expression? I think it is very helpful to know the concept of your work out of the box.

Thanks,

from csgnet.

Hippogriff avatar Hippogriff commented on June 18, 2024

Thank you for the PR but it doesn't seem necessary, because visualize_expressions.py can be used by the user by slight modification.

Can you consider to append a simple command which just apply the network to specified single image, visualize the predicted image and CSG expression? I think it is very helpful to know the concept of your work out of the box.

I will add a small script.

from csgnet.

adrelino avatar adrelino commented on June 18, 2024

I still cannot find the script that just takes a 64x64 binary image (and the provided pre-trained model) as input and outputs a program code (that generates a similar looking image based on camfer or iou distance) for that image.

visualize_expressions.py just takes an expression and generates the ground-truth 64x64 image.

test_synthetic.py takes the pre-trained model and also the whole synthetic data-set expressions, somehow selects a validation subset and computes the mean chamfer distance metric over all program sizes. I guess that from this file, such a script that just takes an image and outputs the program could be extracted, but I am a little confused about these steps:

CSGNet/test_synthetic.py

Lines 104 to 120 in 34e9621

data_, labels = next(test_gen_objs[k])
one_hot_labels = prepare_input_op(labels,
len(generator.unique_draw))
one_hot_labels = Variable(torch.from_numpy(one_hot_labels)).cuda()
data = Variable(torch.from_numpy(data_), volatile=True).cuda()
labels = Variable(torch.from_numpy(labels)).cuda()
test_output = imitate_net.test([data, one_hot_labels, max_len])
pred_images, correct_prog, pred_prog = parser.get_final_canvas(
test_output,
if_just_expressions=False,
if_pred_images=True)
target_images = data_[-1, :, 0, :, :].astype(dtype=bool)
targ_prog = parser.labels2exps(labels, k)
programs_tar[jit] += targ_prog
programs_pred[jit] += pred_prog
distance = chamfer(target_images, pred_images)

When running inference, we should not need ground-truth labels, but then why do we need to extract one-hot-labels from the ground truth labels before feeding it to test_output = imitate_net.test([data, one_hot_labels, max_len])?
How would I proceed if instead of using the generator data_, labels = next(test_gen_objs[k]), I just input my own image (batch), let's say a logo for which I don't even have ground truth labels?

Thanks for your help!

from csgnet.

Hippogriff avatar Hippogriff commented on June 18, 2024

@adrelino Thanx for the script. The labels are unused in test mode.

from csgnet.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.