import gradio as gr from transformers import AutoModelForCausalLM, AutoTokenizer model_name = "THUDM/cogvlm2-video-llama3-chat" model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True) tokenizer = AutoTokenizer.from_pretrained(model_name) def generate_response(video_input): inputs = tokenizer(video_input, return_tensors="pt") outputs = model.generate(**inputs) response = tokenizer.decode(outputs[0], skip_special_tokens=True) return response iface = gr.Interface(fn=generate_response, inputs="text", outputs="text") iface.launch()