Spaces:
Runtime error
Runtime error
besarismaili
commited on
Commit
•
ff3c6aa
1
Parent(s):
91ed88f
- animate.py +29 -0
- app.py +31 -0
- requirements.txt +1 -0
animate.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from stability_sdk.animation import AnimationArgs, Animator
|
2 |
+
|
3 |
+
# Configure the animation
|
4 |
+
args = AnimationArgs()
|
5 |
+
args.interpolate_prompts = True
|
6 |
+
args.locked_seed = True
|
7 |
+
args.max_frames = 48
|
8 |
+
args.seed = 42
|
9 |
+
args.strength_curve = "0:(0)"
|
10 |
+
args.diffusion_cadence_curve = "0:(4)"
|
11 |
+
args.cadence_interp = "film"
|
12 |
+
|
13 |
+
animation_prompts = {
|
14 |
+
0: "a photo of a cute cat",
|
15 |
+
24: "a photo of a cute dog",
|
16 |
+
}
|
17 |
+
negative_prompt = ""
|
18 |
+
|
19 |
+
# Create Animator object to orchestrate the rendering
|
20 |
+
animator = Animator(
|
21 |
+
api_context=context,
|
22 |
+
animation_prompts=animation_prompts,
|
23 |
+
negative_prompt=negative_prompt,
|
24 |
+
args=args
|
25 |
+
)
|
26 |
+
|
27 |
+
# Render each frame of animation
|
28 |
+
for idx, frame in enumerate(animator.render()):
|
29 |
+
frame.save(f"frame_{idx:05d}.png")
|
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#@title Connect to the Stability API
|
2 |
+
import os
|
3 |
+
from stability_sdk.api import Context
|
4 |
+
from stability_sdk.animation_ui import create_ui
|
5 |
+
|
6 |
+
# @markdown To get your API key visit https://dreamstudio.ai/account
|
7 |
+
STABILITY_HOST = "grpc.stability.ai:443" #@param {type:"string"}
|
8 |
+
STABILITY_KEY = os.getenv("STABILITY_KEY")
|
9 |
+
|
10 |
+
# Connect to Stability API
|
11 |
+
context = Context(STABILITY_HOST, STABILITY_KEY)
|
12 |
+
|
13 |
+
# Test the connection
|
14 |
+
context.get_user_info()
|
15 |
+
print("Connection successful!")
|
16 |
+
|
17 |
+
#@title Animation UI
|
18 |
+
show_ui_in_notebook = True #@param {type:"boolean"}
|
19 |
+
|
20 |
+
outputs_path = r'C:\Work\tst\SAnim'
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
# Create UI
|
25 |
+
interface = create_ui(context, outputs_path)
|
26 |
+
|
27 |
+
# Set concurrency_limit on the Interface
|
28 |
+
interface = gr.Interface(fn=interface.fn, inputs=interface.inputs, outputs=interface.outputs, concurrency_limit=2)
|
29 |
+
|
30 |
+
# Launch the UI
|
31 |
+
interface.launch(show_api=False, debug=True, inline=show_ui_in_notebook, height=768, share=True, show_error=True)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
stability-sdk[anim_ui]
|