Spaces:
Runtime error
Runtime error
besarismaili
commited on
Commit
·
0b11a54
1
Parent(s):
c02f1e3
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,13 @@
|
|
1 |
-
#@title Connect to the Stability API
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
from stability_sdk.api import Context
|
5 |
-
from stability_sdk.
|
6 |
|
7 |
from dotenv import load_dotenv
|
8 |
|
9 |
load_dotenv(".env")
|
10 |
|
11 |
-
|
12 |
-
STABILITY_HOST = "grpc.stability.ai:443" #@param {type:"string"}
|
13 |
STABILITY_KEY = os.getenv("STABILITY_KEY")
|
14 |
|
15 |
# Connect to Stability API
|
@@ -19,12 +17,42 @@ context = Context(STABILITY_HOST, STABILITY_KEY)
|
|
19 |
context.get_user_info()
|
20 |
print("Connection successful!")
|
21 |
|
22 |
-
#@title Animation UI
|
23 |
-
show_ui_in_notebook = True #@param {type:"boolean"}
|
24 |
-
|
25 |
outputs_path = r'C:\Work\tst\SAnim'
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
with gr.Blocks() as demo:
|
28 |
gr.Markdown("Stability Animation")
|
|
|
|
|
|
|
|
|
29 |
|
30 |
demo.launch()
|
|
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
from stability_sdk.api import Context
|
4 |
+
from stability_sdk.animation import AnimationArgs, Animator
|
5 |
|
6 |
from dotenv import load_dotenv
|
7 |
|
8 |
load_dotenv(".env")
|
9 |
|
10 |
+
STABILITY_HOST = "grpc.stability.ai:443"
|
|
|
11 |
STABILITY_KEY = os.getenv("STABILITY_KEY")
|
12 |
|
13 |
# Connect to Stability API
|
|
|
17 |
context.get_user_info()
|
18 |
print("Connection successful!")
|
19 |
|
|
|
|
|
|
|
20 |
outputs_path = r'C:\Work\tst\SAnim'
|
21 |
|
22 |
+
def anim(f_promt, s_promt):
|
23 |
+
# Configure the animation
|
24 |
+
args = AnimationArgs()
|
25 |
+
args.interpolate_prompts = True
|
26 |
+
args.locked_seed = True
|
27 |
+
args.max_frames = 48
|
28 |
+
args.seed = 42
|
29 |
+
args.strength_curve = "0:(0)"
|
30 |
+
args.diffusion_cadence_curve = "0:(4)"
|
31 |
+
args.cadence_interp = "film"
|
32 |
+
|
33 |
+
animation_prompts = {
|
34 |
+
0: f_promt,
|
35 |
+
24: s_promt,
|
36 |
+
}
|
37 |
+
negative_prompt = ""
|
38 |
+
|
39 |
+
# Create Animator object to orchestrate the rendering
|
40 |
+
animator = Animator(
|
41 |
+
api_context=context,
|
42 |
+
animation_prompts=animation_prompts,
|
43 |
+
negative_prompt=negative_prompt,
|
44 |
+
args=args
|
45 |
+
)
|
46 |
+
|
47 |
+
# Render each frame of animation
|
48 |
+
for idx, frame in enumerate(animator.render()):
|
49 |
+
frame.save(f"frame_{idx:05d}.png")
|
50 |
+
|
51 |
with gr.Blocks() as demo:
|
52 |
gr.Markdown("Stability Animation")
|
53 |
+
f_promt = gr.Textbox(label="Fist Promt", value="a photo of a cute cat")
|
54 |
+
s_promt = gr.Textbox(label="Fist Promt", value="a photo of a cute dog")
|
55 |
+
btn = gr.Button('Anim')
|
56 |
+
btn.click(fn=anim, inputs=[f_promt,s_promt], outputs=[],api_name="AnimAPI")
|
57 |
|
58 |
demo.launch()
|