Spaces:
Running on Zero
Running on Zero
Upload folder using huggingface_hub
Browse files- app.py +5 -9
- config.json +1 -1
- model.safetensors +1 -1
app.py
CHANGED
|
@@ -28,15 +28,12 @@ except ImportError:
|
|
| 28 |
return fn
|
| 29 |
|
| 30 |
MODEL_PATH = Path(__file__).resolve().parent / "model_scripted.pt"
|
| 31 |
-
MODEL = None
|
| 32 |
|
| 33 |
|
| 34 |
-
def
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
MODEL.eval()
|
| 39 |
-
return MODEL
|
| 40 |
|
| 41 |
|
| 42 |
MAX_SIDE = 4096
|
|
@@ -59,9 +56,8 @@ def upscale(image, scale: float = 4.0, target_long_side: float = 0.0):
|
|
| 59 |
shrink = MAX_SIDE / float(max(out_w, out_h))
|
| 60 |
out_w, out_h = max(1, int(out_w * shrink)), max(1, int(out_h * shrink))
|
| 61 |
|
| 62 |
-
model = get_model()
|
| 63 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 64 |
-
model
|
| 65 |
|
| 66 |
lr = torch.from_numpy(np.asarray(img, dtype=np.float32) / 255.0).permute(2, 0, 1).contiguous().unsqueeze(0).to(device)
|
| 67 |
with torch.no_grad():
|
|
|
|
| 28 |
return fn
|
| 29 |
|
| 30 |
MODEL_PATH = Path(__file__).resolve().parent / "model_scripted.pt"
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
+
def load_model(device: str):
|
| 34 |
+
model = torch.jit.load(str(MODEL_PATH), map_location=device)
|
| 35 |
+
model.eval()
|
| 36 |
+
return model
|
|
|
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
MAX_SIDE = 4096
|
|
|
|
| 56 |
shrink = MAX_SIDE / float(max(out_w, out_h))
|
| 57 |
out_w, out_h = max(1, int(out_w * shrink)), max(1, int(out_h * shrink))
|
| 58 |
|
|
|
|
| 59 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 60 |
+
model = load_model(device)
|
| 61 |
|
| 62 |
lr = torch.from_numpy(np.asarray(img, dtype=np.float32) / 255.0).permute(2, 0, 1).contiguous().unsqueeze(0).to(device)
|
| 63 |
with torch.no_grad():
|
config.json
CHANGED
|
@@ -49,7 +49,7 @@
|
|
| 49 |
},
|
| 50 |
"export": {
|
| 51 |
"torch_version": "2.14.1+cu130",
|
| 52 |
-
"exported_at": "2026-10-23T14:
|
| 53 |
"method": "torch.jit.script + torch.jit.freeze",
|
| 54 |
"verification": {
|
| 55 |
"checks": [
|
|
|
|
| 49 |
},
|
| 50 |
"export": {
|
| 51 |
"torch_version": "2.14.1+cu130",
|
| 52 |
+
"exported_at": "2026-10-23T14:46:57+00:00",
|
| 53 |
"method": "torch.jit.script + torch.jit.freeze",
|
| 54 |
"verification": {
|
| 55 |
"checks": [
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 5054380
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d5f0b33a4448f4c936d26f05df6f2421566343b4f1abb0701582d8a200b94d4b
|
| 3 |
size 5054380
|