Prajwal-r-k commited on
Commit
e837f85
·
verified ·
1 Parent(s): e9300a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -3,7 +3,6 @@ import os
3
  import subprocess
4
  import torch
5
  from PIL import Image
6
- import numpy as np
7
 
8
  UPLOAD_FOLDER = 'uploads'
9
  OUTPUT_FOLDER = 'outputs'
@@ -36,7 +35,12 @@ def gradio_interface(image):
36
  if result.returncode != 0:
37
  return f"Error: {result.stderr}"
38
 
39
- return Image.open(output_path)
 
 
 
 
 
40
 
41
  except Exception as e:
42
  return f"Exception: {str(e)}"
@@ -49,4 +53,4 @@ iface = gr.Interface(
49
  title="Image Restoration with NAFNet"
50
  )
51
 
52
- iface.launch() # Removed share=True
 
3
  import subprocess
4
  import torch
5
  from PIL import Image
 
6
 
7
  UPLOAD_FOLDER = 'uploads'
8
  OUTPUT_FOLDER = 'outputs'
 
35
  if result.returncode != 0:
36
  return f"Error: {result.stderr}"
37
 
38
+ # Check if output image was created
39
+ if not os.path.exists(output_path):
40
+ return "Error: Output image not generated."
41
+
42
+ # Explicitly reload the image
43
+ return Image.open(output_path).copy()
44
 
45
  except Exception as e:
46
  return f"Exception: {str(e)}"
 
53
  title="Image Restoration with NAFNet"
54
  )
55
 
56
+ iface.launch()