Update app.py
Browse files
app.py
CHANGED
@@ -2,24 +2,44 @@ import gradio as gr
|
|
2 |
from PIL import Image
|
3 |
import numpy as np
|
4 |
|
5 |
-
print("π
|
6 |
|
7 |
def enhance_image(image):
|
8 |
-
"""
|
9 |
if image is None:
|
10 |
-
|
|
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
#
|
18 |
-
|
19 |
-
enhance_image,
|
20 |
-
"
|
21 |
-
"
|
22 |
-
title="ZeroIG Enhancement"
|
|
|
23 |
)
|
24 |
|
25 |
-
interface
|
|
|
|
|
|
|
|
|
|
2 |
from PIL import Image
|
3 |
import numpy as np
|
4 |
|
5 |
+
print("π Starting bulletproof ZeroIG...")
|
6 |
|
7 |
def enhance_image(image):
|
8 |
+
"""Super simple image enhancement"""
|
9 |
if image is None:
|
10 |
+
# Return a simple test image if no input
|
11 |
+
arr = np.zeros((400, 400, 3), dtype=np.uint8)
|
12 |
+
arr.fill(128) # Gray image
|
13 |
+
return Image.fromarray(arr)
|
14 |
|
15 |
+
try:
|
16 |
+
# Convert PIL to numpy
|
17 |
+
arr = np.array(image)
|
18 |
+
|
19 |
+
# Simple brightness boost
|
20 |
+
enhanced = np.clip(arr.astype(np.float32) * 1.5, 0, 255).astype(np.uint8)
|
21 |
+
|
22 |
+
# Convert back to PIL
|
23 |
+
return Image.fromarray(enhanced)
|
24 |
+
|
25 |
+
except Exception as e:
|
26 |
+
print(f"Error in enhance_image: {e}")
|
27 |
+
# Return original image if anything fails
|
28 |
+
return image
|
29 |
+
|
30 |
+
print("Creating interface...")
|
31 |
|
32 |
+
# Ultra simple interface
|
33 |
+
demo = gr.Interface(
|
34 |
+
fn=enhance_image,
|
35 |
+
inputs=gr.Image(type="pil", label="Upload Image"),
|
36 |
+
outputs=gr.Image(type="pil", label="Enhanced Image"),
|
37 |
+
title="ZeroIG Image Enhancement",
|
38 |
+
description="Upload an image to make it brighter!"
|
39 |
)
|
40 |
|
41 |
+
print("Launching interface...")
|
42 |
+
|
43 |
+
# Simple launch without share parameter
|
44 |
+
if __name__ == "__main__":
|
45 |
+
demo.launch()
|