Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,25 @@
|
|
| 1 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import glob
|
| 3 |
import time
|
| 4 |
import threading
|
|
|
|
| 1 |
import os
|
| 2 |
+
|
| 3 |
+
# Path to the degradations.py file
|
| 4 |
+
degradations_path = '/usr/local/lib/python3.10/site-packages/basicsr/data/degradations.py'
|
| 5 |
+
|
| 6 |
+
# Check if the file exists
|
| 7 |
+
if os.path.exists(degradations_path):
|
| 8 |
+
with open(degradations_path, 'r') as file:
|
| 9 |
+
content = file.read()
|
| 10 |
+
|
| 11 |
+
# Replace the problematic import
|
| 12 |
+
content = content.replace(
|
| 13 |
+
'from torchvision.transforms.functional_tensor import rgb_to_grayscale',
|
| 14 |
+
'from torchvision.transforms import functional as F\nrgb_to_grayscale = F.rgb_to_grayscale'
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
# Write the modified content back
|
| 18 |
+
with open(degradations_path, 'w') as file:
|
| 19 |
+
file.write(content)
|
| 20 |
+
else:
|
| 21 |
+
print("degradations.py not found!")
|
| 22 |
+
|
| 23 |
import glob
|
| 24 |
import time
|
| 25 |
import threading
|