Spaces:
Runtime error
Runtime error
Synced repo using 'sync_with_huggingface' Github Action
Browse files- gradio_app.py +12 -7
gradio_app.py
CHANGED
|
@@ -2,9 +2,12 @@ import os
|
|
| 2 |
import sys
|
| 3 |
|
| 4 |
if "APP_PATH" in os.environ:
|
| 5 |
-
os.
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1" # For some reason, transformers decided to use .isin for a simple op, which is not supported on MPS
|
| 10 |
|
|
@@ -136,9 +139,10 @@ def del_select_coordinates(img, evt: gr.SelectData):
|
|
| 136 |
|
| 137 |
return (img[0], sections)
|
| 138 |
|
| 139 |
-
|
| 140 |
-
model
|
| 141 |
-
|
|
|
|
| 142 |
|
| 143 |
with gr.Blocks(title="Texify") as demo:
|
| 144 |
gr.Markdown("""
|
|
@@ -215,4 +219,5 @@ with gr.Blocks(title="Texify") as demo:
|
|
| 215 |
outputs=[markdown_result]
|
| 216 |
)
|
| 217 |
|
| 218 |
-
|
|
|
|
|
|
| 2 |
import sys
|
| 3 |
|
| 4 |
if "APP_PATH" in os.environ:
|
| 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)
|
| 11 |
|
| 12 |
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1" # For some reason, transformers decided to use .isin for a simple op, which is not supported on MPS
|
| 13 |
|
|
|
|
| 139 |
|
| 140 |
return (img[0], sections)
|
| 141 |
|
| 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()
|
| 146 |
|
| 147 |
with gr.Blocks(title="Texify") as demo:
|
| 148 |
gr.Markdown("""
|
|
|
|
| 219 |
outputs=[markdown_result]
|
| 220 |
)
|
| 221 |
|
| 222 |
+
if __name__ == "__main__":
|
| 223 |
+
demo.launch()
|