Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ import spaces
|
|
| 3 |
import torch
|
| 4 |
from PIL import Image
|
| 5 |
from RealESRGAN import RealESRGAN
|
|
|
|
|
|
|
| 6 |
|
| 7 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 8 |
model2 = RealESRGAN(device, scale=2)
|
|
@@ -15,6 +17,7 @@ model8.load_weights('weights/RealESRGAN_x8.pth', download=True)
|
|
| 15 |
|
| 16 |
@spaces.GPU(duration=14)
|
| 17 |
def inference(image, size):
|
|
|
|
| 18 |
global model2
|
| 19 |
global model4
|
| 20 |
global model8
|
|
@@ -50,7 +53,7 @@ def inference(image, size):
|
|
| 50 |
model8.load_weights('weights/RealESRGAN_x8.pth', download=False)
|
| 51 |
result = model2.predict(image.convert('RGB'))
|
| 52 |
|
| 53 |
-
print(f"Image size ({device}): {size} ... OK")
|
| 54 |
return result
|
| 55 |
|
| 56 |
|
|
@@ -73,4 +76,4 @@ gr.Interface(inference,
|
|
| 73 |
flagging_mode="never",
|
| 74 |
cache_mode="lazy",
|
| 75 |
delete_cache=(44000, 44000),
|
| 76 |
-
).queue(api_open=True).launch(show_error=True, show_api=True, mcp_server=True)
|
|
|
|
| 3 |
import torch
|
| 4 |
from PIL import Image
|
| 5 |
from RealESRGAN import RealESRGAN
|
| 6 |
+
import time
|
| 7 |
+
from datetime import timedelta as td
|
| 8 |
|
| 9 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 10 |
model2 = RealESRGAN(device, scale=2)
|
|
|
|
| 17 |
|
| 18 |
@spaces.GPU(duration=14)
|
| 19 |
def inference(image, size):
|
| 20 |
+
start_load = time.time()
|
| 21 |
global model2
|
| 22 |
global model4
|
| 23 |
global model8
|
|
|
|
| 53 |
model8.load_weights('weights/RealESRGAN_x8.pth', download=False)
|
| 54 |
result = model2.predict(image.convert('RGB'))
|
| 55 |
|
| 56 |
+
print(f"Image size ({device}): {size}, time: {datetime.datetime.now()} ... OK")
|
| 57 |
return result
|
| 58 |
|
| 59 |
|
|
|
|
| 76 |
flagging_mode="never",
|
| 77 |
cache_mode="lazy",
|
| 78 |
delete_cache=(44000, 44000),
|
| 79 |
+
).queue(api_open=True).launch(show_error=True, show_api=True, mcp_server=True)
|