Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ import json
|
|
| 3 |
import ast
|
| 4 |
import re
|
| 5 |
from io import BytesIO
|
|
|
|
|
|
|
| 6 |
|
| 7 |
import torch
|
| 8 |
import torchvision.transforms as T
|
|
@@ -10,6 +12,15 @@ from PIL import Image
|
|
| 10 |
from torchvision.transforms.functional import InterpolationMode
|
| 11 |
from fastapi import FastAPI, HTTPException
|
| 12 |
from pydantic import BaseModel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
from transformers import AutoModel, AutoTokenizer
|
| 14 |
|
| 15 |
|
|
|
|
| 3 |
import ast
|
| 4 |
import re
|
| 5 |
from io import BytesIO
|
| 6 |
+
import types
|
| 7 |
+
import sys
|
| 8 |
|
| 9 |
import torch
|
| 10 |
import torchvision.transforms as T
|
|
|
|
| 12 |
from torchvision.transforms.functional import InterpolationMode
|
| 13 |
from fastapi import FastAPI, HTTPException
|
| 14 |
from pydantic import BaseModel
|
| 15 |
+
|
| 16 |
+
# Stub bitsandbytes to avoid GPU driver checks in CPU-only environments
|
| 17 |
+
fake_bnb = types.ModuleType("bitsandbytes")
|
| 18 |
+
def _bnb_unavailable(*args, **kwargs):
|
| 19 |
+
raise ImportError("bitsandbytes is not available in this CPU-only deployment")
|
| 20 |
+
fake_bnb.__all__ = ["_bnb_unavailable"]
|
| 21 |
+
fake_bnb._bnb_unavailable = _bnb_unavailable
|
| 22 |
+
sys.modules["bitsandbytes"] = fake_bnb
|
| 23 |
+
|
| 24 |
from transformers import AutoModel, AutoTokenizer
|
| 25 |
|
| 26 |
|