tardis123 commited on
Commit
da34fee
1 Parent(s): 0547ed3

solve <SimSun.ttf> file loading issue

Browse files

the line < if not os.path.exists('SimSun.ttf): > will actually check the path under the running script rather than the model path.

Important Note: i can't test this code because any modification to local file will be overwritten by online version when using <trust_remote_code=True>, and it throws error when i do <trust_remote_code=False> :

ValueError: The repository for /Qwen-VL-Chat contains custom code which must be executed to correctly load the model. You can inspect the repository content at https://hf.co/Qwen-VL-Chat.
Please pass the argument `trust_remote_code=True` to allow custom code to be run.

So this PR is only a suggestion by a tourist who does NOT responsible for this repository, and this PR should be checked before being merged. OR, if I missed sth and made a mistake, I am happy to know it.

Files changed (1) hide show
  1. tokenization_qwen.py +2 -1
tokenization_qwen.py CHANGED
@@ -28,8 +28,9 @@ logger = logging.getLogger(__name__)
28
 
29
  VOCAB_FILES_NAMES = {"vocab_file": "qwen.tiktoken", "ttf": "SimSun.ttf"}
30
  FONT_PATH = try_to_load_from_cache("Qwen/Qwen-VL-Chat", "SimSun.ttf")
 
31
  if FONT_PATH is None:
32
- if not os.path.exists("SimSun.ttf"):
33
  ttf = requests.get("https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/SimSun.ttf")
34
  open("SimSun.ttf", "wb").write(ttf.content)
35
  FONT_PATH = "SimSun.ttf"
 
28
 
29
  VOCAB_FILES_NAMES = {"vocab_file": "qwen.tiktoken", "ttf": "SimSun.ttf"}
30
  FONT_PATH = try_to_load_from_cache("Qwen/Qwen-VL-Chat", "SimSun.ttf")
31
+ ttf_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "SimSun.ttf")
32
  if FONT_PATH is None:
33
+ if not os.path.exists(ttf_path):
34
  ttf = requests.get("https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/SimSun.ttf")
35
  open("SimSun.ttf", "wb").write(ttf.content)
36
  FONT_PATH = "SimSun.ttf"