Update app.py
Browse files
app.py
CHANGED
|
@@ -2244,11 +2244,21 @@ def similarity_matching(sprites_data: dict, project_folder: str, top_k: int = 1,
|
|
| 2244 |
# matched_image_path = paths_list[matched_idx]
|
| 2245 |
# matched_folder = os.path.dirname(matched_image_path)
|
| 2246 |
# matched_filename = os.path.basename(matched_image_path)
|
| 2247 |
-
matched_image_path = paths_list[matched_idx]
|
| 2248 |
-
# Normalize Windows-style backslashes to the platform separator, then normpath
|
| 2249 |
-
matched_image_path = os.path.normpath(str(matched_image_path).replace('\\', os.sep))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2250 |
matched_folder = os.path.dirname(matched_image_path)
|
| 2251 |
matched_filename = os.path.basename(matched_image_path)
|
|
|
|
| 2252 |
try:
|
| 2253 |
# Normalize many forms so we can compare apples-to-apples
|
| 2254 |
mf_abs = os.path.normpath(os.path.abspath(matched_folder))
|
|
|
|
| 2244 |
# matched_image_path = paths_list[matched_idx]
|
| 2245 |
# matched_folder = os.path.dirname(matched_image_path)
|
| 2246 |
# matched_filename = os.path.basename(matched_image_path)
|
| 2247 |
+
# matched_image_path = paths_list[matched_idx]
|
| 2248 |
+
# # Normalize Windows-style backslashes to the platform separator, then normpath
|
| 2249 |
+
# matched_image_path = os.path.normpath(str(matched_image_path).replace('\\', os.sep))
|
| 2250 |
+
# matched_folder = os.path.dirname(matched_image_path)
|
| 2251 |
+
# matched_filename = os.path.basename(matched_image_path)
|
| 2252 |
+
mp = str(matched_image_path).replace('\\', os.sep) # convert Windows backslashes -> platform sep
|
| 2253 |
+
if not os.path.isabs(mp):
|
| 2254 |
+
mp = os.path.normpath(os.path.join(str(BLOCKS_DIR), mp)) # turn relative -> absolute under BLOCKS_DIR
|
| 2255 |
+
else:
|
| 2256 |
+
mp = os.path.normpath(mp) # already absolute: just normalize
|
| 2257 |
+
|
| 2258 |
+
matched_image_path = os.path.abspath(mp) # final absolute path
|
| 2259 |
matched_folder = os.path.dirname(matched_image_path)
|
| 2260 |
matched_filename = os.path.basename(matched_image_path)
|
| 2261 |
+
print("NORM matched_image_path:", matched_image_path, " matched_folder:", matched_folder)
|
| 2262 |
try:
|
| 2263 |
# Normalize many forms so we can compare apples-to-apples
|
| 2264 |
mf_abs = os.path.normpath(os.path.abspath(matched_folder))
|