Spaces:
Runtime error
Runtime error
Eugene Siow
commited on
Commit
·
095fbac
1
Parent(s):
6daa8b4
Add fix for output to PIL image.
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import cv2
|
2 |
import torch
|
|
|
3 |
import gradio as gr
|
4 |
from PIL import Image
|
5 |
from super_image import ImageLoader, EdsrModel, MsrnModel, MdsrModel, AwsrnModel, A2nModel, CarnModel, PanModel, \
|
@@ -45,9 +46,8 @@ def inference(img, scale_str, model_name):
|
|
45 |
preds = model(inputs)
|
46 |
preds = preds.data.cpu().numpy()
|
47 |
pred = preds[0].transpose((1, 2, 0)) * 255.0
|
48 |
-
|
49 |
-
|
50 |
-
return Image.fromarray(pred)
|
51 |
|
52 |
|
53 |
torch.hub.download_url_to_file('http://people.rennes.inria.fr/Aline.Roumy/results/images_SR_BMVC12/input_groundtruth/baby_mini_d3_gaussian.bmp',
|
|
|
1 |
import cv2
|
2 |
import torch
|
3 |
+
import numpy as np
|
4 |
import gradio as gr
|
5 |
from PIL import Image
|
6 |
from super_image import ImageLoader, EdsrModel, MsrnModel, MdsrModel, AwsrnModel, A2nModel, CarnModel, PanModel, \
|
|
|
46 |
preds = model(inputs)
|
47 |
preds = preds.data.cpu().numpy()
|
48 |
pred = preds[0].transpose((1, 2, 0)) * 255.0
|
49 |
+
pred = cv2.cvtColor(pred, cv2.COLOR_BGR2RGB)
|
50 |
+
return Image.fromarray((pred * 255).astype(np.uint8))
|
|
|
51 |
|
52 |
|
53 |
torch.hub.download_url_to_file('http://people.rennes.inria.fr/Aline.Roumy/results/images_SR_BMVC12/input_groundtruth/baby_mini_d3_gaussian.bmp',
|