Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,27 @@
|
|
| 1 |
import os
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
#
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
os.environ["HF_HUB_DISABLE_PROGRESS_BARS"] = "1"
|
| 7 |
-
os.environ["TOKENIZERS_PARALLELISM"]
|
| 8 |
-
|
| 9 |
-
os.environ["HF_HUB_VERBOSITY"] = "error"
|
| 10 |
|
| 11 |
import streamlit as st
|
| 12 |
import numpy as np
|
| 13 |
import re
|
| 14 |
from transformers import AutoModel
|
| 15 |
-
from transformers.dynamic_module_utils import resolve_trust_remote_code # noqa: F401
|
| 16 |
|
| 17 |
-
#
|
| 18 |
try:
|
| 19 |
import transformers.dynamic_module_utils as _dmu
|
| 20 |
_dmu.resolve_trust_remote_code = lambda *a, **kw: True # type: ignore
|
|
|
|
| 1 |
import os
|
| 2 |
+
import builtins
|
| 3 |
+
|
| 4 |
+
# ββ MUST happen before ANY other import βββββββββββββββββββββββββββββββββββββββ
|
| 5 |
+
# transformers calls builtins.input() for the "Do you wish to run the custom
|
| 6 |
+
# code? [y/N]" prompt. Patch it to always answer "y" silently.
|
| 7 |
+
_real_input = builtins.input
|
| 8 |
+
def _auto_yes(prompt=""):
|
| 9 |
+
if "custom code" in str(prompt).lower() or "trust" in str(prompt).lower():
|
| 10 |
+
return "y"
|
| 11 |
+
return _real_input(prompt)
|
| 12 |
+
builtins.input = _auto_yes
|
| 13 |
+
|
| 14 |
+
os.environ["TRUST_REMOTE_CODE"] = "1"
|
| 15 |
os.environ["HF_HUB_DISABLE_PROGRESS_BARS"] = "1"
|
| 16 |
+
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
| 17 |
+
os.environ["HF_HUB_VERBOSITY"] = "error"
|
|
|
|
| 18 |
|
| 19 |
import streamlit as st
|
| 20 |
import numpy as np
|
| 21 |
import re
|
| 22 |
from transformers import AutoModel
|
|
|
|
| 23 |
|
| 24 |
+
# Belt-and-suspenders: patch the internal resolver too, after import
|
| 25 |
try:
|
| 26 |
import transformers.dynamic_module_utils as _dmu
|
| 27 |
_dmu.resolve_trust_remote_code = lambda *a, **kw: True # type: ignore
|