MiyamizuMitsuha
commited on
Commit
•
33db9ac
1
Parent(s):
de8ab08
Update app
Browse files
app.py
CHANGED
@@ -85,6 +85,21 @@ def load_image(image_file, input_size=448, max_num=12):
|
|
85 |
pixel_values = torch.stack(pixel_values)
|
86 |
return pixel_values
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
model_name = "YuukiAsuna/Vintern-1B-v2-ViTable-docvqa"
|
90 |
|
|
|
85 |
pixel_values = torch.stack(pixel_values)
|
86 |
return pixel_values
|
87 |
|
88 |
+
# Save the original cuda() method
|
89 |
+
original_cuda = torch.Tensor.cuda
|
90 |
+
|
91 |
+
# Define a new cuda() method
|
92 |
+
def safe_cuda(self, *args, **kwargs):
|
93 |
+
if torch.cuda.is_available():
|
94 |
+
return original_cuda(self, *args, **kwargs) # Use the original cuda() method
|
95 |
+
else:
|
96 |
+
return self # Return the tensor itself (stays on CPU)
|
97 |
+
|
98 |
+
# Monkey-patch the cuda() method
|
99 |
+
torch.Tensor.cuda = safe_cuda
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
|
104 |
model_name = "YuukiAsuna/Vintern-1B-v2-ViTable-docvqa"
|
105 |
|