RamAnanth1 commited on
Commit
c1fcf29
β€’
1 Parent(s): a92b0d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +72 -11
app.py CHANGED
@@ -108,8 +108,7 @@ def save_results(videos,
108
 
109
  return os.path.join(save_subdir, f"{save_name}_{i:03d}.mp4")
110
 
111
- def get_video(prompt):
112
- seed = 1000
113
  seed_everything(seed)
114
  samples = sample_text2video(model, prompt, n_samples = 1, batch_size = 1,
115
  sampler=ddim_sampler,
@@ -119,12 +118,74 @@ def get_video(prompt):
119
  title = 'Latent Video Diffusion Models'
120
  DESCRIPTION = '<p>This model can only be used for non-commercial purposes. To learn more about the model, take a look at the <a href="https://github.com/VideoCrafter/VideoCrafter" style="text-decoration: underline;" target="_blank">model card</a>.</p>'
121
 
122
- prompt_inp = gr.Textbox(label = "Prompt")
123
- result = gr.Video(label='Result')
124
- iface = gr.Interface(fn=get_video,
125
- inputs=[prompt_inp],
126
- outputs=[result],
127
- title = title,
128
- description = DESCRIPTION,
129
- examples = [["An astronaut riding a horse"]])
130
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  return os.path.join(save_subdir, f"{save_name}_{i:03d}.mp4")
110
 
111
+ def get_video(prompt, seed):
 
112
  seed_everything(seed)
113
  samples = sample_text2video(model, prompt, n_samples = 1, batch_size = 1,
114
  sampler=ddim_sampler,
 
118
  title = 'Latent Video Diffusion Models'
119
  DESCRIPTION = '<p>This model can only be used for non-commercial purposes. To learn more about the model, take a look at the <a href="https://github.com/VideoCrafter/VideoCrafter" style="text-decoration: underline;" target="_blank">model card</a>.</p>'
120
 
121
+ with gr.Blocks(css='style.css') as demo:
122
+ gr.Markdown(DESCRIPTION)
123
+ with gr.Group():
124
+ with gr.Box():
125
+ with gr.Row(elem_id='prompt-container').style(equal_height=True):
126
+ prompt = gr.Text(
127
+ label='Prompt',
128
+ show_label=False,
129
+ max_lines=1,
130
+ placeholder='Enter your prompt',
131
+ elem_id='prompt-text-input').style(container=False)
132
+ run_button = gr.Button('Generate video').style(
133
+ full_width=False)
134
+ result = gr.Video(label='Result', show_label=False, elem_id='gallery')
135
+ with gr.Accordion('Advanced options', open=False):
136
+ seed = gr.Slider(
137
+ label='Seed',
138
+ minimum=-1,
139
+ maximum=1000000,
140
+ step=1,
141
+ value=-1,
142
+ info='If set to -1, a different seed will be used each time.')
143
+ # num_frames = gr.Slider(
144
+ # label='Number of frames',
145
+ # minimum=16,
146
+ # maximum=MAX_NUM_FRAMES,
147
+ # step=1,
148
+ # value=16,
149
+ # info=
150
+ # 'Note that the content of the video also changes when you change the number of frames.'
151
+ # )
152
+ # num_inference_steps = gr.Slider(label='Number of inference steps',
153
+ # minimum=10,
154
+ # maximum=50,
155
+ # step=1,
156
+ # value=25)
157
+
158
+ inputs = [
159
+ prompt,
160
+ seed,
161
+ # num_frames,
162
+ # num_inference_steps,
163
+ ]
164
+ gr.Examples(examples=[["Astronaut riding a horse", 1000]],
165
+ inputs=inputs,
166
+ outputs=result,
167
+ fn=get_video,
168
+ cache_examples=True)
169
+
170
+ prompt.submit(fn=get_video, inputs=inputs, outputs=result)
171
+ run_button.click(fn=get_video, inputs=inputs, outputs=result)
172
+
173
+ # with gr.Accordion(label='Biases and content acknowledgment', open=False):
174
+ # gr.HTML("""<div class="acknowledgments">
175
+ # <h4>Biases and content acknowledgment</h4>
176
+ # <p>
177
+ # Despite how impressive being able to turn text into video is, beware to the fact that this model may output content that reinforces or exacerbates societal biases. The training data includes LAION5B, ImageNet, Webvid and other public datasets. The model was not trained to realistically represent people or events, so using it to generate such content is beyond the model's capabilities.
178
+ # </p>
179
+ # <p>
180
+ # It is not intended to generate content that is demeaning or harmful to people or their environment, culture, religion, etc. Similarly, it is not allowed to generate pornographic, violent and bloody content generation. <b>The model is meant for research purposes</b>.
181
+ # </p>
182
+ # <p>
183
+ # To learn more about the model, head to its <a href="https://huggingface.co/damo-vilab/modelscope-damo-text-to-video-synthesis" style="text-decoration: underline;" target="_blank">model card</a>.
184
+ # </p>
185
+ # </div>
186
+ # """)
187
+
188
+
189
+ demo.queue(api_open=False, max_size=15).launch()
190
+
191
+