ashen-sensored / sd_webui_gligen

83 stars 7 forks source link

cannot open resource error #2

Open BaiterYamato opened 1 year ago

BaiterYamato commented 1 year ago

this error appears when i try to draw anything in the canvas, idk why

  File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 337, in run_predict
    output = await app.get_blocks().process_api(
  File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1015, in process_api
    result = await self.call_function(
  File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 833, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "C:\StableDiffusion\stable-diffusion-webui\extensions\sd_webui_gligen\scripts\gligen_ui.py", line 209, in draw
    box_image = draw_box(state['boxes'], grounding_texts, image, width, height)
  File "C:\StableDiffusion\stable-diffusion-webui\extensions\sd_webui_gligen\scripts\gligen_ui.py", line 119, in draw_box
    font = ImageFont.truetype(font_path, size=18)
  File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\PIL\ImageFont.py", line 1008, in truetype
    return freetype(font)
  File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\PIL\ImageFont.py", line 1005, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\PIL\ImageFont.py", line 255, in __init__
    self.font = core.getfont(
OSError: cannot open resource
jkawamoto commented 1 year ago

I got the same error.

I needed to download DejaVuSans.ttf from https://www.1001fonts.com/dejavu-sans-font.html and put it in stable-diffusion-webui\venv\Lib\site-packages\cv2\qt\fonts\.

BaiterYamato commented 1 year ago

worked, thx!

xueqing0622 commented 1 year ago

same error, but after I put DejaVuSans.ttf to \venv\Lib\site-packages\cv2\qt\fonts\ still not work, Even installing DejaVuSans.ttf font in my computer and restarting the computer, and try in 4 different web browser , still not work.

jkawamoto commented 1 year ago

How about adding print(font_path) after this line?

https://github.com/ashen-sensored/sd_webui_gligen/blob/7d0d8a066c3d4b24fedf272c4f45bc3d21ec1f8f/scripts/gligen_ui.py#L118

It'll print where DejaVuSans.ttf should be located.

xueqing0622 commented 1 year ago

jkawamoto, it work , thanks a lot, you are the master better than ChatGPT My ppath is \python\lib\site-packages\cv2\qt\fonts\DejaVuSans.ttf