Spaces:
Runtime error
Runtime error
| # text_to_video.py | |
| import streamlit as st | |
| import replicate | |
| import os | |
| def generate_video(text_prompt, additional_context): | |
| try: | |
| # Ensure the API key is set | |
| if "REPLICATE_API_TOKEN" not in os.environ: | |
| raise ValueError("REPLICATE_API_TOKEN is not set in environment variables") | |
| input_data = { | |
| "prompt": text_prompt, | |
| "num_frames": additional_context.get('num_frames', 49), | |
| "guidance_scale": additional_context.get('guidance_scale', 6), | |
| "num_inference_steps": additional_context.get('num_inference_steps', 50) | |
| } | |
| output = replicate.run( | |
| "thudm/cogvideox-t2v:e047b1d734c550671fb4de7f7df7f9341ed498b4aa7cd88b82533b60dfec33e3", | |
| input=input_data | |
| ) | |
| return output | |
| except Exception as e: | |
| st.error(f"Error in generate_video: {str(e)}") | |
| return None | |
| def process_text_to_video(result): | |
| if result is None: | |
| st.error("Failed to generate video. Please check the logs for more details.") | |
| return | |
| try: | |
| # Display the generated video | |
| st.write("### Generated Video") | |
| st.video(result) | |
| # Display additional information | |
| st.write("### Generation Details") | |
| st.write(f"- Video URL: {result}") | |
| except Exception as e: | |
| st.error(f"Error processing data for Text to Video: {e}") | |
| st.write("Please check the structure of the API response:") | |
| st.write(result) | |
| # import replicate | |
| # output = replicate.run( | |
| # "thudm/cogvideox-t2v:e047b1d734c550671fb4de7f7df7f9341ed498b4aa7cd88b82533b60dfec33e3", | |
| # input={ | |
| # "prompt": "10-second clip. Muscular man climbs roaring waterfall, carrying massive stone lingam on shoulders. Start with wide shot of waterfall. Zoom in to reveal straining hero, wet skin glistening. Pan up his body to determined face. Water sprays around him. Cut to cheering villagers below. Return to hero pushing upward. End with top-down view, showing height of climb. Mist, lush greenery in background. Intense orchestral music builds throughout. Slow-motion effects for emphasis. Vibrant colors, hyper-realistic water effects.", | |
| # "num_frames": 49, | |
| # "guidance_scale": 6, | |
| # "num_inference_steps": 50 | |
| # } | |
| # ) | |
| # print(output) |