Ayesha352 commited on
Commit
dec9b10
·
verified ·
1 Parent(s): 2f5bf5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -22
app.py CHANGED
@@ -122,30 +122,38 @@ def homography_all_detectors(flat_file, persp_file, json_file):
122
  gallery_images.append((result_rgb, f"{method} Result"))
123
  download_files.append(file_name)
124
 
125
- # return gallery + 5 download files (pad with None if less)
126
  while len(download_files) < 5:
127
  download_files.append(None)
128
 
129
- return [gallery_images] + download_files[:5]
130
 
131
  # ---------------- Gradio UI ----------------
132
- iface = gr.Interface(
133
- fn=homography_all_detectors,
134
- inputs=[
135
- gr.File(label="Upload Flat Image", file_types=[".jpg",".png",".jpeg"]),
136
- gr.File(label="Upload Perspective Image", file_types=[".jpg",".png",".jpeg"]),
137
- gr.File(label="Upload mockup.json", file_types=[".json"])
138
- ],
139
- outputs=[
140
- gr.Gallery(label="Results (per Detector)", show_label=True),
141
- gr.File(label="Download SIFT Result"),
142
- gr.File(label="Download ORB Result"),
143
- gr.File(label="Download BRISK Result"),
144
- gr.File(label="Download KAZE Result"),
145
- gr.File(label="Download AKAZE Result")
146
- ],
147
- title="Homography ROI Projection with Multiple Feature Detectors",
148
- description="Upload flat & perspective images with mockup.json. The system will project ROI using SIFT, ORB, BRISK, KAZE, and AKAZE. Each result can be viewed and downloaded."
149
- )
150
-
151
- iface.launch()
 
 
 
 
 
 
 
 
 
122
  gallery_images.append((result_rgb, f"{method} Result"))
123
  download_files.append(file_name)
124
 
125
+ # pad download files list to 5
126
  while len(download_files) < 5:
127
  download_files.append(None)
128
 
129
+ return flat_img[:, :, ::-1], persp_img[:, :, ::-1], [gallery_images] + download_files[:5]
130
 
131
  # ---------------- Gradio UI ----------------
132
+ with gr.Blocks() as demo:
133
+ gr.Markdown("## Homography ROI Projection with Multiple Feature Detectors")
134
+
135
+ with gr.Row():
136
+ flat_input = gr.File(label="Upload Flat Image", file_types=[".jpg",".png",".jpeg"])
137
+ persp_input = gr.File(label="Upload Perspective Image", file_types=[".jpg",".png",".jpeg"])
138
+ json_input = gr.File(label="Upload mockup.json", file_types=[".json"])
139
+
140
+ with gr.Row():
141
+ flat_preview = gr.Image(label="Flat Image Preview")
142
+ persp_preview = gr.Image(label="Perspective Image Preview")
143
+
144
+ output_gallery = gr.Gallery(label="Detector Results", show_label=True, columns=2, height=400)
145
+
146
+ download_sift = gr.File(label="Download SIFT Result")
147
+ download_orb = gr.File(label="Download ORB Result")
148
+ download_brisk = gr.File(label="Download BRISK Result")
149
+ download_kaze = gr.File(label="Download KAZE Result")
150
+ download_akaze = gr.File(label="Download AKAZE Result")
151
+
152
+ run_btn = gr.Button("Run Homography")
153
+ run_btn.click(
154
+ fn=homography_all_detectors,
155
+ inputs=[flat_input, persp_input, json_input],
156
+ outputs=[flat_preview, persp_preview, output_gallery, download_sift, download_orb, download_brisk, download_kaze, download_akaze]
157
+ )
158
+
159
+ demo.launch()