def generate_slides_html(image_paths, image_ids, desc1, desc2, desc3, output_file='gallery_with_descriptions.html'): # Start of HTML content html_content = ''' Image Gallery ''' with open(output_file, 'w', encoding='utf-8') as f: f.write(html_content) print(f"Gallery with three model outputs has been generated as {output_file}") def generate_rating_html(image_paths, image_ids, desc1, desc2, desc3, desc4, desc5, output_file='gallery_with_ratings.html'): # Start of HTML content with linebreaks html_content = ''' Image Gallery with Ratings
''' # Create JavaScript arrays for each piece of data js_image_paths = [] js_image_ids = [] js_desc1 = [] js_desc2 = [] js_desc3 = [] js_desc4 = [] js_desc5 = [] for i in range(len(image_paths)): js_image_paths.append(f'"{image_paths[i]}"') js_image_ids.append(f'"{image_ids[i]}"') # Process descriptions to properly handle line breaks - replace \n with
for HTML rendering desc1_html = desc1[i].replace('"', '\\"').replace('\n', '
') desc2_html = desc2[i].replace('"', '\\"').replace('\n', '
') desc3_html = desc3[i].replace('"', '\\"').replace('\n', '
') desc4_html = desc4[i].replace('"', '\\"').replace('\n', '
') desc5_html = desc5[i].replace('"', '\\"').replace('\n', '
') js_desc1.append(f'"{desc1_html}"') js_desc2.append(f'"{desc2_html}"') js_desc3.append(f'"{desc3_html}"') js_desc4.append(f'"{desc4_html}"') js_desc5.append(f'"{desc5_html}"') # Add JavaScript to handle randomization and image display html_content += f''' ''' with open(output_file, 'w', encoding='utf-8') as f: f.write(html_content) print(f"Rating form with 5 models has been generated as {output_file}") def generate_rating_html4(image_paths, image_ids, desc1, desc2, desc3, desc4, output_file='gallery_with_ratings.html'): # Start of HTML content html_content = ''' Image Gallery with Ratings
''' # Create JavaScript arrays for each piece of data js_image_paths = [] js_image_ids = [] js_desc1 = [] js_desc2 = [] js_desc3 = [] js_desc4 = [] for i in range(len(image_paths)): js_image_paths.append(f'"{image_paths[i]}"') js_image_ids.append(f'"{image_ids[i]}"') # Process descriptions to properly handle line breaks - replace \n with
for HTML rendering desc1_html = desc1[i].replace('"', '\\"').replace('\n', '
') desc2_html = desc2[i].replace('"', '\\"').replace('\n', '
') desc3_html = desc3[i].replace('"', '\\"').replace('\n', '
') desc4_html = desc4[i].replace('"', '\\"').replace('\n', '
') js_desc1.append(f'"{desc1_html}"') js_desc2.append(f'"{desc2_html}"') js_desc3.append(f'"{desc3_html}"') js_desc4.append(f'"{desc4_html}"') # Add JavaScript to handle randomization and image display html_content += f''' ''' with open(output_file, 'w', encoding='utf-8') as f: f.write(html_content) print(f"Rating form with 4 models has been generated as {output_file}")