Spaces:
Running
on
Zero
Running
on
Zero
added versions to requirements and adjusted startup to be more efficient
Browse files- app.py +13 -22
- requirements.txt +11 -11
- tests/conftest.py +0 -12
app.py
CHANGED
|
@@ -28,30 +28,21 @@ model_3n_id = os.getenv("MODEL_3N_ID", "google/gemma-3n-E4B-it")
|
|
| 28 |
MAX_VIDEO_SIZE = 100 * 1024 * 1024 # 100 MB
|
| 29 |
MAX_IMAGE_SIZE = 10 * 1024 * 1024 # 10 MB
|
| 30 |
|
| 31 |
-
|
| 32 |
-
SKIP_MODEL_LOADING = os.getenv("SKIP_MODEL_LOADING", "false").lower() == "true"
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
device_map="auto",
|
| 41 |
-
attn_implementation="eager",
|
| 42 |
-
)
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
else:
|
| 51 |
-
# Mock objects for testing
|
| 52 |
-
input_processor = None
|
| 53 |
-
model_12 = None
|
| 54 |
-
model_3n = None
|
| 55 |
|
| 56 |
|
| 57 |
def check_file_size(file_path: str) -> bool:
|
|
|
|
| 28 |
MAX_VIDEO_SIZE = 100 * 1024 * 1024 # 100 MB
|
| 29 |
MAX_IMAGE_SIZE = 10 * 1024 * 1024 # 10 MB
|
| 30 |
|
| 31 |
+
input_processor = Gemma3Processor.from_pretrained(model_12_id)
|
|
|
|
| 32 |
|
| 33 |
+
model_12 = Gemma3ForConditionalGeneration.from_pretrained(
|
| 34 |
+
model_12_id,
|
| 35 |
+
torch_dtype=torch.bfloat16,
|
| 36 |
+
device_map="auto",
|
| 37 |
+
attn_implementation="eager",
|
| 38 |
+
)
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
model_3n = Gemma3nForConditionalGeneration.from_pretrained(
|
| 41 |
+
model_3n_id,
|
| 42 |
+
torch_dtype=torch.bfloat16,
|
| 43 |
+
device_map="auto",
|
| 44 |
+
attn_implementation="eager",
|
| 45 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
|
| 48 |
def check_file_size(file_path: str) -> bool:
|
requirements.txt
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
-
torch
|
| 2 |
-
spaces
|
| 3 |
-
gradio
|
| 4 |
-
transformers
|
| 5 |
-
accelerate
|
| 6 |
-
pytest
|
| 7 |
-
loguru
|
| 8 |
-
python-dotenv
|
| 9 |
-
opencv-python
|
| 10 |
-
timm
|
| 11 |
-
pymupdf
|
|
|
|
| 1 |
+
torch==2.6.0+cu126
|
| 2 |
+
spaces==0.40.0
|
| 3 |
+
gradio==5.42.0
|
| 4 |
+
transformers==4.55.2
|
| 5 |
+
accelerate==1.10.0
|
| 6 |
+
pytest==8.4.1
|
| 7 |
+
loguru==0.7.3
|
| 8 |
+
python-dotenv==1.1.1
|
| 9 |
+
opencv-python==4.12.0.88
|
| 10 |
+
timm==1.0.19
|
| 11 |
+
pymupdf==1.26.3
|
tests/conftest.py
DELETED
|
@@ -1,12 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import pytest
|
| 3 |
-
|
| 4 |
-
# Set environment variable before any imports
|
| 5 |
-
os.environ["SKIP_MODEL_LOADING"] = "true"
|
| 6 |
-
|
| 7 |
-
@pytest.fixture(autouse=True)
|
| 8 |
-
def skip_model_loading():
|
| 9 |
-
"""Automatically set environment variable to skip model loading for all tests."""
|
| 10 |
-
# Environment variable is already set above
|
| 11 |
-
yield
|
| 12 |
-
# Keep the variable set for the entire test session
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|