Update app.py
Browse files
app.py
CHANGED
|
@@ -2,38 +2,75 @@ import os
|
|
| 2 |
import gradio as gr
|
| 3 |
from zeroscratches import EraseScratches
|
| 4 |
|
|
|
|
| 5 |
os.system("pip freeze")
|
| 6 |
|
| 7 |
-
|
| 8 |
def predict(img):
|
|
|
|
| 9 |
return EraseScratches().erase(img)
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
"""
|
| 28 |
|
|
|
|
| 29 |
demo = gr.Interface(
|
| 30 |
-
predict,
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
demo.queue().launch()
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from zeroscratches import EraseScratches
|
| 4 |
|
| 5 |
+
# ✅ Install dependencies (if not already installed)
|
| 6 |
os.system("pip freeze")
|
| 7 |
|
| 8 |
+
# ✅ Inference function
|
| 9 |
def predict(img):
|
| 10 |
+
""" Apply scratch removal on image """
|
| 11 |
return EraseScratches().erase(img)
|
| 12 |
|
| 13 |
+
# ✅ Custom CSS for clean design
|
| 14 |
+
custom_css = """
|
| 15 |
+
/* Dark theme styling */
|
| 16 |
+
body, .gradio-container {
|
| 17 |
+
background-color: #000000 !important;
|
| 18 |
+
color: white !important;
|
| 19 |
+
}
|
| 20 |
|
| 21 |
+
/* Styling for buttons */
|
| 22 |
+
.gr-button {
|
| 23 |
+
background: #1e90ff !important;
|
| 24 |
+
color: white !important;
|
| 25 |
+
border: none !important;
|
| 26 |
+
padding: 10px 20px !important;
|
| 27 |
+
font-size: 14px !important;
|
| 28 |
+
width: 100% !important;
|
| 29 |
+
cursor: pointer;
|
| 30 |
+
}
|
| 31 |
|
| 32 |
+
/* Hover effect */
|
| 33 |
+
.gr-button:hover {
|
| 34 |
+
background: #0056b3 !important;
|
| 35 |
+
}
|
| 36 |
|
| 37 |
+
/* Styling for output boxes */
|
| 38 |
+
.gr-box, .gr-input, .gr-output {
|
| 39 |
+
background-color: #1c1c1c !important;
|
| 40 |
+
color: white !important;
|
| 41 |
+
border: 1px solid #333333 !important;
|
| 42 |
+
}
|
| 43 |
|
| 44 |
+
/* Hide Gradio footer and header folders */
|
| 45 |
+
footer, header, .gradio-footer, .gradio-header,
|
| 46 |
+
#footer, #header, #description,
|
| 47 |
+
.svelte-1i4i8j8, .svelte-1lcdy9p, .svelte-18k01vx,
|
| 48 |
+
.svelte-1qtpyo7, .svelte-1xjlq5, .svelte-1g01jrn,
|
| 49 |
+
.svelte-1rs4uyx, .gradio-branding,
|
| 50 |
+
#share-btn, #share, #download-btn, #download,
|
| 51 |
+
.gradio-flag, .gradio-screenshot,
|
| 52 |
+
.gradio-tab, .gradio-tabs,
|
| 53 |
+
.gradio-tabs-wrapper,
|
| 54 |
+
.gradio-header__space {
|
| 55 |
+
display: none !important;
|
| 56 |
+
}
|
| 57 |
|
| 58 |
+
/* Make images non-draggable */
|
| 59 |
+
img {
|
| 60 |
+
pointer-events: none !important;
|
| 61 |
+
-webkit-user-drag: none !important;
|
| 62 |
+
user-select: none !important;
|
| 63 |
+
}
|
| 64 |
"""
|
| 65 |
|
| 66 |
+
# ✅ Gradio Interface with Clean UI
|
| 67 |
demo = gr.Interface(
|
| 68 |
+
fn=predict,
|
| 69 |
+
inputs=[gr.Image(type="pil", label="Input")],
|
| 70 |
+
outputs=[gr.Image(type="numpy", label="Restored Image")],
|
| 71 |
+
title="Restore",
|
| 72 |
+
css=custom_css
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
# ✅ Launch Gradio app
|
| 76 |
+
demo.queue().launch(debug=True)
|
|
|