xiaoyao9184 commited on
Commit
371e8f6
·
verified ·
1 Parent(s): 463dc9d

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (2) hide show
  1. app.py +3 -1
  2. gradio_app.py +7 -1
app.py CHANGED
@@ -36,7 +36,9 @@ install_model()
36
  print(f"LOCAL_PATH: {os.path.abspath(LOCAL_PATH)}")
37
  os.environ["APP_PATH"] = os.path.abspath(LOCAL_PATH)
38
 
39
- # run gradio
 
 
40
  import re
41
  import sys
42
  from gradio.cli import cli
 
36
  print(f"LOCAL_PATH: {os.path.abspath(LOCAL_PATH)}")
37
  os.environ["APP_PATH"] = os.path.abspath(LOCAL_PATH)
38
 
39
+ # run gradio in subprocess in reloaded mode
40
+ # huggingface space issue: https://github.com/gradio-app/gradio/issues/10048
41
+ # need disable reload for huggingface space
42
  import re
43
  import sys
44
  from gradio.cli import cli
gradio_app.py CHANGED
@@ -5,10 +5,16 @@ if "APP_PATH" in os.environ:
5
  os.chdir(os.environ["APP_PATH"])
6
  if os.getcwd() not in sys.path:
7
  sys.path.append(os.getcwd())
8
-
9
  # remove duplicate gradio_app path from sys.path
10
  sys.path = list(dict.fromkeys(sys.path))
11
 
 
 
 
 
 
 
12
  # here the subprocess stops loading, because __name__ is NOT '__main__'
13
  # gradio will reload
14
  if '__main__' == __name__:
 
5
  os.chdir(os.environ["APP_PATH"])
6
  if os.getcwd() not in sys.path:
7
  sys.path.append(os.getcwd())
8
+
9
  # remove duplicate gradio_app path from sys.path
10
  sys.path = list(dict.fromkeys(sys.path))
11
 
12
+ # remove gradio reload env if in huggingface space
13
+ if "SPACE_ID" in os.environ:
14
+ for key in ["GRADIO_WATCH_DIRS", "GRADIO_WATCH_MODULE_NAME", "GRADIO_WATCH_DEMO_NAME", "GRADIO_WATCH_DEMO_PATH"]:
15
+ if key in os.environ:
16
+ del os.environ[key]
17
+
18
  # here the subprocess stops loading, because __name__ is NOT '__main__'
19
  # gradio will reload
20
  if '__main__' == __name__: