LPX
commited on
Commit
·
64eb1c4
1
Parent(s):
a7d5234
☸ feat(preprocessing): add ELA image generation presets
Browse files- added ability to generate ELA images with different presets for comparison
- updated UI to display multiple ELA images in a gallery
🎉Performance: change_ELA_image_generator_script
- modified ELA preprocessing step
- replace single ELA image generation by presets
app.py
CHANGED
@@ -222,15 +222,23 @@ def generate_results_html(results):
|
|
222 |
"""
|
223 |
return html_content
|
224 |
|
|
|
225 |
def predict_image_with_html(img, confidence_threshold, augment_methods, rotate_degrees, noise_level, sharpen_strength):
|
226 |
if augment_methods:
|
227 |
img_pil, _ = augment_image(img, augment_methods, rotate_degrees, noise_level, sharpen_strength)
|
228 |
else:
|
229 |
img_pil = img
|
230 |
img_pil, results = predict_image(img_pil, confidence_threshold)
|
231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
html_content = generate_results_html(results)
|
233 |
-
return img_pil,
|
234 |
|
235 |
with gr.Blocks() as iface:
|
236 |
with gr.Tab("AI Image Detection"):
|
@@ -248,7 +256,7 @@ with gr.Blocks() as iface:
|
|
248 |
inputs = [image_input, confidence_slider, augment_checkboxgroup, rotate_slider, noise_slider, sharpen_slider]
|
249 |
predict_button = gr.Button("Predict")
|
250 |
image_output = gr.Image(label="Processed Image", visible=True)
|
251 |
-
|
252 |
|
253 |
|
254 |
with gr.Column(scale=2):
|
@@ -256,7 +264,7 @@ with gr.Blocks() as iface:
|
|
256 |
gr.Markdown("## OpenSight is a SOTA gen. image detection model, in pre-release prep.\n\nThis HF Space is a temporary home for us and the public to evaluate the shortcomings of current open source models.\n\n<-- Feel free to play around by starting with an image as we prepare our formal announcement.")
|
257 |
# Custom HTML component to display results in 5 columns
|
258 |
results_html = gr.HTML(label="Model Predictions")
|
259 |
-
outputs = [image_output,
|
260 |
|
261 |
# Show/hide rotate slider based on selected augmentation method
|
262 |
augment_checkboxgroup.change(lambda methods: gr.update(visible="rotate" in methods), inputs=[augment_checkboxgroup], outputs=[rotate_slider])
|
|
|
222 |
"""
|
223 |
return html_content
|
224 |
|
225 |
+
|
226 |
def predict_image_with_html(img, confidence_threshold, augment_methods, rotate_degrees, noise_level, sharpen_strength):
|
227 |
if augment_methods:
|
228 |
img_pil, _ = augment_image(img, augment_methods, rotate_degrees, noise_level, sharpen_strength)
|
229 |
else:
|
230 |
img_pil = img
|
231 |
img_pil, results = predict_image(img_pil, confidence_threshold)
|
232 |
+
|
233 |
+
# Generate ELA images with different presets
|
234 |
+
ela_img_1 = ELA(img_pil, scale=77, alpha=0.66)
|
235 |
+
ela_img_2 = ELA(img_pil, scale=100, alpha=0.8)
|
236 |
+
ela_img_3 = ELA(img_pil, scale=50, alpha=0.5)
|
237 |
+
|
238 |
+
ela_images = [ela_img_1, ela_img_2, ela_img_3]
|
239 |
+
|
240 |
html_content = generate_results_html(results)
|
241 |
+
return img_pil, ela_images, html_content
|
242 |
|
243 |
with gr.Blocks() as iface:
|
244 |
with gr.Tab("AI Image Detection"):
|
|
|
256 |
inputs = [image_input, confidence_slider, augment_checkboxgroup, rotate_slider, noise_slider, sharpen_slider]
|
257 |
predict_button = gr.Button("Predict")
|
258 |
image_output = gr.Image(label="Processed Image", visible=True)
|
259 |
+
ela_gallery = gr.Gallery(label="ELA Processed Images", visible=True)
|
260 |
|
261 |
|
262 |
with gr.Column(scale=2):
|
|
|
264 |
gr.Markdown("## OpenSight is a SOTA gen. image detection model, in pre-release prep.\n\nThis HF Space is a temporary home for us and the public to evaluate the shortcomings of current open source models.\n\n<-- Feel free to play around by starting with an image as we prepare our formal announcement.")
|
265 |
# Custom HTML component to display results in 5 columns
|
266 |
results_html = gr.HTML(label="Model Predictions")
|
267 |
+
outputs = [image_output, ela_gallery, results_html]
|
268 |
|
269 |
# Show/hide rotate slider based on selected augmentation method
|
270 |
augment_checkboxgroup.change(lambda methods: gr.update(visible="rotate" in methods), inputs=[augment_checkboxgroup], outputs=[rotate_slider])
|