Clean app.py startup without spaces conflict
Browse files
app.py
CHANGED
|
@@ -17,16 +17,12 @@ from minirewrite.pipeline import MiniRewrite
|
|
| 17 |
|
| 18 |
# Global model instance
|
| 19 |
print("Initializing MiniRewrite model...")
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
MODEL_DIR = ROOT_DIR
|
| 27 |
-
|
| 28 |
-
pipeline = MiniRewrite.from_pretrained(MODEL_DIR, checkpoint_name="best.pt", device="auto")
|
| 29 |
-
print(f"Model loaded on {pipeline.device}!")
|
| 30 |
|
| 31 |
|
| 32 |
def process_rewrite(text: str, task: str, tone: str, style: str):
|
|
|
|
| 17 |
|
| 18 |
# Global model instance
|
| 19 |
print("Initializing MiniRewrite model...")
|
| 20 |
+
MODEL_DIR = ROOT_DIR if (ROOT_DIR / "best.pt").exists() else (ROOT_DIR / "runs" / "rtx4060")
|
| 21 |
+
|
| 22 |
+
# CPU inference is extremely fast (~50ms) for this 7.6M model and requires zero GPU cold-start
|
| 23 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 24 |
+
pipeline = MiniRewrite.from_pretrained(MODEL_DIR, checkpoint_name="best.pt", device=device)
|
| 25 |
+
print(f"Model loaded successfully on {pipeline.device}!")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
def process_rewrite(text: str, task: str, tone: str, style: str):
|