Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -82,7 +82,7 @@ def transfer_to_structure(pptx_file, images_dir_path):
|
|
82 |
slide_item[f"shape_{j}"] = shape_item
|
83 |
item[f"slide_{i}"] = slide_item
|
84 |
|
85 |
-
return print_json(item)
|
86 |
|
87 |
def copy_font_style(original_run, new_run):
|
88 |
new_run.font.name = original_run.font.name
|
@@ -96,15 +96,16 @@ def process_pptx(pptx_file):
|
|
96 |
images_dir_path = "images"
|
97 |
if not os.path.exists(images_dir_path):
|
98 |
os.makedirs(images_dir_path)
|
99 |
-
|
|
|
100 |
|
101 |
# Gradio interface
|
102 |
iface = gr.Interface(
|
103 |
fn=process_pptx,
|
104 |
inputs=gr.File(label="Upload PowerPoint File"),
|
105 |
-
outputs=gr.Textbox(label="JSON Output"),
|
106 |
title="PowerPoint to JSON Converter",
|
107 |
-
description="Upload a PowerPoint file to convert its structure to JSON."
|
108 |
)
|
109 |
|
110 |
iface.launch()
|
|
|
82 |
slide_item[f"shape_{j}"] = shape_item
|
83 |
item[f"slide_{i}"] = slide_item
|
84 |
|
85 |
+
return print_json(item), [os.path.join(images_dir_path, f"picture_{j}.png") for j in range(len(slide.shapes))]
|
86 |
|
87 |
def copy_font_style(original_run, new_run):
|
88 |
new_run.font.name = original_run.font.name
|
|
|
96 |
images_dir_path = "images"
|
97 |
if not os.path.exists(images_dir_path):
|
98 |
os.makedirs(images_dir_path)
|
99 |
+
json_output, image_paths = transfer_to_structure(pptx_file.name, images_dir_path)
|
100 |
+
return json_output, image_paths
|
101 |
|
102 |
# Gradio interface
|
103 |
iface = gr.Interface(
|
104 |
fn=process_pptx,
|
105 |
inputs=gr.File(label="Upload PowerPoint File"),
|
106 |
+
outputs=[gr.Textbox(label="JSON Output"), gr.Gallery(label="Extracted Images")],
|
107 |
title="PowerPoint to JSON Converter",
|
108 |
+
description="Upload a PowerPoint file to convert its structure to JSON and display extracted images."
|
109 |
)
|
110 |
|
111 |
iface.launch()
|