Spaces:
				
			
			
	
			
			
		Running
		
			on 
			
			Zero
	
	
	
			
			
	
	
	
	
		
		
		Running
		
			on 
			
			Zero
	
		hysts
		
	commited on
		
		
					Commit 
							
							·
						
						9d89621
	
1
								Parent(s):
							
							db52699
								
Apply pre-commit
Browse files- app.py +9 -17
- model.py +2 -2
- samples.txt +1 -1
    	
        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 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
             
            def main():
         | 
| 24 | 
             
                only_first_stage = True
         | 
| 25 | 
             
                model = AppModel(only_first_stage)
         | 
| @@ -44,9 +42,6 @@ def main(): | |
| 44 | 
             
                                    visible=not only_first_stage)
         | 
| 45 | 
             
                                run_button = gr.Button('Run')
         | 
| 46 |  | 
| 47 | 
            -
                                
         | 
| 48 | 
            -
                                
         | 
| 49 | 
            -
             | 
| 50 | 
             
                        with gr.Column():
         | 
| 51 | 
             
                            with gr.Group():
         | 
| 52 | 
             
                                translated_text = gr.Textbox(label='Translated Text')
         | 
| @@ -56,14 +51,14 @@ def main(): | |
| 56 |  | 
| 57 | 
             
                    gr.Markdown(NOTES)
         | 
| 58 | 
             
                    gr.Markdown(FOOTER)
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                    
         | 
| 61 | 
            -
             | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 |  | 
| 68 | 
             
                    run_button.click(fn=model.run_with_translation,
         | 
| 69 | 
             
                                     inputs=[
         | 
| @@ -72,10 +67,7 @@ def main(): | |
| 72 | 
             
                                         seed,
         | 
| 73 | 
             
                                         only_first_stage,
         | 
| 74 | 
             
                                     ],
         | 
| 75 | 
            -
                                     outputs=[
         | 
| 76 | 
            -
                                         translated_text,
         | 
| 77 | 
            -
                                         result_video
         | 
| 78 | 
            -
                                     ])
         | 
| 79 |  | 
| 80 | 
             
                demo.launch()
         | 
| 81 |  | 
|  | |
| 18 | 
             
            FOOTER = '<img id="visitor-badge" alt="visitor badge" src="https://visitor-badge.glitch.me/badge?page_id=THUDM.CogVideo" />'
         | 
| 19 |  | 
| 20 |  | 
|  | |
|  | |
| 21 | 
             
            def main():
         | 
| 22 | 
             
                only_first_stage = True
         | 
| 23 | 
             
                model = AppModel(only_first_stage)
         | 
|  | |
| 42 | 
             
                                    visible=not only_first_stage)
         | 
| 43 | 
             
                                run_button = gr.Button('Run')
         | 
| 44 |  | 
|  | |
|  | |
|  | |
| 45 | 
             
                        with gr.Column():
         | 
| 46 | 
             
                            with gr.Group():
         | 
| 47 | 
             
                                translated_text = gr.Textbox(label='Translated Text')
         | 
|  | |
| 51 |  | 
| 52 | 
             
                    gr.Markdown(NOTES)
         | 
| 53 | 
             
                    gr.Markdown(FOOTER)
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                    examples = gr.Examples(
         | 
| 56 | 
            +
                        examples=[['骑滑板的皮卡丘', False, 1234, True],
         | 
| 57 | 
            +
                                  ['a cat playing chess', True, 1253, True]],
         | 
| 58 | 
            +
                        fn=model.run_with_translation,
         | 
| 59 | 
            +
                        inputs=[text, translate, seed, only_first_stage],
         | 
| 60 | 
            +
                        outputs=[translated_text, result_video],
         | 
| 61 | 
            +
                        cache_examples=True)
         | 
| 62 |  | 
| 63 | 
             
                    run_button.click(fn=model.run_with_translation,
         | 
| 64 | 
             
                                     inputs=[
         | 
|  | |
| 67 | 
             
                                         seed,
         | 
| 68 | 
             
                                         only_first_stage,
         | 
| 69 | 
             
                                     ],
         | 
| 70 | 
            +
                                     outputs=[translated_text, result_video])
         | 
|  | |
|  | |
|  | |
| 71 |  | 
| 72 | 
             
                demo.launch()
         | 
| 73 |  | 
    	
        model.py
    CHANGED
    
    | @@ -1225,8 +1225,8 @@ class AppModel(Model): | |
| 1225 | 
             
                    return out_file.name
         | 
| 1226 |  | 
| 1227 | 
             
                def run_with_translation(
         | 
| 1228 | 
            -
             | 
| 1229 | 
            -
             | 
| 1230 | 
             
                    logger.info(f'{text=}, {translate=}, {seed=}, {only_first_stage=}')
         | 
| 1231 | 
             
                    if translate:
         | 
| 1232 | 
             
                        text = translated_text = self.translator(text)
         | 
|  | |
| 1225 | 
             
                    return out_file.name
         | 
| 1226 |  | 
| 1227 | 
             
                def run_with_translation(
         | 
| 1228 | 
            +
                        self, text: str, translate: bool, seed: int,
         | 
| 1229 | 
            +
                        only_first_stage: bool) -> tuple[str | None, str | None]:
         | 
| 1230 | 
             
                    logger.info(f'{text=}, {translate=}, {seed=}, {only_first_stage=}')
         | 
| 1231 | 
             
                    if translate:
         | 
| 1232 | 
             
                        text = translated_text = self.translator(text)
         | 
    	
        samples.txt
    CHANGED
    
    | @@ -1,2 +1,2 @@ | |
| 1 | 
             
            骑滑板的皮卡丘
         | 
| 2 | 
            -
            a cat playing chess
         | 
|  | |
| 1 | 
             
            骑滑板的皮卡丘
         | 
| 2 | 
            +
            a cat playing chess
         | 
