This repository was archived by the owner on May 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 22import sys
33
44if "APP_PATH" in os .environ :
5- os .chdir (os .environ ["APP_PATH" ])
6- # fix sys.path for import
7- sys .path .append (os .getcwd ())
5+ app_path = os .path .abspath (os .environ ["APP_PATH" ])
6+ if os .getcwd () != app_path :
7+ # fix sys.path for import
8+ os .chdir (app_path )
9+ if app_path not in sys .path :
10+ sys .path .append (app_path )
811
912os .environ ["PYTORCH_ENABLE_MPS_FALLBACK" ] = "1" # For some reason, transformers decided to use .isin for a simple op, which is not supported on MPS
1013
@@ -136,9 +139,10 @@ def del_select_coordinates(img, evt: gr.SelectData):
136139
137140 return (img [0 ], sections )
138141
139-
140- model = load_model_cached ()
141- processor = load_processor_cached ()
142+ # Load models if not already loaded in reload mode
143+ if 'model' not in globals ():
144+ model = load_model_cached ()
145+ processor = load_processor_cached ()
142146
143147with gr .Blocks (title = "Texify" ) as demo :
144148 gr .Markdown ("""
@@ -215,4 +219,5 @@ def show_image(file, num=1):
215219 outputs = [markdown_result ]
216220 )
217221
218- demo .launch ()
222+ if __name__ == "__main__" :
223+ demo .launch ()
You can’t perform that action at this time.
0 commit comments