Spaces:
Sleeping
Sleeping
refactor: Reorder imports and the `spaces` dummy decorator definition to the top of the file.
Browse files
app_hf.py
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoModel, AutoTokenizer, AutoProcessor, AutoModelForImageTextToText
|
| 3 |
import torch
|
|
@@ -8,7 +19,6 @@ import datetime
|
|
| 8 |
import fitz # PyMuPDF
|
| 9 |
import io
|
| 10 |
import gc
|
| 11 |
-
import warnings
|
| 12 |
|
| 13 |
# Suppress annoying warnings
|
| 14 |
warnings.filterwarnings("ignore", message="The parameters have been moved from the Blocks constructor to the launch()")
|
|
@@ -17,15 +27,6 @@ warnings.filterwarnings("ignore", message="The following generation flags are no
|
|
| 17 |
warnings.filterwarnings("ignore", message="The attention mask and the pad token id were not set")
|
| 18 |
warnings.filterwarnings("ignore", message="You are using a model of type .* to instantiate a model of type .*")
|
| 19 |
|
| 20 |
-
# Try to import spaces, if not available (local run), create a dummy decorator
|
| 21 |
-
try:
|
| 22 |
-
import spaces
|
| 23 |
-
except ImportError:
|
| 24 |
-
class spaces:
|
| 25 |
-
@staticmethod
|
| 26 |
-
def GPU(func):
|
| 27 |
-
return func
|
| 28 |
-
|
| 29 |
# --- Configuration ---
|
| 30 |
DEEPSEEK_MODEL = 'deepseek-ai/DeepSeek-OCR-2'
|
| 31 |
MEDGEMMA_MODEL = 'google/medgemma-1.5-4b-it'
|
|
|
|
| 1 |
+
import warnings
|
| 2 |
+
|
| 3 |
+
# Try to import spaces, if not available (local run), create a dummy decorator
|
| 4 |
+
try:
|
| 5 |
+
import spaces
|
| 6 |
+
except ImportError:
|
| 7 |
+
class spaces:
|
| 8 |
+
@staticmethod
|
| 9 |
+
def GPU(func):
|
| 10 |
+
return func
|
| 11 |
+
|
| 12 |
import gradio as gr
|
| 13 |
from transformers import AutoModel, AutoTokenizer, AutoProcessor, AutoModelForImageTextToText
|
| 14 |
import torch
|
|
|
|
| 19 |
import fitz # PyMuPDF
|
| 20 |
import io
|
| 21 |
import gc
|
|
|
|
| 22 |
|
| 23 |
# Suppress annoying warnings
|
| 24 |
warnings.filterwarnings("ignore", message="The parameters have been moved from the Blocks constructor to the launch()")
|
|
|
|
| 27 |
warnings.filterwarnings("ignore", message="The attention mask and the pad token id were not set")
|
| 28 |
warnings.filterwarnings("ignore", message="You are using a model of type .* to instantiate a model of type .*")
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
# --- Configuration ---
|
| 31 |
DEEPSEEK_MODEL = 'deepseek-ai/DeepSeek-OCR-2'
|
| 32 |
MEDGEMMA_MODEL = 'google/medgemma-1.5-4b-it'
|