import gradio as gr import os import sys from animationPipeline import animateLogo import shutil def process_svg(uploaded_file): if uploaded_file is None: return None #file_details = {"FileName": uploaded_file.name, "FileType": uploaded_file.type} if not uploaded_file.name.lower().endswith('.svg'): return "Please upload an SVG file." if not os.path.exists('tempDir'): os.mkdir('tempDir') targetPath = os.path.join('tempDir', uploaded_file.name[:-4] + "_animated.svg") sys.setrecursionlimit(1500) success = animateLogo(uploaded_file.name, targetPath) if success: return targetPath else: return "This SVG cannot be animated due to limitations of the used DeepSVG library. Please use another file." iface = gr.Interface( fn=process_svg, inputs=gr.File(label="Upload SVG file", file_types=[".svg"]), outputs=gr.File(label="Download animated SVG"), title="SVG Animation Tool", description="Upload an SVG file to animate it using DeepSVG library", examples = [["svg0.svg"], ["svg1.svg"]] ) iface.launch(share = True)