Spaces:
Build error
Build error
update
Browse files
app.py
CHANGED
|
@@ -176,24 +176,31 @@ def run_chm(
|
|
| 176 |
ax[0].text(*src, str(i), color="white", bbox=dict(facecolor="black", alpha=0.5))
|
| 177 |
ax[1].text(*tgt, str(i), color="black", bbox=dict(facecolor="white", alpha=0.7))
|
| 178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
# Drawing lines between corresponding source and target points
|
| 180 |
-
for src, tgt in zip(src_points_converted, tgt_points_converted):
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
|
|
|
| 191 |
|
| 192 |
# Adding legend
|
| 193 |
-
ax[0].legend()
|
| 194 |
-
ax[1].legend()
|
| 195 |
|
| 196 |
plt.tight_layout()
|
|
|
|
| 197 |
fig.suptitle("CHM Correspondences\nUsing $\it{pas\_psi.pt}$ Weights ", fontsize=16)
|
| 198 |
return fig
|
| 199 |
|
|
@@ -216,40 +223,6 @@ def generate_correspondences(
|
|
| 216 |
)
|
| 217 |
|
| 218 |
|
| 219 |
-
# # Gradio App
|
| 220 |
-
# main = gr.Interface(
|
| 221 |
-
# fn=generate_correspondences,
|
| 222 |
-
# inputs=[
|
| 223 |
-
# gr.Image(shape=(240, 240), type="pil"),
|
| 224 |
-
# gr.Image(shape=(240, 240), type="pil"),
|
| 225 |
-
# gr.Slider(minimum=1, maximum=240, step=1, default=15, label="Min X"),
|
| 226 |
-
# gr.Slider(minimum=1, maximum=240, step=1, default=215, label="Max X"),
|
| 227 |
-
# gr.Slider(minimum=1, maximum=240, step=1, default=15, label="Min Y"),
|
| 228 |
-
# gr.Slider(minimum=1, maximum=240, step=1, default=215, label="Max Y"),
|
| 229 |
-
# ],
|
| 230 |
-
# allow_flagging="never",
|
| 231 |
-
# outputs="plot",
|
| 232 |
-
# examples=[
|
| 233 |
-
# ["./examples/sample1.jpeg", "./examples/sample2.jpeg", 17, 223, 17, 223],
|
| 234 |
-
# [
|
| 235 |
-
# "./examples/Red_Winged_Blackbird_0012_6015.jpg",
|
| 236 |
-
# "./examples/Red_Winged_Blackbird_0025_5342.jpg",
|
| 237 |
-
# 17,
|
| 238 |
-
# 223,
|
| 239 |
-
# 17,
|
| 240 |
-
# 223,
|
| 241 |
-
# ],
|
| 242 |
-
# [
|
| 243 |
-
# "./examples/Yellow_Headed_Blackbird_0026_8545.jpg",
|
| 244 |
-
# "./examples/Yellow_Headed_Blackbird_0020_8549.jpg",
|
| 245 |
-
# 17,
|
| 246 |
-
# 223,
|
| 247 |
-
# 17,
|
| 248 |
-
# 223,
|
| 249 |
-
# ],
|
| 250 |
-
# ],
|
| 251 |
-
# )
|
| 252 |
-
|
| 253 |
with gr.Blocks() as demo:
|
| 254 |
gr.Markdown(
|
| 255 |
"""
|
|
@@ -320,6 +293,22 @@ Performs keypoint transform from a 7x7 gird on the source image to the target im
|
|
| 320 |
gr.Examples(
|
| 321 |
[
|
| 322 |
["./examples/sample1.jpeg", "./examples/sample2.jpeg", 17, 223, 17, 223],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
],
|
| 324 |
inputs=[
|
| 325 |
image1,
|
|
@@ -331,7 +320,6 @@ Performs keypoint transform from a 7x7 gird on the source image to the target im
|
|
| 331 |
],
|
| 332 |
)
|
| 333 |
|
| 334 |
-
# Add a Button component to run the app.
|
| 335 |
run_btn = gr.Button("Run")
|
| 336 |
|
| 337 |
run_btn.click(
|
|
|
|
| 176 |
ax[0].text(*src, str(i), color="white", bbox=dict(facecolor="black", alpha=0.5))
|
| 177 |
ax[1].text(*tgt, str(i), color="black", bbox=dict(facecolor="white", alpha=0.7))
|
| 178 |
|
| 179 |
+
# Create a colormap that will generate 49 distinct colors
|
| 180 |
+
cmap = plt.get_cmap(
|
| 181 |
+
"gist_rainbow", 49
|
| 182 |
+
) # 'gist_rainbow' is just an example, you can choose another colormap
|
| 183 |
+
|
| 184 |
# Drawing lines between corresponding source and target points
|
| 185 |
+
# for i, (src, tgt) in enumerate(zip(src_points_converted, tgt_points_converted)):
|
| 186 |
+
# con = ConnectionPatch(
|
| 187 |
+
# xyA=tgt,
|
| 188 |
+
# xyB=src,
|
| 189 |
+
# coordsA="data",
|
| 190 |
+
# coordsB="data",
|
| 191 |
+
# axesA=ax[1],
|
| 192 |
+
# axesB=ax[0],
|
| 193 |
+
# color=cmap(i),
|
| 194 |
+
# linewidth=2,
|
| 195 |
+
# )
|
| 196 |
+
# ax[1].add_artist(con)
|
| 197 |
|
| 198 |
# Adding legend
|
| 199 |
+
ax[0].legend(loc="lower right", bbox_to_anchor=(1, -0.075))
|
| 200 |
+
ax[1].legend(loc="lower right", bbox_to_anchor=(1, -0.075))
|
| 201 |
|
| 202 |
plt.tight_layout()
|
| 203 |
+
plt.subplots_adjust(wspace=0.1, hspace=0.1)
|
| 204 |
fig.suptitle("CHM Correspondences\nUsing $\it{pas\_psi.pt}$ Weights ", fontsize=16)
|
| 205 |
return fig
|
| 206 |
|
|
|
|
| 223 |
)
|
| 224 |
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
with gr.Blocks() as demo:
|
| 227 |
gr.Markdown(
|
| 228 |
"""
|
|
|
|
| 293 |
gr.Examples(
|
| 294 |
[
|
| 295 |
["./examples/sample1.jpeg", "./examples/sample2.jpeg", 17, 223, 17, 223],
|
| 296 |
+
[
|
| 297 |
+
"./examples/Red_Winged_Blackbird_0012_6015.jpg",
|
| 298 |
+
"./examples/Red_Winged_Blackbird_0025_5342.jpg",
|
| 299 |
+
17,
|
| 300 |
+
223,
|
| 301 |
+
17,
|
| 302 |
+
223,
|
| 303 |
+
],
|
| 304 |
+
[
|
| 305 |
+
"./examples/Yellow_Headed_Blackbird_0026_8545.jpg",
|
| 306 |
+
"./examples/Yellow_Headed_Blackbird_0020_8549.jpg",
|
| 307 |
+
17,
|
| 308 |
+
223,
|
| 309 |
+
17,
|
| 310 |
+
223,
|
| 311 |
+
],
|
| 312 |
],
|
| 313 |
inputs=[
|
| 314 |
image1,
|
|
|
|
| 320 |
],
|
| 321 |
)
|
| 322 |
|
|
|
|
| 323 |
run_btn = gr.Button("Run")
|
| 324 |
|
| 325 |
run_btn.click(
|