InternLM / InternLM-XComposer

InternLM-XComposer-2.5: A Versatile Large Vision Language Model Supporting Long-Contextual Input and Output
Apache License 2.0
2.47k stars 152 forks source link

OSError: [Errno 101] Network is unreachable when doing inference with internlm-xcomposer2.5-7b #360

Closed HuangZhen02 closed 2 months ago

HuangZhen02 commented 3 months ago

when loading the model, it seems that the function get_fond() in ixc_utils.py will be run. However, some errors occurred:

def get_font(): truetype_url = 'https://huggingface.co/internlm/internlm-xcomposer2d5-7b/resolve/main/SimHei.ttf?download=true' ff = urlopen(truetype_url) font = ImageFont.truetype(ff, size=40) return font

<urlopen error [Errno 101] Network is unreachable> OSError: [Errno 101] Network is unreachable

During handling of the above exception, another exception occurred: File "/data/zhuang/huggingface/misc/modules/transformers_modules/internlm-xcomposer2d5-7b/ixc_utils.py", line 13, in get_font ff = urlopen(truetype_url) File "/data/zhuang/huggingface/misc/modules/transformers_modules/internlm-xcomposer2d5-7b/modeling_internlm_xcomposer2.py", line 105, in init self.font = get_font() ......

urllib.error.URLError: <urlopen error [Errno 101] Network is unreachable>

panzhang0212 commented 3 months ago

I can access truetype_url . Can your network access Hugging Face?

resi1ience commented 2 months ago

I can reach huggingface.co but encounter same issue......

ygzhu commented 2 months ago

Download the SimHei.ttf from Hugging Face and set the local path in get_font(). you can refer the code as follow.

def get_font():
    ff = "/Path_of_SimHei/SimHei.ttf"
    font = ImageFont.truetype(ff, size=40)
    return font
resi1ience commented 2 months ago

Download the SimHei.ttf from Hugging Face and set the local path in get_font(). you can refer the code as follow.

def get_font():
    ff = "/Path_of_SimHei/SimHei.ttf"
    font = ImageFont.truetype(ff, size=40)
    return font

Thank you for solution, but I discover that ixc_utils.py would automatically be reset when running the demo, and I'm wonder how to solve it

ygzhu commented 2 months ago

Download the SimHei.ttf from Hugging Face and set the local path in get_font(). you can refer the code as follow.

def get_font():
    ff = "/Path_of_SimHei/SimHei.ttf"
    font = ImageFont.truetype(ff, size=40)
    return font

Thank you for solution, but I discover that ixc_utils.py would automatically be reset when running the demo, and I'm wonder how to solve it

Check the step:

resi1ience commented 2 months ago

Download the SimHei.ttf from Hugging Face and set the local path in get_font(). you can refer the code as follow.

def get_font():
    ff = "/Path_of_SimHei/SimHei.ttf"
    font = ImageFont.truetype(ff, size=40)
    return font

Thank you for solution, but I discover that ixc_utils.py would automatically be reset when running the demo, and I'm wonder how to solve it

Check the step:

  • Step 0 clear the .cache dir
  • Step 1 clone the github repo in your local machine
  • Step 2 clone the Hugging Face in your local machine
  • Step 3 rectify the pretrained model path in example_code.py refer to the path in Step 2(The script in here will be saved in .cache dir)
  • Step 4 download SimHei.ttf and rectify the path in get_font() just run the code, if some model cannot be load from Hugging Face, just follow Step 1 to Step 3, download the model in Hugging Face and rectify the model path in related script, remember to clear the .cache dir

Thank you for solution! It works!

yuhangzang commented 2 months ago

Thanks @ygzhu for providing the solution.