prthm11 commited on
Commit
3d99439
·
verified ·
1 Parent(s): 110cdec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -2391,7 +2391,7 @@ def extract_images_from_pdf(pdf_stream: io.BytesIO):
2391
  raise RuntimeError(f"❌ Error in extract_images_from_pdf: {str(e)}")
2392
 
2393
  # def similarity_matching(input_json_path: str, project_folder: str) -> str:
2394
- def similarity_matching(sprites_data: str, project_folder: str) -> str:
2395
  """
2396
  Finds the best matching assets for input sprites using a FAISS index and builds a Scratch project.
2397
 
@@ -2412,10 +2412,15 @@ def similarity_matching(sprites_data: str, project_folder: str) -> str:
2412
  # 1. PREPARE INPUT SPRITE IMAGES FROM BASE64 DATA #
2413
  # ==================================================== #
2414
  # The input is a JSON string, so we first need to parse it.
2415
- sprites_data_dict = json.loads(sprites_data)
 
 
 
2416
 
2417
  pil_images = []
2418
- for sid, sprite in sprites_data_dict.items():
 
 
2419
  base64_string = sprite["base64"]
2420
  # Decode the base64 string to bytes, then open as a PIL Image
2421
  image_data = base64.b64decode(base64_string.split(',')[-1])
 
2391
  raise RuntimeError(f"❌ Error in extract_images_from_pdf: {str(e)}")
2392
 
2393
  # def similarity_matching(input_json_path: str, project_folder: str) -> str:
2394
+ def similarity_matching(sprites_data: dict, project_folder: str) -> str:
2395
  """
2396
  Finds the best matching assets for input sprites using a FAISS index and builds a Scratch project.
2397
 
 
2412
  # 1. PREPARE INPUT SPRITE IMAGES FROM BASE64 DATA #
2413
  # ==================================================== #
2414
  # The input is a JSON string, so we first need to parse it.
2415
+ #sprites_data_dict = json.loads(sprites_data)
2416
+
2417
+ # ...
2418
+ # The 'sprites_data' variable is already a dictionary.
2419
 
2420
  pil_images = []
2421
+ # Use sprites_data directly
2422
+ for sid, sprite in sprites_data.items():
2423
+ #for sid, sprite in sprites_data_dict.items():
2424
  base64_string = sprite["base64"]
2425
  # Decode the base64 string to bytes, then open as a PIL Image
2426
  image_data = base64.b64decode(base64_string.split(',')[-1])