amos1088 commited on
Commit
24a908d
·
1 Parent(s): d86c8f3

test gradio

Browse files
Files changed (1) hide show
  1. app.py +4 -35
app.py CHANGED
@@ -82,51 +82,20 @@ gif_pipe.load_lora_weights(lora_adapter_id, adapter_name="motion_lora")
82
 
83
  @spaces.GPU
84
  def generate_gif(prompt, reference_image, controlnet_conditioning_scale,style_conditioning_scale,num_frames):
85
- massage_history = [{"role": "system", "content": """
86
- You are a scene designer tasked with creating sparse frames of a video. You will be given a prompt describing the desired video, and your goal is to design only the key frames (sparse frames) that represent major changes in the scene. Do not include repetitive or similar scenes—only capture distinct moments.
87
-
88
- Expected Format:
89
- Return the response as a JSON object with the key "frames". The value should be a list of dictionaries, where each dictionary has:
90
-
91
- "frame_index": an integer indicating the frame's position in the sequence.
92
- "description": a brief description of the scene in this frame.
93
- Example:
94
- If given a prompt like "A sunset over a beach with waves crashing and a ship sailing by," your response should look like this:
95
-
96
- ```json
97
- {
98
- "frames": [
99
- {"frame_index": 0, "description": "Sunset over an empty beach, sky turning orange and pink"},
100
- {"frame_index": 30, "description": "Waves gently crashing on the shore"},
101
- {"frame_index": 60, "description": "A ship appears on the horizon, silhouetted by the sunset"},
102
- {"frame_index": 90, "description": "Ship sailing closer, with waves becoming more dynamic"},
103
- {"frame_index": 120, "description": "Sun dipping below the horizon, casting a golden glow over the water"}
104
- ]
105
- }
106
- ```
107
- This way, each frame represents a distinct scene, and there’s no redundancy between them."""},
108
- {"role": "user", "content": f"give me the frames to generate a video with prompt : `{prompt}`"},]
109
- frames = ask_gpt(massage_history,return_str=False)['frames']
110
- conditioning_frames = []
111
- controlnet_frame_indices =[]
112
- frames = frames[0:1]
113
- for frame in frames:
114
- conditioning_frames.append(generate_image(frame['description'], reference_image, float(style_conditioning_scale)))
115
- controlnet_frame_indices.append(frame['frame_index'])
116
- yield (conditioning_frames, "output.gif")
117
 
118
  video = gif_pipe(
119
  prompt=prompt,
120
  negative_prompt="low quality, worst quality",
121
  num_inference_steps=25,
122
- conditioning_frames=conditioning_frames,
123
- controlnet_frame_indices=controlnet_frame_indices,
124
  controlnet_conditioning_scale=float(controlnet_conditioning_scale),
125
  num_frames=int(num_frames)
126
  ).frames[0]
127
  export_to_gif(video, "output.gif")
128
 
129
- yield (conditioning_frames, "output.gif")
130
 
131
  # Set up Gradio interface
132
  interface = gr.Interface(
 
82
 
83
  @spaces.GPU
84
  def generate_gif(prompt, reference_image, controlnet_conditioning_scale,style_conditioning_scale,num_frames):
85
+ style_image = generate_image(prompt, reference_image, float(style_conditioning_scale))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
  video = gif_pipe(
88
  prompt=prompt,
89
  negative_prompt="low quality, worst quality",
90
  num_inference_steps=25,
91
+ conditioning_frames=[style_image],
92
+ controlnet_frame_indices=[0],
93
  controlnet_conditioning_scale=float(controlnet_conditioning_scale),
94
  num_frames=int(num_frames)
95
  ).frames[0]
96
  export_to_gif(video, "output.gif")
97
 
98
+ yield ([style_image], "output.gif")
99
 
100
  # Set up Gradio interface
101
  interface = gr.Interface(