Spaces:
Running
Running
File size: 1,248 Bytes
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 38 39 40 41 42 |
import gradio as gr
import os
import sys
from animationPipeline import animateLogo
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')
path = os.path.join('tempDir', uploaded_file.name)
targetPath = os.path.join('tempDir', uploaded_file.name[:-4] + "_animated.svg")
with open(path, "wb") as f:
f.write(uploaded_file.read())
sys.setrecursionlimit(1500)
success = animateLogo(path, 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"),
gr.Textbox(label="Status")
],
title="SVG Animation Tool",
description="Upload an SVG file to animate it using DeepSVG library"
)
iface.launch(share = True) |