Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image, ImageDraw
|
3 |
+
|
4 |
+
def detect_discrepancies(original, cnc_output):
|
5 |
+
# If no original image is provided, simply return None.
|
6 |
+
if original is None:
|
7 |
+
return None
|
8 |
+
|
9 |
+
# Create a copy of the original image for the output.
|
10 |
+
img = original.copy()
|
11 |
+
draw = ImageDraw.Draw(img)
|
12 |
+
|
13 |
+
# Overlay text indicating discrepancy detection.
|
14 |
+
text = "Discrepancy Detected"
|
15 |
+
draw.text((10, 10), text, fill=(255, 0, 0))
|
16 |
+
|
17 |
+
return img
|
18 |
+
|
19 |
+
interface = gr.Interface(
|
20 |
+
fn=detect_discrepancies,
|
21 |
+
inputs=[
|
22 |
+
gr.Image(label="Original Image", type="pil"),
|
23 |
+
gr.Image(label="CNC Plotted Image", type="pil")
|
24 |
+
],
|
25 |
+
outputs=gr.Image(label="Discrepancy Visualization"),
|
26 |
+
title="CNC Discrepancy Detector",
|
27 |
+
description="Upload the original input image and the corresponding CNC plotted image to view the discrepancy visualization."
|
28 |
+
)
|
29 |
+
|
30 |
+
if __name__ == '__main__':
|
31 |
+
interface.launch()
|