Code Monkey home page Code Monkey logo

fast_neural_style_transfer's Issues

Unable to produce example results

Hi, thanks for such fast model, I have tried your code and followed steps. So, initially I am getting this error:

TypeError: Cannot handle this data type: (1, 1, 3), <f4

Traceback (most recent call last): File "F:\ai\deep\fast_neural_style_transfer-dev\main.py", line 71, in <module> main() File "F:\ai\deep\fast_neural_style_transfer-dev\main.py", line 64, in main generated_images = generate(content_targets, model_path, save_path=output_save_path, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ai\deep\fast_neural_style_transfer-dev\generate.py", line 23, in generate outputs = _handler2(contents_path, model_path, save_path=save_path, prefix=prefix, suffix=suffix) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "F:\ai\deep\fast_neural_style_transfer-dev\generate.py", line 72, in _handler2 save_images(content_path, output, save_path, prefix=prefix, suffix=suffix) File "F:\ai\deep\fast_neural_style_transfer-dev\utils.py", line 61, in save_images imsave(path, data) File "C:\Users\Najm Abideen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\imageio\v2.py", line 397, in imwrite return file.write(im, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Najm Abideen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\imageio\plugins\pillow.py", line 425, in write pil_frame = Image.fromarray(frame, mode=mode) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Najm Abideen\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\PIL\Image.py", line 3073, in fromarray raise TypeError(msg) from e TypeError: Cannot handle this data type: (1, 1, 3), <f4

I skipped the error and tried to show the result using:
plt.imshow(result[0], interpolation='nearest')
plt.show()

but generated result[0] is an empty image, I have seen very little generated noise on following styles:

'wave': [1.0, 7.0, 1e-2], #-

'scream': [1.0, 60.0, 1e-2], #-

'rain_princess': [1.0, 8.0, 1e-2], #-

image

Actually, I have tried all of your pre trained 10 models.
Have also placed the weights file, "imagenet-vgg-verydeep-19.mat" & "imagenet-vgg-19-weights.npz".

I finally was able to save the image using:

if save_path is not None:
    for i, image in enumerate(output):
        # Convert image to the appropriate data type and scale it to 0-255
        image_scaled = (image * 255).astype(np.uint8)
        # Save the image using imageio
        filename = f"{prefix}_{i}_{suffix}.png" if prefix and suffix else f"image_{i}.png"
        imageio.imwrite(f"{save_path}/{filename}", image_scaled)
    #save_images(content_path, output_converted, save_path, prefix=prefix, suffix=suffix)

but images are simply nothing but noise:
image

Kindly help really appreciate, I don't know why I found this code so late :)

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.