Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -112,42 +112,25 @@ def detect_manipulation(image):
|
|
| 112 |
|
| 113 |
return result_image
|
| 114 |
|
| 115 |
-
# Custom CSS
|
| 116 |
custom_css = """
|
| 117 |
-
#component-0 {
|
| 118 |
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 119 |
-
padding: 20px;
|
| 120 |
-
}
|
| 121 |
-
|
| 122 |
-
.gradio-container {
|
| 123 |
-
max-width: 1200px !important;
|
| 124 |
-
margin: auto !important;
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
#title {
|
| 128 |
text-align: center;
|
| 129 |
-
|
| 130 |
-
font-
|
| 131 |
-
margin-bottom:
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
| 133 |
}
|
| 134 |
-
|
| 135 |
#subtitle {
|
| 136 |
text-align: center;
|
| 137 |
-
color: white;
|
| 138 |
font-size: 1.2em;
|
| 139 |
-
|
| 140 |
-
|
| 141 |
}
|
| 142 |
-
|
| 143 |
-
.main-card {
|
| 144 |
-
background: white;
|
| 145 |
-
border-radius: 20px;
|
| 146 |
-
padding: 40px;
|
| 147 |
-
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
| 148 |
-
}
|
| 149 |
-
|
| 150 |
-
#info-box {
|
| 151 |
background: #e8f4fd;
|
| 152 |
border-left: 4px solid #2196F3;
|
| 153 |
padding: 15px;
|
|
@@ -155,81 +138,26 @@ custom_css = """
|
|
| 155 |
margin-bottom: 20px;
|
| 156 |
color: #1976D2;
|
| 157 |
}
|
| 158 |
-
|
| 159 |
-
.upload-container .transition {
|
| 160 |
-
border: 3px dashed #667eea !important;
|
| 161 |
-
border-radius: 15px !important;
|
| 162 |
-
background: #f8f9ff !important;
|
| 163 |
-
}
|
| 164 |
-
|
| 165 |
-
.upload-container .transition:hover {
|
| 166 |
-
border-color: #764ba2 !important;
|
| 167 |
-
background: #f0f2ff !important;
|
| 168 |
-
}
|
| 169 |
-
|
| 170 |
-
button.primary {
|
| 171 |
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
| 172 |
-
border: none !important;
|
| 173 |
-
color: white !important;
|
| 174 |
-
border-radius: 25px !important;
|
| 175 |
-
padding: 12px 30px !important;
|
| 176 |
-
font-size: 1em !important;
|
| 177 |
-
}
|
| 178 |
-
|
| 179 |
-
button.primary:hover {
|
| 180 |
-
transform: translateY(-2px);
|
| 181 |
-
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4) !important;
|
| 182 |
-
}
|
| 183 |
-
|
| 184 |
-
.output-image {
|
| 185 |
-
border-radius: 15px;
|
| 186 |
-
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
| 187 |
-
}
|
| 188 |
"""
|
| 189 |
|
| 190 |
-
# Create
|
| 191 |
-
with gr.Blocks(css=custom_css,
|
| 192 |
-
gr.HTML(""
|
| 193 |
-
|
| 194 |
-
<div id="subtitle">ReliAble iDentification of inpainted AReas</div>
|
| 195 |
-
""")
|
| 196 |
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
<
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
type="pil",
|
| 211 |
-
elem_classes="upload-container"
|
| 212 |
-
)
|
| 213 |
-
submit_btn = gr.Button("🔍 Detect Manipulations", variant="primary", size="lg")
|
| 214 |
-
|
| 215 |
-
with gr.Column():
|
| 216 |
-
output_image = gr.Image(
|
| 217 |
-
label="Manipulation Heatmap",
|
| 218 |
-
type="pil",
|
| 219 |
-
elem_classes="output-image"
|
| 220 |
-
)
|
| 221 |
-
|
| 222 |
-
gr.Examples(
|
| 223 |
-
examples=[
|
| 224 |
-
# Add paths to your example images here
|
| 225 |
-
# ["examples/example1.png"],
|
| 226 |
-
# ["examples/example2.png"],
|
| 227 |
-
],
|
| 228 |
-
inputs=input_image,
|
| 229 |
-
outputs=output_image,
|
| 230 |
-
fn=detect_manipulation,
|
| 231 |
-
cache_examples=False,
|
| 232 |
-
)
|
| 233 |
|
| 234 |
# Connect the button
|
| 235 |
submit_btn.click(
|
|
|
|
| 112 |
|
| 113 |
return result_image
|
| 114 |
|
| 115 |
+
# Custom CSS for styling
|
| 116 |
custom_css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
#title {
|
| 118 |
text-align: center;
|
| 119 |
+
font-size: 2.5em;
|
| 120 |
+
font-weight: bold;
|
| 121 |
+
margin-bottom: 0.5em;
|
| 122 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 123 |
+
-webkit-background-clip: text;
|
| 124 |
+
-webkit-text-fill-color: transparent;
|
| 125 |
+
background-clip: text;
|
| 126 |
}
|
|
|
|
| 127 |
#subtitle {
|
| 128 |
text-align: center;
|
|
|
|
| 129 |
font-size: 1.2em;
|
| 130 |
+
color: #666;
|
| 131 |
+
margin-bottom: 1em;
|
| 132 |
}
|
| 133 |
+
#info {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
background: #e8f4fd;
|
| 135 |
border-left: 4px solid #2196F3;
|
| 136 |
padding: 15px;
|
|
|
|
| 138 |
margin-bottom: 20px;
|
| 139 |
color: #1976D2;
|
| 140 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
"""
|
| 142 |
|
| 143 |
+
# Create simple interface
|
| 144 |
+
with gr.Blocks(css=custom_css, title="RADAR - Image Manipulation Detection") as demo:
|
| 145 |
+
gr.HTML('<h1 id="title">🎯 RADAR</h1>')
|
| 146 |
+
gr.HTML('<p id="subtitle">ReliAble iDentification of inpainted AReas</p>')
|
|
|
|
|
|
|
| 147 |
|
| 148 |
+
gr.HTML('''
|
| 149 |
+
<div id="info">
|
| 150 |
+
<strong>ℹ️ About RADAR:</strong> Upload an image to detect and localize regions
|
| 151 |
+
that have been manipulated using diffusion-based inpainting models.
|
| 152 |
+
The output shows a heatmap where red areas indicate detected manipulations.
|
| 153 |
+
</div>
|
| 154 |
+
''')
|
| 155 |
+
|
| 156 |
+
with gr.Row():
|
| 157 |
+
input_image = gr.Image(label="Upload Image", type="pil")
|
| 158 |
+
output_image = gr.Image(label="Manipulation Heatmap", type="pil")
|
| 159 |
+
|
| 160 |
+
submit_btn = gr.Button("🔍 Detect Manipulations", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
# Connect the button
|
| 163 |
submit_btn.click(
|