Jimmyzheng-10 commited on
Commit
95b965e
·
1 Parent(s): 2e6b21d

Back to 'bg-gray-400' version

screencoder/html_generator.py CHANGED
@@ -41,7 +41,7 @@ def get_prompt_dict(instructions):
41
  # only return the code within the <div> and </div> tags""",
42
  # }
43
  return {
44
- "sidebar": f"""这是一个container的截图。这是用户给的额外要求:{instructions["sidebar"]}请填写一段完整的HTML和tail-wind CSS代码以准确再现给定的容器。请注意所有组块的排版、图标样式、大小、文字信息需要在用户额外条件的基础上与原始截图基本保持一致。请保持图标一致,如果是大块图像,请使用"placeholder.png"替换,注意代码中的大小和位置信息。以下是供填写的代码:
45
 
46
  <div>
47
  your code here
@@ -49,7 +49,7 @@ def get_prompt_dict(instructions):
49
 
50
  只需返回<div>和</div>标签内的代码""",
51
 
52
- "header": f"""这是一个container的截图。这是用户给的额外要求:{instructions["header"]}请填写一段完整的HTML和tail-wind CSS代码以准确再现给定的容器。请注意所有组块在boundary box中的相对位置、排版、文字信息、颜色需要在用户额外条件的基础上与原始截图基本保持一致。以下是供填写的代码:
53
 
54
  <div>
55
  your code here
@@ -57,7 +57,7 @@ def get_prompt_dict(instructions):
57
 
58
  只需返回<div>和</div>标签内的代码""",
59
 
60
- "navigation": f"""这是一个container的截图。这是用户给的额外要求:{instructions["navigation"]}请填写一段完整的HTML和tail-wind CSS代码以准确再现给定的容器。请注意所有组块的在boundary box中的相对位置、文字排版、颜色需要在用户额外条件的基础上与原始截图基本保持一致。图像请你直接使用原始截图中一致的图标。以下是供填写的代码:
61
 
62
  <div>
63
  your code here
@@ -65,7 +65,7 @@ def get_prompt_dict(instructions):
65
 
66
  只需返回<div>和</div>标签内的代码""",
67
 
68
- "main content": f"""这是一个container的截图。这是用户给的额外要求:{instructions["main content"]}请填写一段完整的HTML和tail-wind CSS代码以准确再现给定的容器。截图中显示的图像务必使用"placeholder.png"替换,注意代码中其大小和位置信息,不需要识别其中的文字信息。请注意所有组块在boundary box中的相对位置、排版、文字信息、颜色需要在用户额外条件的基础上与原始截图基本保持一致。以下是供填写的代码:
69
 
70
  <div>
71
  your code here
 
41
  # only return the code within the <div> and </div> tags""",
42
  # }
43
  return {
44
+ "sidebar": f"""这是一个container的截图。这是用户给的额外要求:{instructions["sidebar"]}请填写一段完整的HTML和tail-wind CSS代码以准确再现给定的容器。请注意所有组块的排版、图标样式、大小、文字信息需要在用户额外条件的基础上与原始截图基本保持一致。请保持生成的svg图标和原图一致。请使用相同大小、位置的纯灰色图像块并标记为"bg-gray-400"代替图片,注意代码中的大小和位置信息。以下是供填写的代码:
45
 
46
  <div>
47
  your code here
 
49
 
50
  只需返回<div>和</div>标签内的代码""",
51
 
52
+ "header": f"""这是一个container的截图。这是用户给的额外要求:{instructions["header"]}请填写一段完整的HTML和tail-wind CSS代码以准确再现给定的容器。请注意所有组块在boundary box中的相对位置、排版、文字信息、颜色需要在用户额外条件的基础上与原始截图基本保持一致。请保持生成的svg图标和原图一致。请使用相同大小、位置的纯灰色图像块并标记为"bg-gray-400"代替图片,注意代码中的大小和位置信息。以下是供填写的代码:
53
 
54
  <div>
55
  your code here
 
57
 
58
  只需返回<div>和</div>标签内的代码""",
59
 
60
+ "navigation": f"""这是一个container的截图。这是用户给的额外要求:{instructions["navigation"]}请填写一段完整的HTML和tail-wind CSS代码以准确再现给定的容器。请注意所有组块的在boundary box中的相对位置、文字排版、颜色需要在用户额外条件的基础上与原始截图基本保持一致。图像请你直接使用原始截图中一致的图标。请使用相同大小、位置的纯灰色图像块并标记为"bg-gray-400"代替图片,注意代码中的大小和位置信息。以下是供填写的代码:
61
 
62
  <div>
63
  your code here
 
65
 
66
  只需返回<div>和</div>标签内的代码""",
67
 
68
+ "main content": f"""这是一个container的截图。这是用户给的额外要求:{instructions["main content"]}请填写一段完整的HTML和tail-wind CSS代码以准确再现给定的容器。截图中显示的图像请使用相同大小、位置的纯灰色图像块并标记为"bg-gray-400"代替图片,注意代码中其大小和位置信息,不需要识别其中的文字信息。请注意所有组块在boundary box中的相对位置、排版、文字信息、颜色需要在用户额外条件的基础上与原始截图基本保持一致。以下是供填写的代码:
69
 
70
  <div>
71
  your code here
screencoder/image_box_detection.py CHANGED
@@ -59,13 +59,13 @@ def extract_bboxes_from_html_fallback(html_path: Path):
59
 
60
  # Extract placeholder bboxes
61
  placeholder_bboxes = []
62
- placeholder_images = soup.find_all('img', src='placeholder.png')
63
  for i, img in enumerate(placeholder_images):
64
  # For fallback, we'll use a simple approach
65
  # In a real scenario, you'd need to parse the actual layout
66
  placeholder_bboxes.append({
67
  'id': f'ph{i}',
68
- 'x': 100 + i * 50, # Simple positioning
69
  'y': 100 + i * 50,
70
  'w': 100,
71
  'h': 100,
@@ -121,7 +121,7 @@ async def extract_bboxes_from_html(html_path: Path):
121
 
122
  const placeholder_bboxes = [];
123
  let ph_id_counter = 0;
124
- const all_potential_placeholders = document.querySelectorAll('img[src="placeholder.png"]');
125
 
126
  for (const el of all_potential_placeholders) {
127
  // Apply the same filters as before
 
59
 
60
  # Extract placeholder bboxes
61
  placeholder_bboxes = []
62
+ placeholder_images = soup.find_all(class_='bg-gray-400')
63
  for i, img in enumerate(placeholder_images):
64
  # For fallback, we'll use a simple approach
65
  # In a real scenario, you'd need to parse the actual layout
66
  placeholder_bboxes.append({
67
  'id': f'ph{i}',
68
+ 'x': 100 + i * 50,
69
  'y': 100 + i * 50,
70
  'w': 100,
71
  'h': 100,
 
121
 
122
  const placeholder_bboxes = [];
123
  let ph_id_counter = 0;
124
+ const all_potential_placeholders = document.querySelectorAll('.bg-gray-400');
125
 
126
  for (const el of all_potential_placeholders) {
127
  // Apply the same filters as before