Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,6 @@ import numpy as np
|
|
| 8 |
import streamlit as st
|
| 9 |
import plotly.graph_objects as go
|
| 10 |
from PIL import Image
|
| 11 |
-
from your_pipeline_file import enhancement_pipeline
|
| 12 |
# ---------------------------------------------------------
|
| 13 |
# SAFE HELPER
|
| 14 |
# ---------------------------------------------------------
|
|
@@ -192,5 +191,23 @@ def run_image_enhancement(img_np):
|
|
| 192 |
"parallel_time": 0.0,
|
| 193 |
"speedup": 1.0
|
| 194 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
if __name__ == "__main__":
|
| 196 |
main()
|
|
|
|
| 8 |
import streamlit as st
|
| 9 |
import plotly.graph_objects as go
|
| 10 |
from PIL import Image
|
|
|
|
| 11 |
# ---------------------------------------------------------
|
| 12 |
# SAFE HELPER
|
| 13 |
# ---------------------------------------------------------
|
|
|
|
| 191 |
"parallel_time": 0.0,
|
| 192 |
"speedup": 1.0
|
| 193 |
}
|
| 194 |
+
|
| 195 |
+
def enhancement_pipeline(img, config):
|
| 196 |
+
|
| 197 |
+
img = np.array(img).astype(np.float32)
|
| 198 |
+
|
| 199 |
+
if config.get("gamma_enable", False):
|
| 200 |
+
gamma = config.get("gamma", 1.0)
|
| 201 |
+
img = np.power(img / 255.0, gamma) * 255.0
|
| 202 |
+
|
| 203 |
+
if config.get("clahe_enable", False):
|
| 204 |
+
lab = cv2.cvtColor(img.astype(np.uint8), cv2.COLOR_RGB2LAB)
|
| 205 |
+
l, a, b = cv2.split(lab)
|
| 206 |
+
clahe = cv2.createCLAHE(clipLimit=config.get("clahe_clip", 2.0), tileGridSize=(8,8))
|
| 207 |
+
l = clahe.apply(l)
|
| 208 |
+
img = cv2.merge((l,a,b))
|
| 209 |
+
img = cv2.cvtColor(img, cv2.COLOR_LAB2RGB)
|
| 210 |
+
|
| 211 |
+
return np.clip(img, 0, 255).astype(np.uint8)
|
| 212 |
if __name__ == "__main__":
|
| 213 |
main()
|