Spaces:
Runtime error
Runtime error
Commit
·
af6d115
1
Parent(s):
02d0fb2
app.py
CHANGED
@@ -23,7 +23,7 @@ def anim(f_promt, s_promt, stability_key):
|
|
23 |
args = AnimationArgs()
|
24 |
args.interpolate_prompts = True
|
25 |
args.locked_seed = True
|
26 |
-
args.max_frames =
|
27 |
args.seed = 42
|
28 |
args.strength_curve = "0:(0)"
|
29 |
args.diffusion_cadence_curve = "0:(4)"
|
@@ -31,7 +31,7 @@ def anim(f_promt, s_promt, stability_key):
|
|
31 |
|
32 |
animation_prompts = {
|
33 |
0: f_promt,
|
34 |
-
|
35 |
}
|
36 |
negative_prompt = ""
|
37 |
|
@@ -42,23 +42,20 @@ def anim(f_promt, s_promt, stability_key):
|
|
42 |
negative_prompt=negative_prompt,
|
43 |
args=args
|
44 |
)
|
|
|
|
|
45 |
|
46 |
-
#
|
47 |
-
|
48 |
-
file_path = os.path.join("output", f"frame_{idx:05d}.png")
|
49 |
-
frame.save(file_path)
|
50 |
-
yield file_path
|
51 |
-
|
52 |
-
def file():
|
53 |
-
# Get current working directory
|
54 |
-
app_dir = os.getcwd()
|
55 |
-
|
56 |
-
# Set output folder for files
|
57 |
-
output_dir = os.path.join(app_dir, "moutput")
|
58 |
|
59 |
if not os.path.exists(output_dir):
|
60 |
os.makedirs(output_dir)
|
61 |
print("Created folder at:"+output_dir)
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
with gr.Blocks() as demo:
|
64 |
gr.Markdown("Stability Animation")
|
@@ -68,10 +65,6 @@ with gr.Blocks() as demo:
|
|
68 |
|
69 |
outimg = gr.Files(label="Generated Files")
|
70 |
btn = gr.Button('Anim')
|
71 |
-
fbtn = gr.Button('Get Dir')
|
72 |
-
files = gr.Text()
|
73 |
-
|
74 |
-
fbtn.click(fn=file, inputs=[], outputs=[files])
|
75 |
|
76 |
btn.click(fn=anim, inputs=[f_promt, s_promt, stability_key], outputs=[outimg],api_name="AnimAPI")
|
77 |
|
|
|
23 |
args = AnimationArgs()
|
24 |
args.interpolate_prompts = True
|
25 |
args.locked_seed = True
|
26 |
+
args.max_frames = 5
|
27 |
args.seed = 42
|
28 |
args.strength_curve = "0:(0)"
|
29 |
args.diffusion_cadence_curve = "0:(4)"
|
|
|
31 |
|
32 |
animation_prompts = {
|
33 |
0: f_promt,
|
34 |
+
2: s_promt,
|
35 |
}
|
36 |
negative_prompt = ""
|
37 |
|
|
|
42 |
negative_prompt=negative_prompt,
|
43 |
args=args
|
44 |
)
|
45 |
+
# Get root folder of the repository
|
46 |
+
repo_dir = os.path.dirname(os.path.abspath(__file__))
|
47 |
|
48 |
+
# Define output folder path
|
49 |
+
output_dir = os.path.join(repo_dir, "Outputs")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
if not os.path.exists(output_dir):
|
52 |
os.makedirs(output_dir)
|
53 |
print("Created folder at:"+output_dir)
|
54 |
+
# Render each frame of animation
|
55 |
+
for idx, frame in enumerate(animator.render()):
|
56 |
+
file_path = os.path.join(output_dir, f"frame_{idx:05d}.png")
|
57 |
+
frame.save(file_path)
|
58 |
+
yield file_path
|
59 |
|
60 |
with gr.Blocks() as demo:
|
61 |
gr.Markdown("Stability Animation")
|
|
|
65 |
|
66 |
outimg = gr.Files(label="Generated Files")
|
67 |
btn = gr.Button('Anim')
|
|
|
|
|
|
|
|
|
68 |
|
69 |
btn.click(fn=anim, inputs=[f_promt, s_promt, stability_key], outputs=[outimg],api_name="AnimAPI")
|
70 |
|