Jimmyzheng-10 commited on
Commit
cec0dbe
·
1 Parent(s): 85d7518
app.py CHANGED
@@ -23,20 +23,20 @@ examples_data = [
23
  "screencoder/data/input/test1.png"
24
  ],
25
  [
26
- "screencoder/data/input/test2.png",
27
  "",
28
  "",
29
  "",
30
  "",
31
- "screencoder/data/input/test2.png"
32
  ],
33
  [
34
- "screencoder/data/input/test3.png",
35
  "",
36
  "",
37
  "",
38
  "",
39
- "screencoder/data/input/test3.png"
40
  ],
41
  ]
42
  example_rows = [row[:5] for row in examples_data]
 
23
  "screencoder/data/input/test1.png"
24
  ],
25
  [
26
+ "screencoder/data/input/test3.png",
27
  "",
28
  "",
29
  "",
30
  "",
31
+ "screencoder/data/input/test3.png"
32
  ],
33
  [
34
+ "screencoder/data/input/draft.png",
35
  "",
36
  "",
37
  "",
38
  "",
39
+ "screencoder/data/input/draft.png"
40
  ],
41
  ]
42
  example_rows = [row[:5] for row in examples_data]
screencoder/data/input/draft.png ADDED

Git LFS Details

  • SHA256: 6d612227d5edab2b43d781a0750815023ceb34fe06734757f589f76de9721e1c
  • Pointer size: 132 Bytes
  • Size of remote file: 1.31 MB
screencoder/image_replacer.py CHANGED
@@ -99,7 +99,7 @@ def main():
99
  soup = BeautifulSoup(html_content, 'html.parser')
100
 
101
  # 1. Find all placeholder elements by their class, in document order.
102
- placeholder_elements = soup.find_all('img', src="placeholder.png")
103
 
104
  # 2. Get the placeholder IDs from the mapping file in the correct, sorted order.
105
  def natural_sort_key(s):
@@ -132,10 +132,18 @@ def main():
132
  # Debug: Print the path being used
133
  print(f"Setting image path for {ph_id}: {relative_img_path}")
134
 
135
- # --- Update the img tag's src attribute ---
136
- # Since we're now working with img tags instead of div tags,
137
- # we just need to update the src attribute
138
- ph_element['src'] = relative_img_path
 
 
 
 
 
 
 
 
139
 
140
  # Save the modified HTML
141
  final_html_path.write_text(str(soup))
 
99
  soup = BeautifulSoup(html_content, 'html.parser')
100
 
101
  # 1. Find all placeholder elements by their class, in document order.
102
+ placeholder_elements = soup.find_all(class_='bg-gray-400')
103
 
104
  # 2. Get the placeholder IDs from the mapping file in the correct, sorted order.
105
  def natural_sort_key(s):
 
132
  # Debug: Print the path being used
133
  print(f"Setting image path for {ph_id}: {relative_img_path}")
134
 
135
+ # --- Convert div with bg-gray-400 class to img tag ---
136
+ # Create a new img element
137
+ new_img = soup.new_tag('img')
138
+ new_img['src'] = relative_img_path
139
+ new_img['class'] = ph_element.get('class', [])
140
+ # Remove bg-gray-400 class and add appropriate image classes
141
+ if 'bg-gray-400' in new_img['class']:
142
+ new_img['class'].remove('bg-gray-400')
143
+ new_img['class'].extend(['w-full', 'h-full', 'object-cover'])
144
+
145
+ # Replace the div element with the new img element
146
+ ph_element.replace_with(new_img)
147
 
148
  # Save the modified HTML
149
  final_html_path.write_text(str(soup))