Spaces:
Runtime error
Runtime error
Commit
·
d5d86d7
1
Parent(s):
bafe3e0
- .gitignore +2 -1
- app.py +8 -4
.gitignore
CHANGED
@@ -110,4 +110,5 @@ venv.bak/
|
|
110 |
*.pt
|
111 |
|
112 |
# Files
|
113 |
-
api.py
|
|
|
|
110 |
*.pt
|
111 |
|
112 |
# Files
|
113 |
+
api.py
|
114 |
+
/frames
|
app.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
import os
|
|
|
|
|
2 |
import gradio as gr
|
3 |
from stability_sdk.api import Context
|
4 |
from stability_sdk.animation import AnimationArgs, Animator
|
@@ -43,10 +45,12 @@ def anim(f_promt, s_promt, stability_key):
|
|
43 |
|
44 |
# Render each frame of animation
|
45 |
for idx, frame in enumerate(animator.render()):
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
50 |
with gr.Blocks() as demo:
|
51 |
gr.Markdown("Stability Animation")
|
52 |
f_promt = gr.Textbox(label="First Prompt", value="a photo of a cute cat")
|
|
|
1 |
import os
|
2 |
+
import io
|
3 |
+
import base64
|
4 |
import gradio as gr
|
5 |
from stability_sdk.api import Context
|
6 |
from stability_sdk.animation import AnimationArgs, Animator
|
|
|
45 |
|
46 |
# Render each frame of animation
|
47 |
for idx, frame in enumerate(animator.render()):
|
48 |
+
# Convert PIL Image to base64
|
49 |
+
buffered = io.BytesIO()
|
50 |
+
frame.save(buffered, format="PNG")
|
51 |
+
img_str = base64.b64encode(buffered.getvalue()).decode()
|
52 |
+
yield img_str # Yield the base64 string of the generated frame
|
53 |
+
|
54 |
with gr.Blocks() as demo:
|
55 |
gr.Markdown("Stability Animation")
|
56 |
f_promt = gr.Textbox(label="First Prompt", value="a photo of a cute cat")
|