import os try: from huggingface_hub import login # Try to login with token from environment variable hf_token = os.environ["HF_TOKEN"] if hf_token: login(token=hf_token) print("✅ Authenticated with Hugging Face") else: print("No HF_TOKEN found, trying without authentication...") except Exception as e: print(f"Authentication failed: {e}") import sys from test_environment import main as check_environment from test_environment import setup_environment setup_environment() # setup env os.environ["CUDA_HOME"] = "/usr/local/cuda" os.environ["LD_LIBRARY_PATH"] = "$CUDA_HOME/lib:$CUDA_HOME/lib64:$LD_LIBRARY_PATH" os.environ["PATH"] = "$CUDA_HOME/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:$PATH" if not check_environment(): sys.exit(1) from download_checkpoints import main as download_checkpoints CHECKPOINTS_PATH = "/data/checkpoints" # download checkpoints os.makedirs(CHECKPOINTS_PATH, exist_ok=True) download_checkpoints(hf_token="", output_dir=CHECKPOINTS_PATH, model="7b_av") import gradio as gr from helper import generate_video_fun # Define the Gradio Blocks interface with gr.Blocks() as demo: gr.Markdown( """ # Cosmos-Transfer1-7B-Sample-AV """ ) with gr.Row(): with gr.Column(): rgb_video_input = gr.Video(label="Input RGB Video", format="mp4") hdmap_input = gr.Video(label="Input HD Map Video", format="mp4") lidar_input = gr.Video(label="Input LiDAR Video", format="mp4") prompt_input = gr.Textbox( label="Prompt", lines=5, # value="A close-up shot captures a vibrant yellow scrubber vigorously working on a grimy plate, its bristles moving in circular motions to lift stubborn grease and food residue. The dish, once covered in remnants of a hearty meal, gradually reveals its original glossy surface. Suds form and bubble around the scrubber, creating a satisfying visual of cleanliness in progress. The sound of scrubbing fills the air, accompanied by the gentle clinking of the dish against the sink. As the scrubber continues its task, the dish transforms, gleaming under the bright kitchen lights, symbolizing the triumph of cleanliness over mess.", # noqa: E501 value="The video is captured from a camera mounted on a car. The camera is facing forward. The video showcases a scenic golden-hour drive through a suburban area, bathed in the warm, golden hues of the setting sun. The dashboard camera captures the play of light and shadow as the sun’s rays filter through the trees, casting elongated patterns onto the road. The streetlights remain off, as the golden glow of the late afternoon sun provides ample illumination. The two-lane road appears to shimmer under the soft light, while the concrete barrier on the left side of the road reflects subtle warm tones. The stone wall on the right, adorned with lush greenery, stands out vibrantly under the golden light, with the palm trees swaying gently in the evening breeze. Several parked vehicles, including white sedans and vans, are seen on the left side of the road, their surfaces reflecting the amber hues of the sunset. The trees, now highlighted in a golden halo, cast intricate shadows onto the pavement. Further ahead, houses with red-tiled roofs glow warmly in the fading light, standing out against the sky, which transitions from deep orange to soft pastel blue. As the vehicle continues, a white sedan is seen driving in the same lane, while a black sedan and a white van move further ahead. The road markings are crisp, and the entire setting radiates a peaceful, almost cinematic beauty. The golden light, combined with the quiet suburban landscape, creates an atmosphere of tranquility and warmth, making for a mesmerizing and soothing drive.", # noqa: E501 placeholder="Enter your descriptive prompt here...", ) negative_prompt_input = gr.Textbox( label="Negative Prompt", lines=3, # value="The video captures a series of frames showing ugly scenes, static with no motion, motion blur, over-saturation, shaky footage, low resolution, grainy texture, pixelated images, poorly lit areas, underexposed and overexposed scenes, poor color balance, washed out colors, choppy sequences, jerky movements, low frame rate, artifacting, color banding, unnatural transitions, outdated special effects, fake elements, unconvincing visuals, poorly edited content, jump cuts, visual noise, and flickering. Overall, the video is of poor quality.", # noqa: E501 value="The video captures a game playing, with bad crappy graphics and cartoonish frames. It represents a recording of old outdated games. The lighting looks very fake. The textures are very raw and basic. The geometries are very primitive. The images are very pixelated and of poor CG quality. There are many subtitles in the footage. Overall, the video is unrealistic at all.", # noqa: E501 placeholder="Enter what you DON'T want to see in the image...", ) with gr.Row(): randomize_seed_checkbox = gr.Checkbox(label="Randomize Seed", value=False) seed_input = gr.Slider(minimum=0, maximum=1000000, value=1, step=1, label="Seed") chunking_input = gr.Slider(minimum=0, maximum=121, value=4, step=1, label="Chunking size") generate_button = gr.Button("Generate Image") with gr.Column(): output_video = gr.Video(label="Generated Video", format="mp4") output_file = gr.File(label="Download Results") generate_button.click( fn=generate_video_fun(CHECKPOINTS_PATH), inputs=[ rgb_video_input, hdmap_input, lidar_input, prompt_input, negative_prompt_input, seed_input, randomize_seed_checkbox, chunking_input, ], outputs=[output_video, output_file, seed_input], ) if __name__ == "__main__": demo.launch() # demo.launch(server_name="0.0.0.0")