llava / app.py
BOUDELLAH's picture
Create app.py
e0776a4 verified
raw
history blame contribute delete
833 Bytes
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load the model and tokenizer
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):
# Tokenize and generate
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
# Create a Gradio interface
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."
)
# Launch the interface
interface.launch()