|
import gradio as gr |
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
|
|
|
|
model_name = "llava-hf/llava-v1.6-vicuna-13b-hf" |
|
tokenizer = AutoTokenizer.from_pretrained(model_name) |
|
model = AutoModelForCausalLM.from_pretrained(model_name) |
|
|
|
def generate_response(input_text): |
|
|
|
inputs = tokenizer(input_text, return_tensors="pt") |
|
outputs = model.generate(**inputs, max_length=200) |
|
response = tokenizer.decode(outputs[0], skip_special_tokens=True) |
|
return response |
|
|
|
|
|
interface = gr.Interface( |
|
fn=generate_response, |
|
inputs="text", |
|
outputs="text", |
|
title="LLaVA-v1.6-vicuna-13b", |
|
description="This is a chatbot interface for the llava-hf/llava-v1.6-vicuna-13b-hf model." |
|
) |
|
|
|
|
|
interface.launch() |
|
|