Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
from realesrgan import RealESRGAN
|
5 |
+
from PIL import Image
|
6 |
+
import torch
|
7 |
+
|
8 |
+
# Load model (langsung ke GPU jika tersedia)
|
9 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
10 |
+
model = RealESRGAN(device, scale=2)
|
11 |
+
model.load_weights('weights/RealESRGAN_x2.pth') # nanti download dari huggingface atau official
|
12 |
+
|
13 |
+
def enhance_image(input_image):
|
14 |
+
output_image = model.predict(input_image)
|
15 |
+
return output_image
|
16 |
+
|
17 |
+
# Launch API
|
18 |
+
gr.Interface(fn=enhance_image, inputs=gr.Image(), outputs=gr.Image()).launch()
|