Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ from diffusers import AnimateDiffPipeline, MotionAdapter, DDIMScheduler
|
|
| 4 |
from diffusers.utils import export_to_gif
|
| 5 |
import random
|
| 6 |
|
| 7 |
-
def generate_gif(image, animation_type):
|
| 8 |
# Load the motion adapter
|
| 9 |
adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-2", torch_dtype=torch.float16)
|
| 10 |
|
|
@@ -35,10 +35,9 @@ def generate_gif(image, animation_type):
|
|
| 35 |
|
| 36 |
# Generate a random seed
|
| 37 |
seed = random.randint(0, 2**32 - 1)
|
| 38 |
-
prompt = "best quality, high quality, trending on artstation"
|
| 39 |
|
| 40 |
# Set adapter weights for the selected adapter
|
| 41 |
-
adapter_weight = [
|
| 42 |
|
| 43 |
pipe.set_adapters([animation_type], adapter_weights=adapter_weight)
|
| 44 |
|
|
@@ -60,10 +59,15 @@ def generate_gif(image, animation_type):
|
|
| 60 |
# Gradio interface
|
| 61 |
iface = gr.Interface(
|
| 62 |
fn=generate_gif,
|
| 63 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
outputs=gr.Image(type="pil", label="Generated GIF"),
|
| 65 |
title="AnimateDiff + IP Adapter Demo",
|
| 66 |
-
description="Upload an image
|
| 67 |
)
|
| 68 |
|
| 69 |
-
iface.launch(debug=True,share=True)
|
|
|
|
| 4 |
from diffusers.utils import export_to_gif
|
| 5 |
import random
|
| 6 |
|
| 7 |
+
def generate_gif(image, animation_type, prompt, adapter_strength):
|
| 8 |
# Load the motion adapter
|
| 9 |
adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-2", torch_dtype=torch.float16)
|
| 10 |
|
|
|
|
| 35 |
|
| 36 |
# Generate a random seed
|
| 37 |
seed = random.randint(0, 2**32 - 1)
|
|
|
|
| 38 |
|
| 39 |
# Set adapter weights for the selected adapter
|
| 40 |
+
adapter_weight = [adapter_strength]
|
| 41 |
|
| 42 |
pipe.set_adapters([animation_type], adapter_weights=adapter_weight)
|
| 43 |
|
|
|
|
| 59 |
# Gradio interface
|
| 60 |
iface = gr.Interface(
|
| 61 |
fn=generate_gif,
|
| 62 |
+
inputs=[
|
| 63 |
+
gr.Image(type="pil"),
|
| 64 |
+
gr.Radio(["zoom-out", "tilt-up", "pan-left"]),
|
| 65 |
+
gr.Textbox(label="Prompt"),
|
| 66 |
+
gr.Slider(minimum=0, maximum=4, step=0.1, default=1, label="IP Adapter Strength")
|
| 67 |
+
],
|
| 68 |
outputs=gr.Image(type="pil", label="Generated GIF"),
|
| 69 |
title="AnimateDiff + IP Adapter Demo",
|
| 70 |
+
description="Upload an image, select a motion module type, and adjust the prompt and IP Adapter strength to generate a GIF!"
|
| 71 |
)
|
| 72 |
|
| 73 |
+
iface.launch(debug=True, share=True)
|