Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ from PIL import Image
|
|
| 3 |
from RealESRGAN import RealESRGAN
|
| 4 |
import gradio as gr
|
| 5 |
import os
|
|
|
|
| 6 |
|
| 7 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 8 |
model2 = RealESRGAN(device, scale=2)
|
|
@@ -58,6 +59,13 @@ def inference_image(image, size):
|
|
| 58 |
|
| 59 |
|
| 60 |
def inference_video(video, size):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
os.system("python inference_video.py")
|
| 62 |
return os.path.join('/tmp/results_mp4_videos/', 'input.mp4')
|
| 63 |
|
|
|
|
| 3 |
from RealESRGAN import RealESRGAN
|
| 4 |
import gradio as gr
|
| 5 |
import os
|
| 6 |
+
from random import randint
|
| 7 |
|
| 8 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 9 |
model2 = RealESRGAN(device, scale=2)
|
|
|
|
| 59 |
|
| 60 |
|
| 61 |
def inference_video(video, size):
|
| 62 |
+
_id = randint(1, 10000)
|
| 63 |
+
INPUT_DIR = "/tmp/" + str(_id) + "/"
|
| 64 |
+
os.system("rm -rf " + INPUT_DIR)
|
| 65 |
+
os.system("mkdir " + INPUT_DIR)
|
| 66 |
+
input_image_path = os.path.join(INPUT_DIR, 'input.jpg')
|
| 67 |
+
video.save(input_image_path)
|
| 68 |
+
video.save(INPUT_DIR + "input.mp4", "MP4")
|
| 69 |
os.system("python inference_video.py")
|
| 70 |
return os.path.join('/tmp/results_mp4_videos/', 'input.mp4')
|
| 71 |
|