Spaces:
Running on Zero
Running on Zero
Upload folder using huggingface_hub
Browse files- app.py +12 -0
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -92,12 +92,24 @@ def load_image_from_pil(pil_image):
|
|
| 92 |
|
| 93 |
# --- Load model at module scope (ZeroGPU pattern) ---------------------------
|
| 94 |
print("Loading model...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
model = AutoModel.from_pretrained(
|
| 96 |
MODEL_ID,
|
| 97 |
torch_dtype=torch.bfloat16,
|
| 98 |
trust_remote_code=True,
|
| 99 |
).eval().to("cuda")
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 102 |
MODEL_ID,
|
| 103 |
trust_remote_code=True,
|
|
|
|
| 92 |
|
| 93 |
# --- Load model at module scope (ZeroGPU pattern) ---------------------------
|
| 94 |
print("Loading model...")
|
| 95 |
+
|
| 96 |
+
# transformers 5.x expects `all_tied_weights_keys` on PreTrainedModel subclasses.
|
| 97 |
+
# The custom InternVLChatModel (written for transformers 4.x) doesn't call post_init()
|
| 98 |
+
# which is where transformers 5.x sets this attribute. Add a default so loading works.
|
| 99 |
+
import transformers.modeling_utils as _mu
|
| 100 |
+
if 'all_tied_weights_keys' not in _mu.PreTrainedModel.__dict__:
|
| 101 |
+
_mu.PreTrainedModel.all_tied_weights_keys = {}
|
| 102 |
+
|
| 103 |
model = AutoModel.from_pretrained(
|
| 104 |
MODEL_ID,
|
| 105 |
torch_dtype=torch.bfloat16,
|
| 106 |
trust_remote_code=True,
|
| 107 |
).eval().to("cuda")
|
| 108 |
|
| 109 |
+
# Ensure the attribute exists on the loaded model instance (custom code may skip post_init)
|
| 110 |
+
if not hasattr(model, 'all_tied_weights_keys') or not isinstance(getattr(model, 'all_tied_weights_keys', None), dict):
|
| 111 |
+
model.all_tied_weights_keys = {}
|
| 112 |
+
|
| 113 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 114 |
MODEL_ID,
|
| 115 |
trust_remote_code=True,
|
requirements.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
torchvision
|
| 2 |
einops
|
| 3 |
timm
|
| 4 |
-
transformers
|
| 5 |
https://huggingface.co/datasets/multimodalart/zerogpu-blackwell-wheels/resolve/main/wheels/pt212-cu130-cp310/flash_attn-2.8.3-cp310-cp310-linux_x86_64.whl
|
|
|
|
| 1 |
torchvision
|
| 2 |
einops
|
| 3 |
timm
|
| 4 |
+
transformers
|
| 5 |
https://huggingface.co/datasets/multimodalart/zerogpu-blackwell-wheels/resolve/main/wheels/pt212-cu130-cp310/flash_attn-2.8.3-cp310-cp310-linux_x86_64.whl
|