Spaces:
Running
Running
File size: 1,140 Bytes
7b01213 767e123 7b01213 b549d4a 7b01213 7729519 7b01213 c6991f1 7b01213 a1a59ce 93d1495 7b01213 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
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) |