Update app.py
Browse files
app.py
CHANGED
|
@@ -83,7 +83,7 @@ JPEG_QUALITY = 80
|
|
| 83 |
GPU_MEMORY_FRACTION = 0.8
|
| 84 |
|
| 85 |
# --- 1. Device ---
|
| 86 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 87 |
torch.backends.cudnn.benchmark = True
|
| 88 |
if device.type == 'cuda':
|
| 89 |
torch.cuda.set_per_process_memory_fraction(GPU_MEMORY_FRACTION, device=0)
|
|
@@ -180,6 +180,7 @@ def handle_file(file, prompt, extra_prompt, max_new_tokens, progress=gr.Progress
|
|
| 180 |
# --- 3. Inference Function ---
|
| 181 |
@spaces.GPU
|
| 182 |
def run_inference(img: Image.Image, prompt: str = "", max_new_tokens: int = 512) -> str:
|
|
|
|
| 183 |
if img.mode != "RGB":
|
| 184 |
img = img.convert("RGB")
|
| 185 |
prompt_text = prompt.strip()
|
|
|
|
| 83 |
GPU_MEMORY_FRACTION = 0.8
|
| 84 |
|
| 85 |
# --- 1. Device ---
|
| 86 |
+
device = torch.device("cpu") #torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 87 |
torch.backends.cudnn.benchmark = True
|
| 88 |
if device.type == 'cuda':
|
| 89 |
torch.cuda.set_per_process_memory_fraction(GPU_MEMORY_FRACTION, device=0)
|
|
|
|
| 180 |
# --- 3. Inference Function ---
|
| 181 |
@spaces.GPU
|
| 182 |
def run_inference(img: Image.Image, prompt: str = "", max_new_tokens: int = 512) -> str:
|
| 183 |
+
model.to("cuda")
|
| 184 |
if img.mode != "RGB":
|
| 185 |
img = img.convert("RGB")
|
| 186 |
prompt_text = prompt.strip()
|