XingangPan / DragGAN

Official Code for DragGAN (SIGGRAPH 2023)
https://vcai.mpi-inf.mpg.de/projects/DragGAN/
Other
35.7k stars 3.45k forks source link

AttributeError: 'FreeTypeFont' object has no attribute 'getsize' #152

Open so349mng opened 1 year ago

so349mng commented 1 year ago

When executing py file, !python /content/DragGAN/visualizer_drag_gradio.py

File under cache_dir (./checkpoints): ['stylegan2_horses_256_pytorch.pkl', 'stylegan2_elephants_512_pytorch.pkl', 'stylegan2-ffhq-512x512.pkl', 'stylegan2_lions_512_pytorch.pkl', 'stylegan2_dogs_1024_pytorch.pkl', 'stylegan2-afhqcat-512x512.pkl', 'stylegan2-cat-config-f.pkl', 'stylegan2-car-config-f.pkl'] Valid checkpoint file: {'stylegan2_horses_256_pytorch': './checkpoints/stylegan2_horses_256_pytorch.pkl', 'stylegan2_elephants_512_pytorch': './checkpoints/stylegan2_elephants_512_pytorch.pkl', 'stylegan2-ffhq-512x512': './checkpoints/stylegan2-ffhq-512x512.pkl', 'stylegan2_lions_512_pytorch': './checkpoints/stylegan2_lions_512_pytorch.pkl', 'stylegan2_dogs_1024_pytorch': './checkpoints/stylegan2_dogs_1024_pytorch.pkl', 'stylegan2-afhqcat-512x512': './checkpoints/stylegan2-afhqcat-512x512.pkl', 'stylegan2-cat-config-f': './checkpoints/stylegan2-cat-config-f.pkl', 'stylegan2-car-config-f': './checkpoints/stylegan2-car-config-f.pkl'} Loading "./checkpoints/stylegan2_lions_512_pytorch.pkl"... Done. () {'z_dim': 512, 'c_dim': 0, 'w_dim': 512, 'img_resolution': 512, 'img_channels': 3, 'mapping_kwargs': {'num_layers': 8, 'embed_features': None, 'layer_features': None, 'activation': 'lrelu', 'lr_multiplier': 0.01, 'w_avg_beta': 0.995}, 'synthesis_kwargs': {'channel_base': 32768, 'channel_max': 512, 'num_fp16_res': 0, 'conv_clamp': None, 'architecture': 'skip', 'resample_filter': [1, 3, 3, 1], 'use_noise': True, 'activation': 'lrelu'}} Setting up PyTorch plugin "bias_act_plugin"... Done. Setting up PyTorch plugin "upfirdn2d_plugin"... Done.

Traceback (most recent call last): File "/content/DragGAN/visualizer_drag_gradio.py", line 205, in global_state = init_images(global_state) File "/content/DragGAN/visualizer_drag_gradio.py", line 96, in init_images add_watermark_np(np.array(init_image))) File "/content/DragGAN/viz/renderer.py", line 56, in add_watermark_np text_width, text_height = font.getsize(watermark_text) AttributeError: 'FreeTypeFont' object has no attribute 'getsize'

ghost commented 1 year ago

You can nasty-fix it by replacing on line 56 in viz.renderer:

text_width, text_height = [0,0]
cobanov commented 1 year ago

Solved on this PR #239

radames commented 1 year ago

hi @cobanov you can pin Pillow==9.5.0, it seems to be an issue with the newest Pillow==10.0.0

so349mng commented 1 year ago

Thank for all your guys. It works. !!!

[image: 截屏2023-07-16 14.47.44.png]

Radamés Ajna @.***> 于2023年7月4日周二 23:43写道:

hi @cobanov https://github.com/cobanov you can pin Pillow==9.5.0, it seems to be an issue with the newest Pillow==10.0.0

— Reply to this email directly, view it on GitHub https://github.com/XingangPan/DragGAN/issues/152#issuecomment-1620467278, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYLZNWUJFA5Q2DHOEZONVNTXOQ22NANCNFSM6AAAAAAZ3QKZYQ . You are receiving this because you authored the thread.Message ID: @.***>