FastStyle icon indicating copy to clipboard operation
FastStyle copied to clipboard

How to load pretrained models?

Open vonum opened this issue 4 years ago • 2 comments

How are we supposed to use the pretrained models linked in the docs? https://drive.google.com/drive/folders/1-ywa__KcK4uEEYOzgfeRCpCzP3RJKBwL

The main.py evaluate works only with the weights.index file of any model, but those weights are not good, you get noise basically. Loading any other weight leads to:

python main.py evaluate    \
  --weights weights/aquarelle/weights.data-00001-of-00002 \
  --content images/content/stata.jpg \
  --result images/results/result.jpg

Results in:

2021-09-12 20:12:00.189751: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open weights/aquarelle/weights.data-00001-of-00002: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
Traceback (most recent call last):
  File "main.py", line 119, in <module>
    main()
  File "main.py", line 111, in main
    transfer(**parameters)
  File "/home/vonum/code/ml/FastStyle/evaluate.py", line 14, in transfer
    network.load_weights(weights).expect_partial()
  File "/home/vonum/Envs/fast-style/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py", line 2348, in load_weights
    with h5py.File(filepath, 'r') as f:
  File "/home/vonum/Envs/fast-style/lib/python3.8/site-packages/h5py/_hl/files.py", line 424, in __init__
    fid = make_fid(name, mode, userblock_size,
  File "/home/vonum/Envs/fast-style/lib/python3.8/site-packages/h5py/_hl/files.py", line 190, in make_fid
    fid = h5f.open(name, flags, fapl=fapl)
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5f.pyx", line 96, in h5py.h5f.open
OSError: Unable to open file (file signature not found)

vonum avatar Sep 12 '21 18:09 vonum

python main.py evaluate \ --weights ./weights/aquarelle \ --content ./path/to/content/image.jpg(video.mp4) \ --result ./path/to/save/results/image.jpg

Index file should read all the data from weights folder . Basically depend on the image you select if it is a 4k one don't expect to get good results on pretrained models.

KlausStortebeker avatar Sep 16 '21 09:09 KlausStortebeker

I download the pretrained weight. when I evaluate this model with the command: python main.py evaluate --weights ./weights/aquarelle/weights --content ./images/content/chicago.jpg --result ./images/results/Result.jpg but it leads to tensorflow.python.framework.errors_impl.OpError what should i do??

masteroneright avatar Apr 15 '22 01:04 masteroneright