akhaliq HF staff commited on
Commit
19dbe8c
1 Parent(s): 09c7d4d

update to use gr Examples

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -18,8 +18,6 @@ NOTES = 'This app is adapted from <a href="https://github.com/hysts/CogVideo_dem
18
  FOOTER = '<img id="visitor-badge" alt="visitor badge" src="https://visitor-badge.glitch.me/badge?page_id=THUDM.CogVideo" />'
19
 
20
 
21
- def set_example_text(example: list) -> dict:
22
- return gr.Textbox.update(value=example[0])
23
 
24
 
25
  def main():
@@ -48,7 +46,11 @@ def main():
48
 
49
  with open('samples.txt') as f:
50
  samples = [[line.strip()] for line in f.readlines()]
51
- examples = gr.Dataset(components=[text], samples=samples)
 
 
 
 
52
 
53
  with gr.Column():
54
  with gr.Group():
@@ -74,12 +76,8 @@ def main():
74
  result_video,
75
  result_gallery,
76
  ])
77
- examples.click(fn=set_example_text,
78
- inputs=examples,
79
- outputs=examples.components,
80
- queue=False)
81
 
82
- demo.launch(enable_queue=True, share=False)
83
 
84
 
85
  if __name__ == '__main__':
 
18
  FOOTER = '<img id="visitor-badge" alt="visitor badge" src="https://visitor-badge.glitch.me/badge?page_id=THUDM.CogVideo" />'
19
 
20
 
 
 
21
 
22
 
23
  def main():
 
46
 
47
  with open('samples.txt') as f:
48
  samples = [[line.strip()] for line in f.readlines()]
49
+ examples = gr.Examples(examples=samples,
50
+ fn=model.run_with_translation,
51
+ inputs=[text,translate,seed,only_first_stage],
52
+ outputs=[translated_text,result_video,result_gallery],
53
+ cache_examples=True)
54
 
55
  with gr.Column():
56
  with gr.Group():
 
76
  result_video,
77
  result_gallery,
78
  ])
 
 
 
 
79
 
80
+ demo.launch()
81
 
82
 
83
  if __name__ == '__main__':