Spaces:
Runtime error
Runtime error
Daniel Gil-U Fuhge
commited on
Commit
·
9484460
1
Parent(s):
5340dd0
Bugfix DeepSvg
Browse files- animationPipeline.py +5 -2
- app.py +7 -4
animationPipeline.py
CHANGED
|
@@ -35,8 +35,10 @@ def animateLogo(path : str, targetPath : str):
|
|
| 35 |
).to(device)
|
| 36 |
|
| 37 |
model.load_state_dict(torch.load("models/animation_transformer2.pth", map_location=torch.device('cpu')), strict=False)
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
| 40 |
df = df.drop("animation_id", axis=1)
|
| 41 |
|
| 42 |
df = pd.concat([df, pd.DataFrame(0, index=df.index, columns=range(df.shape[1], df.shape[1] + 26))], axis=1, ignore_index=True).astype(float)
|
|
@@ -52,6 +54,7 @@ def animateLogo(path : str, targetPath : str):
|
|
| 52 |
result["animation_id"] = range(len(result))
|
| 53 |
print(result, path)
|
| 54 |
animate_logo(result, targetPath)
|
|
|
|
| 55 |
|
| 56 |
#logo = "data/examples/logo_181.svg"
|
| 57 |
#animateLogo(logo)
|
|
|
|
| 35 |
).to(device)
|
| 36 |
|
| 37 |
model.load_state_dict(torch.load("models/animation_transformer2.pth", map_location=torch.device('cpu')), strict=False)
|
| 38 |
+
try:
|
| 39 |
+
df = compute_embedding(path, "models/deepSVG_hierarchical_ordered.pth.tar")
|
| 40 |
+
except:
|
| 41 |
+
return False
|
| 42 |
df = df.drop("animation_id", axis=1)
|
| 43 |
|
| 44 |
df = pd.concat([df, pd.DataFrame(0, index=df.index, columns=range(df.shape[1], df.shape[1] + 26))], axis=1, ignore_index=True).astype(float)
|
|
|
|
| 54 |
result["animation_id"] = range(len(result))
|
| 55 |
print(result, path)
|
| 56 |
animate_logo(result, targetPath)
|
| 57 |
+
return True
|
| 58 |
|
| 59 |
#logo = "data/examples/logo_181.svg"
|
| 60 |
#animateLogo(logo)
|
app.py
CHANGED
|
@@ -20,7 +20,10 @@ if uploaded_file is not None:
|
|
| 20 |
f.write(uploaded_file.getbuffer())
|
| 21 |
st.success("Saved File")
|
| 22 |
sys.setrecursionlimit(1500)
|
| 23 |
-
animateLogo(path, targetPath)
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
f.write(uploaded_file.getbuffer())
|
| 21 |
st.success("Saved File")
|
| 22 |
sys.setrecursionlimit(1500)
|
| 23 |
+
success = animateLogo(path, targetPath)
|
| 24 |
+
if success:
|
| 25 |
+
with open(targetPath, "rb") as file:
|
| 26 |
+
st.write(file)
|
| 27 |
+
st.download_button('Download animated SVG', data=file, file_name=uploaded_file.name[:-4]+"_animated.svg")
|
| 28 |
+
else:
|
| 29 |
+
st.write('This SVG cannot be animated due to limitations of the used DeepSVG library. Please use another file.')
|